Re: [PATCH v3 1/5] drivers: provide devm_platform_get_and_ioremap_resource()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dejin,

On Sun, Mar 15, 2020 at 3:05 PM Dejin Zheng <zhengdejin5@xxxxxxxxx> wrote:
> 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>
> Signed-off-by: Dejin Zheng <zhengdejin5@xxxxxxxxx>

Thanks for your patch!

> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -62,6 +62,28 @@ struct resource *platform_get_resource(struct platform_device *dev,
>  EXPORT_SYMBOL_GPL(platform_get_resource);
>
>  #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: get the resource

Optional output parameter to store a pointer to the obtained resource.

With the above changed:

Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

> + */
> +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);

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux