Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCHv2] gpio: logicvc: use devm_platform_get_and_ioremap_resource()
@ 2026-07-16 18:16 Rosen Penev
  0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-07-16 18:16 UTC (permalink / raw)
  To: linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

In the regmap fallback path, replace of_address_to_resource() plus
devm_ioremap_resource() with devm_platform_get_and_ioremap_resource(),
which looks up the resource and maps it in one call. The helper returns a
pointer to the resource, so update resource_size() to dereference it.

Drop the now-unused linux/of_address.h include; of_node is still used by
syscon_node_to_regmap() and platform_get_resource() resolves the same MEM
resource that of_address_to_resource(of_node, 0) did.

Built for ARM (multi_v7_defconfig + CONFIG_GPIO_LOGICVC) with LLVM=1;
drivers/gpio/gpio-logicvc.o compiles cleanly.

Assisted-by: opencode:hy3-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: remove unused ret.
 drivers/gpio/gpio-logicvc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-logicvc.c b/drivers/gpio/gpio-logicvc.c
index cb9dbcc290ad..697370f43002 100644
--- a/drivers/gpio/gpio-logicvc.c
+++ b/drivers/gpio/gpio-logicvc.c
@@ -8,7 +8,6 @@
 #include <linux/gpio/driver.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
@@ -91,7 +90,6 @@ static int logicvc_gpio_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *of_node = dev->of_node;
 	struct logicvc_gpio *logicvc;
-	int ret;

 	logicvc = devm_kzalloc(dev, sizeof(*logicvc), GFP_KERNEL);
 	if (!logicvc)
@@ -102,20 +100,14 @@ static int logicvc_gpio_probe(struct platform_device *pdev)

 	/* Grab our own regmap if that fails. */
 	if (IS_ERR(logicvc->regmap)) {
-		struct resource res;
+		struct resource *res;
 		void __iomem *base;

-		ret = of_address_to_resource(of_node, 0, &res);
-		if (ret) {
-			dev_err(dev, "Failed to get resource from address\n");
-			return ret;
-		}
-
-		base = devm_ioremap_resource(dev, &res);
+		base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 		if (IS_ERR(base))
 			return PTR_ERR(base);

-		logicvc_gpio_regmap_config.max_register = resource_size(&res) -
+		logicvc_gpio_regmap_config.max_register = resource_size(res) -
 			logicvc_gpio_regmap_config.reg_stride;

 		logicvc->regmap =
--
2.55.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-16 18:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16 18:16 [PATCHv2] gpio: logicvc: use devm_platform_get_and_ioremap_resource() Rosen Penev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox