提交 482715ff 编写于 作者: A Andy Shevchenko 提交者: Linus Walleij

pinctrl: core: Show pin numbers for the controllers with base = 0

The commit f1b206cf ("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: f1b206cf ("pinctrl: core: print gpio in pins debugfs file")
Cc: Drew Fustini <drew@beagleboard.org>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: NDrew Fustini <drew@beagleboard.org>
Reviewed-by: NDrew Fustini <drew@beagleboard.org>
Link: https://lore.kernel.org/r/20210415130356.15885-1-andriy.shevchenko@linux.intel.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 33cc5270
...@@ -1604,8 +1604,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) ...@@ -1604,8 +1604,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
unsigned i, pin; unsigned i, pin;
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
struct pinctrl_gpio_range *range; struct pinctrl_gpio_range *range;
unsigned int gpio_num;
struct gpio_chip *chip; struct gpio_chip *chip;
int gpio_num;
#endif #endif
seq_printf(s, "registered pins: %d\n", pctldev->desc->npins); seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
...@@ -1625,7 +1625,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) ...@@ -1625,7 +1625,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
seq_printf(s, "pin %d (%s) ", pin, desc->name); seq_printf(s, "pin %d (%s) ", pin, desc->name);
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
gpio_num = 0; gpio_num = -1;
list_for_each_entry(range, &pctldev->gpio_ranges, node) { list_for_each_entry(range, &pctldev->gpio_ranges, node) {
if ((pin >= range->pin_base) && if ((pin >= range->pin_base) &&
(pin < (range->pin_base + range->npins))) { (pin < (range->pin_base + range->npins))) {
...@@ -1633,10 +1633,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) ...@@ -1633,10 +1633,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
break; break;
} }
} }
chip = gpio_to_chip(gpio_num); if (gpio_num >= 0)
if (chip && chip->gpiodev && chip->gpiodev->base) chip = gpio_to_chip(gpio_num);
seq_printf(s, "%u:%s ", gpio_num - else
chip->gpiodev->base, chip->label); chip = NULL;
if (chip)
seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label);
else else
seq_puts(s, "0:? "); seq_puts(s, "0:? ");
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册