[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdVvjvR4J-nB8zmJVH62VGvPPnsLX0+X=aC9p_Dnh_AJ9A@mail.gmail.com>
Date: Sun, 15 Mar 2020 10:47:59 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Dejin Zheng <zhengdejin5@...il.com>
Cc: Greg KH <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Minas Harutyunyan <hminas@...opsys.com>,
Mathias Nyman <mathias.nyman@...el.com>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Arnd Bergmann <arnd@...db.de>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
Thierry Reding <treding@...dia.com>,
Thomas Gleixner <tglx@...utronix.de>,
Suzuki K Poulose <suzuki.poulose@....com>,
Hans de Goede <hdegoede@...hat.com>,
USB list <linux-usb@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource()
Hi Dejin,
On Sat, Mar 14, 2020 at 6:26 AM Dejin Zheng <zhengdejin5@...il.com> 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.
>
> Signed-off-by: Dejin Zheng <zhengdejin5@...il.com>
Thanks for your patch!
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -62,6 +62,24 @@ struct resource *platform_get_resource(struct platform_device *dev,
> EXPORT_SYMBOL_GPL(platform_get_resource);
>
> #ifdef CONFIG_HAS_IOMEM
> +/**
> + * devm_platform_ioremap_and_get_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
> + */
> +void __iomem *
> +devm_platform_ioremap_and_get_resource(struct platform_device *pdev,
> + unsigned int index, struct resource **res)
> +{
> + *res = platform_get_resource(pdev, IORESOURCE_MEM, index);
> + return devm_ioremap_resource(&pdev->dev, *res);
> +}
> +EXPORT_SYMBOL_GPL(devm_platform_ioremap_and_get_resource);
As this duplicates most of the implementation of
devm_platform_ioremap_resource(),
I think it would be better to make res optional:
void __iomem *
devm_platform_ioremap_and_get_resource(struct platform_device *pdev,
unsigned int index, struct
resource **resp)
{
struct resource **res;
res = platform_get_resource(pdev, IORESOURCE_MEM, index);
if (resp)
*resp = res;
return devm_ioremap_resource(&pdev->dev, *res);
}
And implement devm_platform_ioremap_resource() by calling
devm_platform_ioremap_and_get_resource() with resp = NULL.
Whether the best way to do that is as an exported functions, or as an
inlined function, is to be seen (measure impact on kernel size).
> +
> /**
> * 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 276a03c24691..5fd1977e3eaf 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -55,6 +55,9 @@ extern struct device *
> platform_find_device_by_driver(struct device *start,
> const struct device_driver *drv);
> extern void __iomem *
> +devm_platform_ioremap_and_get_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 void __iomem *
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
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
Powered by blists - more mailing lists