Skip to content

Commit be1f605

Browse files
Linus Walleijgregkh
authored andcommitted
gpio: No NULL owner
commit 7d18f0a upstream. Sometimes a GPIO is fetched with NULL as parent device, and that is just fine. So under these circumstances, avoid using dev_name() to provide a name for the GPIO line. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: Daniel Rosenberg <drosen@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1c4eb2a commit be1f605

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,6 +3204,8 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
32043204
struct gpio_desc *desc = NULL;
32053205
int status;
32063206
enum gpio_lookup_flags lookupflags = 0;
3207+
/* Maybe we have a device name, maybe not */
3208+
const char *devname = dev ? dev_name(dev) : "?";
32073209

32083210
dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
32093211

@@ -3232,8 +3234,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
32323234
return desc;
32333235
}
32343236

3235-
/* If a connection label was passed use that, else use the device name as label */
3236-
status = gpiod_request(desc, con_id ? con_id : dev_name(dev));
3237+
/*
3238+
* If a connection label was passed use that, else attempt to use
3239+
* the device name as label
3240+
*/
3241+
status = gpiod_request(desc, con_id ? con_id : devname);
32373242
if (status < 0)
32383243
return ERR_PTR(status);
32393244

0 commit comments

Comments
 (0)