linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper
@ 2019-12-10 20:31 Yangtao Li
  2019-12-10 20:31 ` [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource Yangtao Li
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Yangtao Li @ 2019-12-10 20:31 UTC (permalink / raw)
  To: gregkh, rafael, srinivas.kandagatla, vz, khilman, mripard, wens,
	andriy.shevchenko, mchehab+samsung, mans, treding,
	suzuki.poulose, bgolaszewski, tglx
  Cc: linux-kernel, linux-arm-kernel, linux-amlogic, Yangtao Li

There are currently 300+ instances of using platform_get_resource_byname()
and devm_ioremap_resource() together in the kernel tree.

This patch wraps these two calls in a single helper.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/base/platform.c         | 22 +++++++++++++++++++++-
 include/linux/platform_device.h |  3 +++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b6c6c7d97d5b..9c4f5e229600 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -60,6 +60,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
 }
 EXPORT_SYMBOL_GPL(platform_get_resource);
 
+#ifdef CONFIG_HAS_IOMEM
 /**
  * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
  *				    device
@@ -68,7 +69,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
  *        resource management
  * @index: resource index
  */
-#ifdef CONFIG_HAS_IOMEM
+
 void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 					     unsigned int index)
 {
@@ -78,6 +79,25 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 	return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+
+/**
+ * devm_platform_ioremap_resource_byname - call devm_ioremap_resource() for
+ *					   a platform device
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ *        resource managemend
+ * @name: resource name
+ */
+void __iomem *
+devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+				      const char *name)
+{
+	struct resource *res;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+	return devm_ioremap_resource(&pdev->dev, res);
+}
+EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
 #endif /* CONFIG_HAS_IOMEM */
 
 static int __platform_get_irq(struct platform_device *dev, unsigned int num)
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 1b5cec067533..24ff5da9c532 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -63,6 +63,9 @@ extern int platform_irq_count(struct platform_device *);
 extern struct resource *platform_get_resource_byname(struct platform_device *,
 						     unsigned int,
 						     const char *);
+extern void __iomem *
+devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+				      const char *name);
 extern int platform_get_irq_byname(struct platform_device *, const char *);
 extern int platform_add_devices(struct platform_device **, int);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Yangtao Li
@ 2019-12-10 20:31 ` Yangtao Li
  2019-12-10 20:34   ` Frank Lee
  2019-12-18  2:46   ` Chen-Yu Tsai
  2019-12-10 20:31 ` [PATCH 2/5] nvmem: lpc18xx_otp: " Yangtao Li
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 10+ messages in thread
From: Yangtao Li @ 2019-12-10 20:31 UTC (permalink / raw)
  To: gregkh, rafael, srinivas.kandagatla, vz, khilman, mripard, wens,
	andriy.shevchenko, mchehab+samsung, mans, treding,
	suzuki.poulose, bgolaszewski, tglx
  Cc: linux-kernel, linux-arm-kernel, linux-amlogic, Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/nvmem/sunxi_sid.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c
index e26ef1bbf198..c54adf60b155 100644
--- a/drivers/nvmem/sunxi_sid.c
+++ b/drivers/nvmem/sunxi_sid.c
@@ -112,7 +112,6 @@ static int sun8i_sid_read_by_reg(void *context, unsigned int offset,
 static int sunxi_sid_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	struct nvmem_config *nvmem_cfg;
 	struct nvmem_device *nvmem;
 	struct sunxi_sid *sid;
@@ -129,8 +128,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
 		return -EINVAL;
 	sid->value_offset = cfg->value_offset;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	sid->base = devm_ioremap_resource(dev, res);
+	sid->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(sid->base))
 		return PTR_ERR(sid->base);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] nvmem: lpc18xx_otp: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Yangtao Li
  2019-12-10 20:31 ` [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource Yangtao Li
@ 2019-12-10 20:31 ` Yangtao Li
  2019-12-10 20:31 ` [PATCH 3/5] nvmem: meson-mx-efuse: " Yangtao Li
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Yangtao Li @ 2019-12-10 20:31 UTC (permalink / raw)
  To: gregkh, rafael, srinivas.kandagatla, vz, khilman, mripard, wens,
	andriy.shevchenko, mchehab+samsung, mans, treding,
	suzuki.poulose, bgolaszewski, tglx
  Cc: linux-kernel, linux-arm-kernel, linux-amlogic, Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/nvmem/lpc18xx_otp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nvmem/lpc18xx_otp.c b/drivers/nvmem/lpc18xx_otp.c
index 16c92ea85d49..8faed05e3cbe 100644
--- a/drivers/nvmem/lpc18xx_otp.c
+++ b/drivers/nvmem/lpc18xx_otp.c
@@ -68,14 +68,12 @@ static int lpc18xx_otp_probe(struct platform_device *pdev)
 {
 	struct nvmem_device *nvmem;
 	struct lpc18xx_otp *otp;
-	struct resource *res;
 
 	otp = devm_kzalloc(&pdev->dev, sizeof(*otp), GFP_KERNEL);
 	if (!otp)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	otp->base = devm_ioremap_resource(&pdev->dev, res);
+	otp->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(otp->base))
 		return PTR_ERR(otp->base);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] nvmem: meson-mx-efuse: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Yangtao Li
  2019-12-10 20:31 ` [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource Yangtao Li
  2019-12-10 20:31 ` [PATCH 2/5] nvmem: lpc18xx_otp: " Yangtao Li
@ 2019-12-10 20:31 ` Yangtao Li
  2019-12-10 20:41   ` Martin Blumenstingl
  2019-12-10 20:31 ` [PATCH 4/5] nvmem: bcm-ocotp: " Yangtao Li
  2019-12-28 17:39 ` [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Frank Lee
  4 siblings, 1 reply; 10+ messages in thread
From: Yangtao Li @ 2019-12-10 20:31 UTC (permalink / raw)
  To: gregkh, rafael, srinivas.kandagatla, vz, khilman, mripard, wens,
	andriy.shevchenko, mchehab+samsung, mans, treding,
	suzuki.poulose, bgolaszewski, tglx
  Cc: linux-kernel, linux-arm-kernel, linux-amlogic, Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/nvmem/meson-mx-efuse.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
index 07c9f38c1c60..24c6e8b15987 100644
--- a/drivers/nvmem/meson-mx-efuse.c
+++ b/drivers/nvmem/meson-mx-efuse.c
@@ -194,7 +194,6 @@ static int meson_mx_efuse_probe(struct platform_device *pdev)
 {
 	const struct meson_mx_efuse_platform_data *drvdata;
 	struct meson_mx_efuse *efuse;
-	struct resource *res;
 
 	drvdata = of_device_get_match_data(&pdev->dev);
 	if (!drvdata)
@@ -204,8 +203,7 @@ static int meson_mx_efuse_probe(struct platform_device *pdev)
 	if (!efuse)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	efuse->base = devm_ioremap_resource(&pdev->dev, res);
+	efuse->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(efuse->base))
 		return PTR_ERR(efuse->base);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] nvmem: bcm-ocotp: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Yangtao Li
                   ` (2 preceding siblings ...)
  2019-12-10 20:31 ` [PATCH 3/5] nvmem: meson-mx-efuse: " Yangtao Li
@ 2019-12-10 20:31 ` Yangtao Li
  2019-12-28 17:39 ` [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Frank Lee
  4 siblings, 0 replies; 10+ messages in thread
From: Yangtao Li @ 2019-12-10 20:31 UTC (permalink / raw)
  To: gregkh, rafael, srinivas.kandagatla, vz, khilman, mripard, wens,
	andriy.shevchenko, mchehab+samsung, mans, treding,
	suzuki.poulose, bgolaszewski, tglx
  Cc: linux-kernel, linux-arm-kernel, linux-amlogic, Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/nvmem/bcm-ocotp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c
index a8097511582a..87b7198a7676 100644
--- a/drivers/nvmem/bcm-ocotp.c
+++ b/drivers/nvmem/bcm-ocotp.c
@@ -254,7 +254,6 @@ MODULE_DEVICE_TABLE(acpi, bcm_otpc_acpi_ids);
 static int bcm_otpc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	struct otpc_priv *priv;
 	struct nvmem_device *nvmem;
 	int err;
@@ -269,8 +268,7 @@ static int bcm_otpc_probe(struct platform_device *pdev)
 		return -ENODEV;
 
 	/* Get OTP base address register. */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap_resource(dev, res);
+	priv->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->base)) {
 		dev_err(dev, "unable to map I/O memory\n");
 		return PTR_ERR(priv->base);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 ` [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource Yangtao Li
@ 2019-12-10 20:34   ` Frank Lee
  2019-12-18  2:46   ` Chen-Yu Tsai
  1 sibling, 0 replies; 10+ messages in thread
From: Frank Lee @ 2019-12-10 20:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Srini Kandagatla, vz,
	khilman, Maxime Ripard, Chen-Yu Tsai, andriy.shevchenko,
	Mauro Carvalho Chehab, mans, treding, suzuki.poulose,
	bgolaszewski, tglx
  Cc: Linux Kernel Mailing List, Linux ARM, linux-amlogic

There is no 5/5 in this patchset, a small mistake.

Thx,
Yangtao

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] nvmem: meson-mx-efuse: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 ` [PATCH 3/5] nvmem: meson-mx-efuse: " Yangtao Li
@ 2019-12-10 20:41   ` Martin Blumenstingl
  0 siblings, 0 replies; 10+ messages in thread
From: Martin Blumenstingl @ 2019-12-10 20:41 UTC (permalink / raw)
  To: Yangtao Li
  Cc: gregkh, rafael, srinivas.kandagatla, vz, khilman, mripard, wens,
	andriy.shevchenko, mchehab+samsung, mans, treding,
	suzuki.poulose, bgolaszewski, tglx, linux-amlogic, linux-kernel,
	linux-arm-kernel

On Tue, Dec 10, 2019 at 9:33 PM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

thank you for taking care of this!


Martin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource
  2019-12-10 20:31 ` [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource Yangtao Li
  2019-12-10 20:34   ` Frank Lee
@ 2019-12-18  2:46   ` Chen-Yu Tsai
  1 sibling, 0 replies; 10+ messages in thread
From: Chen-Yu Tsai @ 2019-12-18  2:46 UTC (permalink / raw)
  To: Yangtao Li, Srinivas Kandagatla, Maxime Ripard
  Cc: Greg Kroah-Hartman, rafael, Vladimir Zapolskiy, Kevin Hilman,
	Andy Shevchenko, Mauro Carvalho Chehab, Mans Rullgard,
	Thierry Reding, suzuki.poulose, Bartosz Golaszewski,
	Thomas Gleixner, linux-kernel, linux-arm-kernel,
	open list:ARM/Amlogic Meson...

On Wed, Dec 11, 2019 at 4:32 AM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>

Acked-by: Chen-Yu Tsai <wens@csie.org>

> ---
>  drivers/nvmem/sunxi_sid.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c
> index e26ef1bbf198..c54adf60b155 100644
> --- a/drivers/nvmem/sunxi_sid.c
> +++ b/drivers/nvmem/sunxi_sid.c
> @@ -112,7 +112,6 @@ static int sun8i_sid_read_by_reg(void *context, unsigned int offset,
>  static int sunxi_sid_probe(struct platform_device *pdev)
>  {
>         struct device *dev = &pdev->dev;
> -       struct resource *res;
>         struct nvmem_config *nvmem_cfg;
>         struct nvmem_device *nvmem;
>         struct sunxi_sid *sid;
> @@ -129,8 +128,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
>                 return -EINVAL;
>         sid->value_offset = cfg->value_offset;
>
> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       sid->base = devm_ioremap_resource(dev, res);
> +       sid->base = devm_platform_ioremap_resource(pdev, 0);
>         if (IS_ERR(sid->base))
>                 return PTR_ERR(sid->base);
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper
  2019-12-10 20:31 [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Yangtao Li
                   ` (3 preceding siblings ...)
  2019-12-10 20:31 ` [PATCH 4/5] nvmem: bcm-ocotp: " Yangtao Li
@ 2019-12-28 17:39 ` Frank Lee
  2019-12-29 12:13   ` Bartosz Golaszewski
  4 siblings, 1 reply; 10+ messages in thread
From: Frank Lee @ 2019-12-28 17:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Srini Kandagatla, vz,
	khilman, Maxime Ripard, Chen-Yu Tsai, andriy.shevchenko,
	Mauro Carvalho Chehab, mans, treding, suzuki.poulose,
	bgolaszewski, tglx
  Cc: Linux Kernel Mailing List, Linux ARM, linux-amlogic

ping...

On Wed, Dec 11, 2019 at 4:31 AM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> There are currently 300+ instances of using platform_get_resource_byname()
> and devm_ioremap_resource() together in the kernel tree.
>
> This patch wraps these two calls in a single helper.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/base/platform.c         | 22 +++++++++++++++++++++-
>  include/linux/platform_device.h |  3 +++
>  2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index b6c6c7d97d5b..9c4f5e229600 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -60,6 +60,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
>  }
>  EXPORT_SYMBOL_GPL(platform_get_resource);
>
> +#ifdef CONFIG_HAS_IOMEM
>  /**
>   * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
>   *                                 device
> @@ -68,7 +69,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
>   *        resource management
>   * @index: resource index
>   */
> -#ifdef CONFIG_HAS_IOMEM
> +
>  void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
>                                              unsigned int index)
>  {
> @@ -78,6 +79,25 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
>         return devm_ioremap_resource(&pdev->dev, res);
>  }
>  EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
> +
> +/**
> + * devm_platform_ioremap_resource_byname - call devm_ioremap_resource() for
> + *                                        a platform device
> + *
> + * @pdev: platform device to use both for memory resource lookup as well as
> + *        resource managemend
> + * @name: resource name
> + */
> +void __iomem *
> +devm_platform_ioremap_resource_byname(struct platform_device *pdev,
> +                                     const char *name)
> +{
> +       struct resource *res;
> +
> +       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
> +       return devm_ioremap_resource(&pdev->dev, res);
> +}
> +EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
>  #endif /* CONFIG_HAS_IOMEM */
>
>  static int __platform_get_irq(struct platform_device *dev, unsigned int num)
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 1b5cec067533..24ff5da9c532 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -63,6 +63,9 @@ extern int platform_irq_count(struct platform_device *);
>  extern struct resource *platform_get_resource_byname(struct platform_device *,
>                                                      unsigned int,
>                                                      const char *);
> +extern void __iomem *
> +devm_platform_ioremap_resource_byname(struct platform_device *pdev,
> +                                     const char *name);
>  extern int platform_get_irq_byname(struct platform_device *, const char *);
>  extern int platform_add_devices(struct platform_device **, int);
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper
  2019-12-28 17:39 ` [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Frank Lee
@ 2019-12-29 12:13   ` Bartosz Golaszewski
  0 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2019-12-29 12:13 UTC (permalink / raw)
  To: Frank Lee
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Srini Kandagatla,
	Vladimir Zapolskiy, Kevin Hilman, Maxime Ripard, Chen-Yu Tsai,
	Andy Shevchenko, Mauro Carvalho Chehab, mans, treding,
	suzuki.poulose, Thomas Gleixner, Linux Kernel Mailing List,
	Linux ARM, linux-amlogic

sob., 28 gru 2019 o 18:39 Frank Lee <tiny.windzz@gmail.com> napisał(a):
>
> ping...
>
> On Wed, Dec 11, 2019 at 4:31 AM Yangtao Li <tiny.windzz@gmail.com> wrote:
> >
> > There are currently 300+ instances of using platform_get_resource_byname()
> > and devm_ioremap_resource() together in the kernel tree.
> >
> > This patch wraps these two calls in a single helper.
> >
> > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> > ---
> >  drivers/base/platform.c         | 22 +++++++++++++++++++++-
> >  include/linux/platform_device.h |  3 +++
> >  2 files changed, 24 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index b6c6c7d97d5b..9c4f5e229600 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -60,6 +60,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
> >  }
> >  EXPORT_SYMBOL_GPL(platform_get_resource);
> >
> > +#ifdef CONFIG_HAS_IOMEM
> >  /**
> >   * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
> >   *                                 device
> > @@ -68,7 +69,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
> >   *        resource management
> >   * @index: resource index
> >   */
> > -#ifdef CONFIG_HAS_IOMEM
> > +
> >  void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
> >                                              unsigned int index)
> >  {
> > @@ -78,6 +79,25 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
> >         return devm_ioremap_resource(&pdev->dev, res);
> >  }
> >  EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
> > +
> > +/**
> > + * devm_platform_ioremap_resource_byname - call devm_ioremap_resource() for
> > + *                                        a platform device
> > + *
> > + * @pdev: platform device to use both for memory resource lookup as well as
> > + *        resource managemend
> > + * @name: resource name
> > + */
> > +void __iomem *
> > +devm_platform_ioremap_resource_byname(struct platform_device *pdev,
> > +                                     const char *name)
> > +{
> > +       struct resource *res;
> > +
> > +       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
> > +       return devm_ioremap_resource(&pdev->dev, res);
> > +}
> > +EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
> >  #endif /* CONFIG_HAS_IOMEM */
> >
> >  static int __platform_get_irq(struct platform_device *dev, unsigned int num)
> > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> > index 1b5cec067533..24ff5da9c532 100644
> > --- a/include/linux/platform_device.h
> > +++ b/include/linux/platform_device.h
> > @@ -63,6 +63,9 @@ extern int platform_irq_count(struct platform_device *);
> >  extern struct resource *platform_get_resource_byname(struct platform_device *,
> >                                                      unsigned int,
> >                                                      const char *);
> > +extern void __iomem *
> > +devm_platform_ioremap_resource_byname(struct platform_device *pdev,
> > +                                     const char *name);
> >  extern int platform_get_irq_byname(struct platform_device *, const char *);
> >  extern int platform_add_devices(struct platform_device **, int);
> >
> > --
> > 2.17.1
> >

This exact routine has existed upstream since commit c9c8641d3ebd
("drivers: provide devm_platform_ioremap_resource_byname()"). What
version are you working on?

Bart

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-12-29 12:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 20:31 [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Yangtao Li
2019-12-10 20:31 ` [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource Yangtao Li
2019-12-10 20:34   ` Frank Lee
2019-12-18  2:46   ` Chen-Yu Tsai
2019-12-10 20:31 ` [PATCH 2/5] nvmem: lpc18xx_otp: " Yangtao Li
2019-12-10 20:31 ` [PATCH 3/5] nvmem: meson-mx-efuse: " Yangtao Li
2019-12-10 20:41   ` Martin Blumenstingl
2019-12-10 20:31 ` [PATCH 4/5] nvmem: bcm-ocotp: " Yangtao Li
2019-12-28 17:39 ` [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Frank Lee
2019-12-29 12:13   ` Bartosz Golaszewski

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).