Skip to content

Commit

Permalink
gpio: No NULL owner
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Walleij committed Jan 17, 2018
1 parent b888fb6 commit 7d18f0a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3623,6 +3623,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);

Expand Down Expand Up @@ -3651,8 +3653,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);

Expand Down

0 comments on commit 7d18f0a

Please sign in to comment.