diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2018-01-16 08:29:50 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-06-16 09:52:33 +0200 |
commit | be1f605bea9557a85f717e2707bc7c0c22e7ad81 (patch) | |
tree | 3b8c5f6f5928d0dc9a4be927897cc4db28a4b365 /drivers/gpio | |
parent | 1c4eb2a50e77109b3b89c57e80fce54a72f69fcf (diff) | |
download | linux-stable-be1f605bea9557a85f717e2707bc7c0c22e7ad81.tar.gz linux-stable-be1f605bea9557a85f717e2707bc7c0c22e7ad81.tar.bz2 linux-stable-be1f605bea9557a85f717e2707bc7c0c22e7ad81.zip |
gpio: No NULL owner
commit 7d18f0a14aa6a0d6bad39111c1fb655f07f71d59 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>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 56b24198741c..dd0076497463 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3204,6 +3204,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); @@ -3232,8 +3234,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); |