Commit a85d35d2 authored by Linus Walleij's avatar Linus Walleij Committed by Stefan Bader

gpio: No NULL owner

BugLink: https://bugs.launchpad.net/bugs/1777389

commit 7d18f0a1 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: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: Daniel Rosenberg <drosen@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 130d3b38
......@@ -2186,6 +2186,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);
......@@ -2214,8 +2216,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment