Merge tag 'pinctrl-v5.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[platform/kernel/linux-rpi.git] / drivers / pinctrl / core.c
index 3b40402..a4ac87c 100644 (file)
@@ -1627,8 +1627,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
        unsigned i, pin;
 #ifdef CONFIG_GPIOLIB
        struct pinctrl_gpio_range *range;
-       unsigned int gpio_num;
        struct gpio_chip *chip;
+       int gpio_num;
 #endif
 
        seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
@@ -1648,7 +1648,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
                seq_printf(s, "pin %d (%s) ", pin, desc->name);
 
 #ifdef CONFIG_GPIOLIB
-               gpio_num = 0;
+               gpio_num = -1;
                list_for_each_entry(range, &pctldev->gpio_ranges, node) {
                        if ((pin >= range->pin_base) &&
                            (pin < (range->pin_base + range->npins))) {
@@ -1656,10 +1656,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
                                break;
                        }
                }
-               chip = gpio_to_chip(gpio_num);
-               if (chip && chip->gpiodev && chip->gpiodev->base)
-                       seq_printf(s, "%u:%s ", gpio_num -
-                               chip->gpiodev->base, chip->label);
+               if (gpio_num >= 0)
+                       chip = gpio_to_chip(gpio_num);
+               else
+                       chip = NULL;
+               if (chip)
+                       seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label);
                else
                        seq_puts(s, "0:? ");
 #endif