gpio: label descriptors using the device name

Message ID
State New
Headers show
  • gpio: label descriptors using the device name
Related show

Commit Message

Linus Walleij Jan. 4, 2018, 9:40 p.m.
Some GPIO lines appear named "?" in the lsgpio dump due to their
requesting drivers not passing a reasonable label.

Most typically this happens if a device tree node just defines
gpios = <...> and not foo-gpios = <...>, the former gets named
"foo" and the latter gets named "?".

However the struct device passed in is always valid so let's
just label the GPIO with dev_name() on the device if no proper
label was passed.

Cc: Reported-by: Jason Kridner <>
Reported-by: Jason Kridner <>
Signed-off-by: Linus Walleij <>
Jason: would be great if you can test this and check if it gives
you reasonable consumer names.
 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 7dde703b6da2..986293143068 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3650,7 +3650,8 @@  struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
 		return desc;
-	status = gpiod_request(desc, con_id);
+	/* 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 (status < 0)
 		return ERR_PTR(status);