]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: swnode: compare the "undefined" swnode by its address, not name
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 15 Dec 2025 15:46:24 +0000 (16:46 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Thu, 18 Dec 2025 11:27:00 +0000 (12:27 +0100)
We know the address of the underlying remote software node referenced by
the GPIO property (if it is a software node). We don't need to compare
its name, we can compare its address which is more precise anyway.

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20251215154624.67099-1-bartosz.golaszewski@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib-swnode.c

index b44f35d68459095a14b48056fca2c58e04b0a2ed..54bad9e88fe5c76b498e99567bd156799079adc2 100644 (file)
 
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/property.h>
 
 #include "gpiolib.h"
 #include "gpiolib-swnode.h"
 
-#define GPIOLIB_SWNODE_UNDEFINED_NAME "swnode-gpio-undefined"
-
 static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
 {
        const struct software_node *gdev_node;
        struct gpio_device *gdev;
 
        gdev_node = to_software_node(fwnode);
-       if (!gdev_node || !gdev_node->name)
+       if (!gdev_node)
                goto fwnode_lookup;
 
        /*
@@ -38,7 +37,7 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
         * primarily used as a key for internal chip selects in SPI bindings.
         */
        if (IS_ENABLED(CONFIG_GPIO_SWNODE_UNDEFINED) &&
-           !strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME))
+           gdev_node == &swnode_gpio_undefined)
                return ERR_PTR(-ENOENT);
 
 fwnode_lookup:
@@ -139,9 +138,7 @@ int swnode_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)
  * A special node that identifies undefined GPIOs, this is primarily used as
  * a key for internal chip selects in SPI bindings.
  */
-const struct software_node swnode_gpio_undefined = {
-       .name = GPIOLIB_SWNODE_UNDEFINED_NAME,
-};
+const struct software_node swnode_gpio_undefined = { };
 EXPORT_SYMBOL_NS_GPL(swnode_gpio_undefined, "GPIO_SWNODE");
 
 static int __init swnode_gpio_init(void)