1
0
Fork 0

gpio: No NULL owner

commit 7d18f0a14a 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>
pull/10/head
Linus Walleij 2018-01-16 08:29:50 +01:00 committed by Greg Kroah-Hartman
parent 7d970250cb
commit c7a372ddc3
1 changed files with 7 additions and 2 deletions

View File

@ -3313,6 +3313,8 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
struct gpio_desc *desc = NULL;
int status;
enum gpio_lookup_flags lookupflags = 0;
/* Maybe we have a device name, maybe not */
const char *devname = dev ? dev_name(dev) : "?";
dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
@ -3341,8 +3343,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
return desc;
}
/* If a connection label was passed use that, else use the device name as label */
status = gpiod_request(desc, con_id ? con_id : dev_name(dev));
/*
* If a connection label was passed use that, else attempt to use
* the device name as label
*/
status = gpiod_request(desc, con_id ? con_id : devname);
if (status < 0)
return ERR_PTR(status);