drivers: provide devm_platform_get_and_ioremap_resource()
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@linux-m68k.org> Suggested-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com> Link: https://lore.kernel.org/r/20200323160612.17277-2-zhengdejin5@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
d2e971d884
Коммит
890cc39a87
|
@ -62,6 +62,28 @@ struct resource *platform_get_resource(struct platform_device *dev,
|
||||||
EXPORT_SYMBOL_GPL(platform_get_resource);
|
EXPORT_SYMBOL_GPL(platform_get_resource);
|
||||||
|
|
||||||
#ifdef CONFIG_HAS_IOMEM
|
#ifdef CONFIG_HAS_IOMEM
|
||||||
|
/**
|
||||||
|
* 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
|
* devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
|
||||||
* device
|
* device
|
||||||
|
|
|
@ -55,6 +55,9 @@ extern struct device *
|
||||||
platform_find_device_by_driver(struct device *start,
|
platform_find_device_by_driver(struct device *start,
|
||||||
const struct device_driver *drv);
|
const struct device_driver *drv);
|
||||||
extern void __iomem *
|
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,
|
devm_platform_ioremap_resource(struct platform_device *pdev,
|
||||||
unsigned int index);
|
unsigned int index);
|
||||||
extern void __iomem *
|
extern void __iomem *
|
||||||
|
|
Загрузка…
Ссылка в новой задаче