Skip to content

Commit b91da0d

Browse files
linuswZhengShunQian
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 78a0815 commit b91da0d

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
@@ -2200,6 +2200,8 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
22002200
struct gpio_desc *desc = NULL;
22012201
int status;
22022202
enum gpio_lookup_flags lookupflags = 0;
2203+
/* Maybe we have a device name, maybe not */
2204+
const char *devname = dev ? dev_name(dev) : "?";
22032205

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

@@ -2228,8 +2230,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
22282230
return desc;
22292231
}
22302232

2231-
/* If a connection label was passed use that, else use the device name as label */
2232-
status = gpiod_request(desc, con_id ? con_id : dev_name(dev));
2233+
/*
2234+
* If a connection label was passed use that, else attempt to use
2235+
* the device name as label
2236+
*/
2237+
status = gpiod_request(desc, con_id ? con_id : devname);
22332238
if (status < 0)
22342239
return ERR_PTR(status);
22352240

0 commit comments

Comments
 (0)