Skip to content

Commit c4f78b5

Browse files
linuswgregkh
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 <[email protected]> Cc: Daniel Rosenberg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 81613cc commit c4f78b5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/gpio/gpiolib.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,8 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
21172117
struct gpio_desc *desc = NULL;
21182118
int status;
21192119
enum gpio_lookup_flags lookupflags = 0;
2120+
/* Maybe we have a device name, maybe not */
2121+
const char *devname = dev ? dev_name(dev) : "?";
21202122

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

@@ -2145,8 +2147,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
21452147
return desc;
21462148
}
21472149

2148-
/* If a connection label was passed use that, else use the device name as label */
2149-
status = gpiod_request(desc, con_id ? con_id : dev_name(dev));
2150+
/*
2151+
* If a connection label was passed use that, else attempt to use
2152+
* the device name as label
2153+
*/
2154+
status = gpiod_request(desc, con_id ? con_id : devname);
21502155
if (status < 0)
21512156
return ERR_PTR(status);
21522157

0 commit comments

Comments
 (0)