Skip to content

Commit 0d776cf

Browse files
bebarinoBartosz Golaszewski
authored andcommitted
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 <[email protected]> Fixes: 8eb1f71 ("gpiolib: consolidate GPIO lookups") Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent ebb03f6 commit 0d776cf

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

drivers/gpio/gpiolib-devres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
158158
if (!dr)
159159
return ERR_PTR(-ENOMEM);
160160

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);
162162
if (IS_ERR(desc)) {
163163
devres_free(dr);
164164
return desc;

drivers/gpio/gpiolib.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4171,13 +4171,13 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode,
41714171
return desc;
41724172
}
41734173

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)
41814181
{
41824182
unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;
41834183
/*

drivers/gpio/gpiolib.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ static inline int gpiod_request_user(struct gpio_desc *desc, const char *label)
223223
return ret;
224224
}
225225

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+
226234
int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
227235
unsigned long lflags, enum gpiod_flags dflags);
228236
int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce);

0 commit comments

Comments
 (0)