drivers: add devm_platform_ioremap_resource_byname() helper
Subsystems (5)
PATCH 1/1 drivers: add devm_platform_ioremap_resource_byname() helper
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.
--- drivers/base/platform.c | 22 +++++++++++++++++++++- include/linux/platform_device.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-)
drivers/base/platform.c +21 -1
@@ -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)
include/linux/platform_device.h +3 -0
@@ -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 );
Signature · 1 line
2.17.1
PATCH 1/5 nvmem: sunxi_sid: convert to devm_platform_ioremap_resource
Use devm_platform_ioremap_resource() to simplify code.
--- drivers/nvmem/sunxi_sid.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nvmem/sunxi_sid.c +1 -3
@@ -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);
Signature · 1 line
2.17.1
PATCH 2/5 nvmem: lpc18xx_otp: convert to devm_platform_ioremap_resource
In reply to Yangtao LiUse devm_platform_ioremap_resource() to simplify code.
--- drivers/nvmem/lpc18xx_otp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nvmem/lpc18xx_otp.c +1 -3
@@ -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);
Signature · 1 line
2.17.1
PATCH 3/5 nvmem: meson-mx-efuse: convert to devm_platform_ioremap_resource
In reply to Yangtao LiUse devm_platform_ioremap_resource() to simplify code.
--- drivers/nvmem/meson-mx-efuse.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nvmem/meson-mx-efuse.c +1 -3
@@ -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);
Signature · 1 line
2.17.1
PATCH 4/5 nvmem: bcm-ocotp: convert to devm_platform_ioremap_resource
In reply to Yangtao LiUse devm_platform_ioremap_resource() to simplify code.
--- drivers/nvmem/bcm-ocotp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nvmem/bcm-ocotp.c +1 -3
@@ -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);
Signature · 1 line
2.17.1
Re: [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource
In reply to Yangtao LiThere is no 5/5 in this patchset, a small mistake.
Thx,
Yangtao
Re: [PATCH 3/5] nvmem: meson-mx-efuse: convert to devm_platform_ioremap_resource
In reply to Yangtao LiQuoted 4 lines · Yangtao Li
Use
devm_platform_ioremap_resource()to simplify code.Signed-off-by Yangtao Li <[email protected]>
thank you for taking care of this!
Martin
Re: [PATCH 1/5] nvmem: sunxi_sid: convert to devm_platform_ioremap_resource
In reply to Yangtao LiQuoted 4 lines · Yangtao Li
Use
devm_platform_ioremap_resource()to simplify code.Signed-off-by Yangtao Li <[email protected]>
Quoted 29 lines
--- drivers/nvmem/sunxi_sid.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/nvmem/sunxi_sid.c +1
-4@@ -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
ping...
Quoted 74 lines · Yangtao Li
There are currently 300+ instances of using
platform_get_resource_byname()anddevm_ioremap_resource()together in the kernel tree.This patch wraps these two calls in a single helper.
Signed-off-by Yangtao Li <[email protected]>--- drivers/base/platform.c | 22 +++++++++++++++++++++- include/linux/platform_device.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-)drivers/base/platform.c +21
-1@@ -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)include/linux/platform_device.h +3
-1@@ -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 ); --
Quoted 2 lines
2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
sob., 28 gru 2019 o 18:39 Frank Lee <[email protected]> napisał(a):
Quoted 77 lines
ping...
Quoted 73 lines · Yangtao Li
There are currently 300+ instances of using
platform_get_resource_byname()anddevm_ioremap_resource()together in the kernel tree.This patch wraps these two calls in a single helper.
Signed-off-by Yangtao Li <[email protected]>--- drivers/base/platform.c | 22 +++++++++++++++++++++- include/linux/platform_device.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-)drivers/base/platform.c +21
-1@@ -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)include/linux/platform_device.h +3
-0@@ -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 );
Quoted 3 lines
Quoted 3 lines
--
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