Skip to contentSkip to conversation

Input: gpio-keys - fix misleading GPIO number

PATCH In review Wei 3 participants 4 messages Sep 24, 2025 – Sep 25, 2025

Subsystems (2)
lore
Share & tools
lore

Wei

author
#0 lore raw

PATCH 1/1 Input: gpio-keys - fix misleading GPIO number

From: Wei Liu <[email protected]>

The error log prints button->gpio, which is unset and default to 0 in non-legacy configurations, leading to misleading messages.

Use desc_to_gpio() to report the actual global GPIO number.

---
 drivers/input/keyboard/gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/gpio_keys.c +1 -1
index f9db86da0818..243295a3ea1d 100644
@@ -584,7 +584,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 				error = irq;
 				dev_err_probe(dev, error,
 					      "Unable to get irq number for GPIO %d\n",
-					      button->gpio);
+					      desc_to_gpio(bdata->gpiod));
 				return error;
 			}
 			bdata->irq = irq;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 17 lines · Wei

From: Wei Liu <[email protected]>

The error log prints button->gpio, which is unset and default to 0 in non-legacy configurations, leading to misleading messages.

Use desc_to_gpio() to report the actual global GPIO number.

---
 drivers/input/keyboard/gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/gpio_keys.c +0 -0
index f9db86da0818..243295a3ea1d 100644

drivers/input/keyboard/gpio_keys.c static int gpio_keys_setup_key(struct platform_device *pdev, · line 587

Quoted 5 lines
drivers/input/keyboard/gpio_keys.c +1 -1
@@ -584,7 +584,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
                                error = irq;
                                dev_err_probe(dev, error,
                                              "Unable to get irq number for GPIO %d\n",
-                                             button->gpio);
+                                             desc_to_gpio(bdata->gpiod));

That's technically a legacy interface.

Can we just not mention the GPIO number?

The only thing that would actually make sense in this kind of errors is if we add some new interface like:

const char * get_gpiod_debug_string(gpiod);

that can output the chip and line number from the core.

Yours,
Linus Walleij

maintainer
#2 lore raw
Quoted 27 lines · Linus Walleij
Quoted 17 lines · Wei

From: Wei Liu <[email protected]>

The error log prints button->gpio, which is unset and default to 0 in non-legacy configurations, leading to misleading messages.

Use desc_to_gpio() to report the actual global GPIO number.

---
 drivers/input/keyboard/gpio_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/gpio_keys.c +0 -0
index f9db86da0818..243295a3ea1d 100644

drivers/input/keyboard/gpio_keys.c static int gpio_keys_setup_key(struct platform_device *pdev, · line 587

Quoted 5 lines
drivers/input/keyboard/gpio_keys.c +1 -1
@@ -584,7 +584,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
                                error = irq;
                                dev_err_probe(dev, error,
                                              "Unable to get irq number for GPIO %d\n",
-                                             button->gpio);
+                                             desc_to_gpio(bdata->gpiod));

That's technically a legacy interface.

Quoted 1 line

Can we just not mention the GPIO number?

Yes, there was a patch removing printing this number... We are losing debug context though.

Quoted 5 lines

The only thing that would actually make sense in this kind of errors is if we add some new interface like:

const char * get_gpiod_debug_string(gpiod);

I assume the char will be dynamically allocated. Freeing it will be PITA.

I see vsprintf() has %pC for printing clocks and %pg for block devices, maybe we could have %pGD or similar for GPIO descriptors?

Thanks.

Signature · 1 line
Dmitry
#3 lore raw
Quoted 2 lines · Dmitry Torokhov

I see vsprintf() has %pC for printing clocks and %pg for block devices, maybe we could have %pGD or similar for GPIO descriptors?

I have no idea how that actually works, but I like this general idea!

Yours,
Linus Walleij