This is a note to let you know that I've just added the patch titled drivers: provide devm_platform_get_and_ioremap_resource() to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drivers-provide-devm_platform_get_and_ioremap_resour.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit fd7faf5cca8a179c583b5138eb6565e59d24bfb9 Author: Dejin Zheng <zhengdejin5@xxxxxxxxx> Date: Tue Mar 24 00:06:08 2020 +0800 drivers: provide devm_platform_get_and_ioremap_resource() [ Upstream commit 890cc39a879906b63912482dfc41944579df2dc6 ] Since commit "drivers: provide devm_platform_ioremap_resource()", it was wrap platform_get_resource() and devm_ioremap_resource() as single helper devm_platform_ioremap_resource(). but now, many drivers still used platform_get_resource() and devm_ioremap_resource() together in the kernel tree. The reason can not be replaced is they still need use the resource variables obtained by platform_get_resource(). so provide this helper. Suggested-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Suggested-by: Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx> Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> Signed-off-by: Dejin Zheng <zhengdejin5@xxxxxxxxx> Link: https://lore.kernel.org/r/20200323160612.17277-2-zhengdejin5@xxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Stable-dep-of: 2d47b79d2bd3 ("i2c: mux: reg: check return value after calling platform_get_resource()") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ea83c279b8a3..c4e398f3de50 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -80,6 +80,28 @@ struct resource *platform_get_resource(struct platform_device *dev, } EXPORT_SYMBOL_GPL(platform_get_resource); +/** + * devm_platform_get_and_ioremap_resource - call devm_ioremap_resource() for a + * platform device and get resource + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource management + * @index: resource index + * @res: optional output parameter to store a pointer to the obtained resource. + */ +void __iomem * +devm_platform_get_and_ioremap_resource(struct platform_device *pdev, + unsigned int index, struct resource **res) +{ + struct resource *r; + + r = platform_get_resource(pdev, IORESOURCE_MEM, index); + if (res) + *res = r; + return devm_ioremap_resource(&pdev->dev, r); +} +EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource); + /** * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform * device diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 9e5c98fcea8c..1de7ea6efdc9 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -52,6 +52,9 @@ extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); extern void __iomem * +devm_platform_get_and_ioremap_resource(struct platform_device *pdev, + unsigned int index, struct resource **res); +extern void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index); extern int platform_get_irq(struct platform_device *, unsigned int);