]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Thu, 26 Feb 2026 09:56:36 +0000 (10:56 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Fri, 27 Feb 2026 08:53:06 +0000 (09:53 +0100)
In GPIOLIB, during fwnode lookup, after having resolved the consumer's
reference to a specific fwnode, we only match it against the primary
node of the controllers. Let's extend that to also the secondary node by
reworking gpio_chip_match_by_fwnode()

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://patch.msgid.link/20260226-device-match-secondary-fwnode-v4-1-27bd0cfbd8c6@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib.c

index 86a171e96b0ebc9dd77acce8de11266dd870002d..d85c97bc158f539ce0355d0216904bb04eba2b67 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/file.h>
 #include <linux/fs.h>
+#include <linux/fwnode.h>
 #include <linux/idr.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -1394,7 +1395,16 @@ EXPORT_SYMBOL_GPL(gpio_device_find_by_label);
 
 static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, const void *fwnode)
 {
-       return device_match_fwnode(&gc->gpiodev->dev, fwnode);
+       struct device *dev = &gc->gpiodev->dev;
+       struct fwnode_handle *node = dev_fwnode(dev);
+
+       if (IS_ERR(fwnode))
+               return 0;
+
+       if (device_match_fwnode(dev, fwnode))
+               return 1;
+
+       return node && node->secondary == fwnode;
 }
 
 /**