Skip to content

Commit 482715f

Browse files
andy-shevLinus Walleij
authored andcommitted
pinctrl: core: Show pin numbers for the controllers with base = 0
The commit f1b206c ("pinctrl: core: print gpio in pins debugfs file") enabled GPIO pin number and label in debugfs for pin controller. However, it limited that feature to the chips where base is positive number. This, in particular, excluded chips where base is 0 for the historical or backward compatibility reasons. Refactor the code to include the latter as well. Fixes: f1b206c ("pinctrl: core: print gpio in pins debugfs file") Cc: Drew Fustini <drew@beagleboard.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Drew Fustini <drew@beagleboard.org> Reviewed-by: Drew Fustini <drew@beagleboard.org> Link: https://lore.kernel.org/r/20210415130356.15885-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 33cc527 commit 482715f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/pinctrl/core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,8 +1604,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
16041604
unsigned i, pin;
16051605
#ifdef CONFIG_GPIOLIB
16061606
struct pinctrl_gpio_range *range;
1607-
unsigned int gpio_num;
16081607
struct gpio_chip *chip;
1608+
int gpio_num;
16091609
#endif
16101610

16111611
seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
@@ -1625,18 +1625,20 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
16251625
seq_printf(s, "pin %d (%s) ", pin, desc->name);
16261626

16271627
#ifdef CONFIG_GPIOLIB
1628-
gpio_num = 0;
1628+
gpio_num = -1;
16291629
list_for_each_entry(range, &pctldev->gpio_ranges, node) {
16301630
if ((pin >= range->pin_base) &&
16311631
(pin < (range->pin_base + range->npins))) {
16321632
gpio_num = range->base + (pin - range->pin_base);
16331633
break;
16341634
}
16351635
}
1636-
chip = gpio_to_chip(gpio_num);
1637-
if (chip && chip->gpiodev && chip->gpiodev->base)
1638-
seq_printf(s, "%u:%s ", gpio_num -
1639-
chip->gpiodev->base, chip->label);
1636+
if (gpio_num >= 0)
1637+
chip = gpio_to_chip(gpio_num);
1638+
else
1639+
chip = NULL;
1640+
if (chip)
1641+
seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label);
16401642
else
16411643
seq_puts(s, "0:? ");
16421644
#endif

0 commit comments

Comments
 (0)