* [PATCH v2 0/4] drivers: new helper for ioremapping memory resources
@ 2020-03-14 5:26 Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource() Dejin Zheng
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Dejin Zheng @ 2020-03-14 5:26 UTC (permalink / raw)
To: gregkh, rafael, hminas, mathias.nyman, bgolaszewski, arnd, geert,
mchehab+samsung, treding, tglx, suzuki.poulose, hdegoede,
linux-usb
Cc: linux-kernel, Dejin Zheng
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.
The first patch in this series adds a wrapper for these two calls and
the other uses it in a driver.
Since V1:
- add some real users of this function (Thanks for greg k-h's reminder)
Dejin Zheng (4):
drivers: provide devm_platform_ioremap_and_get_resource()
usb: host: xhci-plat: convert to
devm_platform_ioremap_and_get_resource
usb: host: hisilicon: convert to
devm_platform_ioremap_and_get_resource
usb: dwc2: convert to devm_platform_ioremap_and_get_resource
drivers/base/platform.c | 18 ++++++++++++++++++
drivers/usb/dwc2/platform.c | 3 +--
drivers/usb/host/xhci-histb.c | 3 +--
drivers/usb/host/xhci-plat.c | 3 +--
include/linux/platform_device.h | 3 +++
5 files changed, 24 insertions(+), 6 deletions(-)
--
2.25.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource()
2020-03-14 5:26 [PATCH v2 0/4] drivers: new helper for ioremapping memory resources Dejin Zheng
@ 2020-03-14 5:26 ` Dejin Zheng
2020-03-15 9:47 ` Geert Uytterhoeven
2020-03-15 10:01 ` Sergei Shtylyov
2020-03-14 5:26 ` [PATCH v2 2/4] usb: host: xhci-plat: convert to devm_platform_ioremap_and_get_resource Dejin Zheng
` (2 subsequent siblings)
3 siblings, 2 replies; 8+ messages in thread
From: Dejin Zheng @ 2020-03-14 5:26 UTC (permalink / raw)
To: gregkh, rafael, hminas, mathias.nyman, bgolaszewski, arnd, geert,
mchehab+samsung, treding, tglx, suzuki.poulose, hdegoede,
linux-usb
Cc: linux-kernel, Dejin Zheng
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@gmail.com>
---
drivers/base/platform.c | 18 ++++++++++++++++++
include/linux/platform_device.h | 3 +++
2 files changed, 21 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 7fa654f1288b..b3e2409effae 100644
--- 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);
+
/**
* 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 *
--
2.25.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] usb: host: xhci-plat: convert to devm_platform_ioremap_and_get_resource
2020-03-14 5:26 [PATCH v2 0/4] drivers: new helper for ioremapping memory resources Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource() Dejin Zheng
@ 2020-03-14 5:26 ` Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 3/4] usb: host: hisilicon: " Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 4/4] usb: dwc2: " Dejin Zheng
3 siblings, 0 replies; 8+ messages in thread
From: Dejin Zheng @ 2020-03-14 5:26 UTC (permalink / raw)
To: gregkh, rafael, hminas, mathias.nyman, bgolaszewski, arnd, geert,
mchehab+samsung, treding, tglx, suzuki.poulose, hdegoede,
linux-usb
Cc: linux-kernel, Dejin Zheng
Use devm_platform_ioremap_and_get_resource() to simplify code, which
contains platform_get_resource() and devm_ioremap_resource(), it also
get the resource for use by the following code.
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
drivers/usb/host/xhci-plat.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d90cd5ec09cf..2852afa69ee9 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -219,8 +219,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_runtime;
}
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+ hcd->regs = devm_platform_ioremap_and_get_resource(pdev, 0, &res);
if (IS_ERR(hcd->regs)) {
ret = PTR_ERR(hcd->regs);
goto put_hcd;
--
2.25.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/4] usb: host: hisilicon: convert to devm_platform_ioremap_and_get_resource
2020-03-14 5:26 [PATCH v2 0/4] drivers: new helper for ioremapping memory resources Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource() Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 2/4] usb: host: xhci-plat: convert to devm_platform_ioremap_and_get_resource Dejin Zheng
@ 2020-03-14 5:26 ` Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 4/4] usb: dwc2: " Dejin Zheng
3 siblings, 0 replies; 8+ messages in thread
From: Dejin Zheng @ 2020-03-14 5:26 UTC (permalink / raw)
To: gregkh, rafael, hminas, mathias.nyman, bgolaszewski, arnd, geert,
mchehab+samsung, treding, tglx, suzuki.poulose, hdegoede,
linux-usb
Cc: linux-kernel, Dejin Zheng
Use devm_platform_ioremap_and_get_resource() to simplify code, which
contains platform_get_resource() and devm_ioremap_resource(), it also
get the resource for use by the following code.
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
drivers/usb/host/xhci-histb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci-histb.c b/drivers/usb/host/xhci-histb.c
index 3c4abb5a1c3f..a314139e5343 100644
--- a/drivers/usb/host/xhci-histb.c
+++ b/drivers/usb/host/xhci-histb.c
@@ -219,8 +219,7 @@ static int xhci_histb_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- histb->ctrl = devm_ioremap_resource(&pdev->dev, res);
+ histb->ctrl = devm_platform_ioremap_and_get_resource(pdev, 0, &res);
if (IS_ERR(histb->ctrl))
return PTR_ERR(histb->ctrl);
--
2.25.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] usb: dwc2: convert to devm_platform_ioremap_and_get_resource
2020-03-14 5:26 [PATCH v2 0/4] drivers: new helper for ioremapping memory resources Dejin Zheng
` (2 preceding siblings ...)
2020-03-14 5:26 ` [PATCH v2 3/4] usb: host: hisilicon: " Dejin Zheng
@ 2020-03-14 5:26 ` Dejin Zheng
3 siblings, 0 replies; 8+ messages in thread
From: Dejin Zheng @ 2020-03-14 5:26 UTC (permalink / raw)
To: gregkh, rafael, hminas, mathias.nyman, bgolaszewski, arnd, geert,
mchehab+samsung, treding, tglx, suzuki.poulose, hdegoede,
linux-usb
Cc: linux-kernel, Dejin Zheng
Use devm_platform_ioremap_and_get_resource() to simplify code, which
contains platform_get_resource() and devm_ioremap_resource(), it also
get the resource for use by the following code.
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
drivers/usb/dwc2/platform.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 3c6ce09a6db5..56eec2b95eaf 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -392,8 +392,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
return retval;
}
- res = platform_get_resource(dev, IORESOURCE_MEM, 0);
- hsotg->regs = devm_ioremap_resource(&dev->dev, res);
+ hsotg->regs = devm_platform_ioremap_and_get_resource(dev, 0, &res);
if (IS_ERR(hsotg->regs))
return PTR_ERR(hsotg->regs);
--
2.25.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource()
2020-03-14 5:26 ` [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource() Dejin Zheng
@ 2020-03-15 9:47 ` Geert Uytterhoeven
2020-03-15 10:01 ` Sergei Shtylyov
1 sibling, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2020-03-15 9:47 UTC (permalink / raw)
To: Dejin Zheng
Cc: Greg KH, Rafael J. Wysocki, Minas Harutyunyan, Mathias Nyman,
Bartosz Golaszewski, Arnd Bergmann, Mauro Carvalho Chehab,
Thierry Reding, Thomas Gleixner, Suzuki K Poulose, Hans de Goede,
USB list, Linux Kernel Mailing List
Hi Dejin,
On Sat, Mar 14, 2020 at 6:26 AM Dejin Zheng <zhengdejin5@gmail.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@gmail.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@linux-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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource()
2020-03-14 5:26 ` [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource() Dejin Zheng
2020-03-15 9:47 ` Geert Uytterhoeven
@ 2020-03-15 10:01 ` Sergei Shtylyov
2020-03-15 12:38 ` Dejin Zheng
1 sibling, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2020-03-15 10:01 UTC (permalink / raw)
To: Dejin Zheng, gregkh, rafael, hminas, mathias.nyman, bgolaszewski,
arnd, geert, mchehab+samsung, treding, tglx, suzuki.poulose,
hdegoede, linux-usb
Cc: linux-kernel
Hello!
On 14.03.2020 8:26, Dejin Zheng wrote:
> Since commit "drivers: provide devm_platform_ioremap_resource()",
> It was wrap platform_get_resource() and devm_ioremap_resource() as
^^ it
> 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.
Not really sure that's worth the effort...
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> ---
> drivers/base/platform.c | 18 ++++++++++++++++++
> include/linux/platform_device.h | 3 +++
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 7fa654f1288b..b3e2409effae 100644
> --- 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);
That looks more like devm_platform_get_and_ioremap_resource().
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource()
2020-03-15 10:01 ` Sergei Shtylyov
@ 2020-03-15 12:38 ` Dejin Zheng
0 siblings, 0 replies; 8+ messages in thread
From: Dejin Zheng @ 2020-03-15 12:38 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: gregkh, rafael, hminas, mathias.nyman, bgolaszewski, arnd, geert,
mchehab+samsung, treding, tglx, suzuki.poulose, hdegoede,
linux-usb, linux-kernel
On Sun, Mar 15, 2020 at 01:01:14PM +0300, Sergei Shtylyov wrote:
> Hello!
>
> On 14.03.2020 8:26, Dejin Zheng wrote:
>
> > Since commit "drivers: provide devm_platform_ioremap_resource()",
> > It was wrap platform_get_resource() and devm_ioremap_resource() as
> ^^ it
Ok and Thanks!
>
> > 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.
>
> Not really sure that's worth the effort...
>
Many drivers using platform_get_resource() and devm_ioremap_resource() together
in the kernel tree. if use this helper, have one function call less.
> > Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> > ---
> > drivers/base/platform.c | 18 ++++++++++++++++++
> > include/linux/platform_device.h | 3 +++
> > 2 files changed, 21 insertions(+)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 7fa654f1288b..b3e2409effae 100644
> > --- 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);
>
> That looks more like devm_platform_get_and_ioremap_resource().
>
Thanks for your suggestions. I will do it.
> [...]
>
> MBR, Sergei
BR,
Dejin
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-03-15 12:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 5:26 [PATCH v2 0/4] drivers: new helper for ioremapping memory resources Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 1/4] drivers: provide devm_platform_ioremap_and_get_resource() Dejin Zheng
2020-03-15 9:47 ` Geert Uytterhoeven
2020-03-15 10:01 ` Sergei Shtylyov
2020-03-15 12:38 ` Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 2/4] usb: host: xhci-plat: convert to devm_platform_ioremap_and_get_resource Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 3/4] usb: host: hisilicon: " Dejin Zheng
2020-03-14 5:26 ` [PATCH v2 4/4] usb: dwc2: " Dejin Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).