gpiolib: Pass consumer device through to core in devm_fwnode_gpiod_get_index()
authorStephen Boyd <swboyd@chromium.org>
Fri, 23 Feb 2024 06:52:53 +0000 (22:52 -0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 27 Feb 2024 13:17:38 +0000 (14:17 +0100)
This devm API takes a consumer device as an argument to setup the devm
action, but throws it away when calling further into gpiolib. This leads
to odd debug messages like this:

 (NULL device *): using DT '/gpio-keys/switch-pen-insert' for '(null)' GPIO lookup

Let's pass the consumer device down, by directly calling what
fwnode_gpiod_get_index() calls but pass the device used for devm. This
changes the message to look like this instead:

 gpio-keys gpio-keys: using DT '/gpio-keys/switch-pen-insert' for '(null)' GPIO lookup

Note that callers of fwnode_gpiod_get_index() will still see the NULL
device pointer debug message, but there's not much we can do about that
because the API doesn't take a struct device.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Fixes: 8eb1f71e7acc ("gpiolib: consolidate GPIO lookups")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib-devres.c
drivers/gpio/gpiolib.c
drivers/gpio/gpiolib.h

index fe9ce6b19f15c5b3ad00b23e36c343e1ca0878b9..4987e62dcb3d153681180aab2108bfd4d37c1c4e 100644 (file)
@@ -158,7 +158,7 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
        if (!dr)
                return ERR_PTR(-ENOMEM);
 
-       desc = fwnode_gpiod_get_index(fwnode, con_id, index, flags, label);
+       desc = gpiod_find_and_request(dev, fwnode, con_id, index, flags, label, false);
        if (IS_ERR(desc)) {
                devres_free(dr);
                return desc;
index 63e793a410e3f9d35c112217fe99f2891d20ed7e..3e2cd85673b677f2fe944eea219b04fc00fc6bc8 100644 (file)
@@ -4171,13 +4171,13 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode,
        return desc;
 }
 
-static struct gpio_desc *gpiod_find_and_request(struct device *consumer,
-                                               struct fwnode_handle *fwnode,
-                                               const char *con_id,
-                                               unsigned int idx,
-                                               enum gpiod_flags flags,
-                                               const char *label,
-                                               bool platform_lookup_allowed)
+struct gpio_desc *gpiod_find_and_request(struct device *consumer,
+                                        struct fwnode_handle *fwnode,
+                                        const char *con_id,
+                                        unsigned int idx,
+                                        enum gpiod_flags flags,
+                                        const char *label,
+                                        bool platform_lookup_allowed)
 {
        unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;
        /*
index ada36aa0f81abdcee6d0dfe7fc99c114726d0640..f67d5991ab1c7a58d375b2f6bd3275b41adb8ade 100644 (file)
@@ -223,6 +223,14 @@ static inline int gpiod_request_user(struct gpio_desc *desc, const char *label)
        return ret;
 }
 
+struct gpio_desc *gpiod_find_and_request(struct device *consumer,
+                                        struct fwnode_handle *fwnode,
+                                        const char *con_id,
+                                        unsigned int idx,
+                                        enum gpiod_flags flags,
+                                        const char *label,
+                                        bool platform_lookup_allowed);
+
 int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
                unsigned long lflags, enum gpiod_flags dflags);
 int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce);