kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: Provide devm_platform_ioremap_resource_byname()
@ 2019-06-14 13:26 Markus Elfring
  2019-06-14 13:38 ` Andy Shevchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Elfring @ 2019-06-14 13:26 UTC (permalink / raw)
  To: kernel-janitors, Greg Kroah-Hartman, Rafael J. Wysocki
  Cc: LKML, Andy Shevchenko, Bartosz Golaszewski, Enrico Weigelt,
	Himanshu Jha, Linus Walleij

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource”
are called together in 181 source files.
This implementation detail can be determined also with the help
of the semantic patch language (Coccinelle software).

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource
structure pointer before and a redundant argument can be omitted
for the resource type.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/platform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4d1729853d1a..c1f19a479dd7 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -97,6 +97,24 @@ 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 management
+ * @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 */

 /**
--
2.22.0

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

end of thread, other threads:[~2019-06-17 13:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 13:26 [PATCH] drivers: Provide devm_platform_ioremap_resource_byname() Markus Elfring
2019-06-14 13:38 ` Andy Shevchenko
2019-06-14 14:10   ` Greg Kroah-Hartman
2019-06-14 14:47     ` Andy Shevchenko
2019-06-14 15:32       ` Greg Kroah-Hartman
2019-06-14 16:14       ` Markus Elfring
2019-06-15  8:44         ` Julia Lawall
2019-06-15 10:23           ` Markus Elfring
2019-06-17  9:55     ` [PATCH] " Rafael J. Wysocki
2019-06-17 13:54       ` Markus Elfring

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