diff mbox

[6/6] gpiolib: Add gpio name information to /sys/kernel/debug/gpio

Message ID 1438680203-13432-7-git-send-email-mpa@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Markus Pargmann Aug. 4, 2015, 9:23 a.m. UTC
Add some information about gpio names to the debugfs gpio file. name and
label of a GPIO are then displayed next to each other. This way it is
easy to see what the real name of GPIO is and what the driver requested
it for.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/gpio/gpiolib.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Linus Walleij Aug. 10, 2015, 10:02 a.m. UTC | #1
On Tue, Aug 4, 2015 at 11:23 AM, Markus Pargmann <mpa@pengutronix.de> wrote:

> Add some information about gpio names to the debugfs gpio file. name and
> label of a GPIO are then displayed next to each other. This way it is
> easy to see what the real name of GPIO is and what the driver requested
> it for.
>
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>

This patch looks correct in the context.

Yours,
Linus Walleij
Alexandre Courbot Aug. 17, 2015, 7:29 a.m. UTC | #2
On Mon, Aug 10, 2015 at 7:02 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Tue, Aug 4, 2015 at 11:23 AM, Markus Pargmann <mpa@pengutronix.de> wrote:
>
>> Add some information about gpio names to the debugfs gpio file. name and
>> label of a GPIO are then displayed next to each other. This way it is
>> easy to see what the real name of GPIO is and what the driver requested
>> it for.
>>
>> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
>
> This patch looks correct in the context.

Looks correct indeed, but on a related note one might question the
need to have both a "name" and a "label" for a GPIO?
Linus Walleij Aug. 25, 2015, 2:34 p.m. UTC | #3
On Mon, Aug 17, 2015 at 9:29 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Mon, Aug 10, 2015 at 7:02 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Tue, Aug 4, 2015 at 11:23 AM, Markus Pargmann <mpa@pengutronix.de> wrote:
>>
>>> Add some information about gpio names to the debugfs gpio file. name and
>>> label of a GPIO are then displayed next to each other. This way it is
>>> easy to see what the real name of GPIO is and what the driver requested
>>> it for.
>>>
>>> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
>>
>> This patch looks correct in the context.
>
> Looks correct indeed, but on a related note one might question the
> need to have both a "name" and a "label" for a GPIO?

The way I see it a certain GPIO controller has names for the
GPIO lines, like gpio0,1,2...n, while the label is for the actual
use of the GPIO line. It's a bit like the regulator name, rail name
and consumer endpoints guess. Just we only have two names,
not three :P

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index edfeb0485112..926a1507431f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2307,14 +2307,19 @@  static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 	int			is_irq;
 
 	for (i = 0; i < chip->ngpio; i++, gpio++, gdesc++) {
-		if (!test_bit(FLAG_REQUESTED, &gdesc->flags))
+		if (!test_bit(FLAG_REQUESTED, &gdesc->flags)) {
+			if (gdesc->name) {
+				seq_printf(s, " gpio-%-3d (%-20.20s)\n",
+					   gpio, gdesc->name);
+			}
 			continue;
+		}
 
 		gpiod_get_direction(gdesc);
 		is_out = test_bit(FLAG_IS_OUT, &gdesc->flags);
 		is_irq = test_bit(FLAG_USED_AS_IRQ, &gdesc->flags);
-		seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s",
-			gpio, gdesc->label,
+		seq_printf(s, " gpio-%-3d (%-20.20s|%-20.20s) %s %s %s",
+			gpio, gdesc->name ? gdesc->name : "", gdesc->label,
 			is_out ? "out" : "in ",
 			chip->get
 				? (chip->get(chip, i) ? "hi" : "lo")