Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: Pass consumer device through to core in devm_fwnode_gpiod_get_index()

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>

authored by

Stephen Boyd and committed by
Bartosz Golaszewski
0d776cfd ebb03f69

+16 -8
+1 -1
drivers/gpio/gpiolib-devres.c
··· 158 158 if (!dr) 159 159 return ERR_PTR(-ENOMEM); 160 160 161 - desc = fwnode_gpiod_get_index(fwnode, con_id, index, flags, label); 161 + desc = gpiod_find_and_request(dev, fwnode, con_id, index, flags, label, false); 162 162 if (IS_ERR(desc)) { 163 163 devres_free(dr); 164 164 return desc;
+7 -7
drivers/gpio/gpiolib.c
··· 4171 4171 return desc; 4172 4172 } 4173 4173 4174 - static struct gpio_desc *gpiod_find_and_request(struct device *consumer, 4175 - struct fwnode_handle *fwnode, 4176 - const char *con_id, 4177 - unsigned int idx, 4178 - enum gpiod_flags flags, 4179 - const char *label, 4180 - bool platform_lookup_allowed) 4174 + struct gpio_desc *gpiod_find_and_request(struct device *consumer, 4175 + struct fwnode_handle *fwnode, 4176 + const char *con_id, 4177 + unsigned int idx, 4178 + enum gpiod_flags flags, 4179 + const char *label, 4180 + bool platform_lookup_allowed) 4181 4181 { 4182 4182 unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT; 4183 4183 /*
+8
drivers/gpio/gpiolib.h
··· 223 223 return ret; 224 224 } 225 225 226 + struct gpio_desc *gpiod_find_and_request(struct device *consumer, 227 + struct fwnode_handle *fwnode, 228 + const char *con_id, 229 + unsigned int idx, 230 + enum gpiod_flags flags, 231 + const char *label, 232 + bool platform_lookup_allowed); 233 + 226 234 int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, 227 235 unsigned long lflags, enum gpiod_flags dflags); 228 236 int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce);