From 216c1204757190666b0f6bd3e32590a1008a4343 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 20 Nov 2025 14:24:00 +0100 Subject: [PATCH] gpio: swnode: allow referencing GPIO chips by firmware nodes When doing a software node lookup, we require both the fwnode that references a GPIO chip as well as the node associated with that chip to be software nodes. However, we now allow referencing generic firmware nodes from software nodes in driver core so we should allow the same in GPIO core. Make the software node name check optional and dependent on whether the referenced firmware node is a software node. If it's not, just continue with the lookup. Acked-by: Linus Walleij Reviewed-by: Andy Shevchenko Acked-by: Greg Kroah-Hartman Signed-off-by: Bartosz Golaszewski Signed-off-by: Philipp Zabel --- drivers/gpio/gpiolib-swnode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c index e3806db1c0e07..b44f35d684590 100644 --- a/drivers/gpio/gpiolib-swnode.c +++ b/drivers/gpio/gpiolib-swnode.c @@ -31,7 +31,7 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode) gdev_node = to_software_node(fwnode); if (!gdev_node || !gdev_node->name) - return ERR_PTR(-EINVAL); + goto fwnode_lookup; /* * Check for a special node that identifies undefined GPIOs, this is @@ -41,6 +41,7 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode) !strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME)) return ERR_PTR(-ENOENT); +fwnode_lookup: gdev = gpio_device_find_by_fwnode(fwnode); return gdev ?: ERR_PTR(-EPROBE_DEFER); } -- 2.47.3