Commit db503298 authored by Léo DUBOIN's avatar Léo DUBOIN Committed by Linus Walleij

pinctrl: core: take into account the pins array in pinctrl_pins_show()

We previously only looked at the 'pin_base' of the pinctrl_gpio_ranges
struct for determining if a pin matched a GPIO number.

This value is present only if the 'pins' array is not NULL,
and is 0 otherwise. This means that GPIO ranges declared using
gpiochip_add_pingroup_range(), thus making use of pins, were always matched
by the pins in the range [0-npins] even if they contained pins in a
completely separate range.
Signed-off-by: default avatarLéo DUBOIN <lduboin@freebox.fr>
Link: https://lore.kernel.org/r/6df39bd47942156be5713f8f4e317d2ad3e0ddeb.1714049455.git.lduboin@freebox.frSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent f805e356
...@@ -1672,11 +1672,20 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) ...@@ -1672,11 +1672,20 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
gpio_num = -1; 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 (range->pins != NULL) {
(pin < (range->pin_base + range->npins))) { for (int i = 0; i < range->npins; ++i) {
gpio_num = range->base + (pin - range->pin_base); if (range->pins[i] == pin) {
break; gpio_num = range->base + i;
break;
}
}
} else if ((pin >= range->pin_base) &&
(pin < (range->pin_base + range->npins))) {
gpio_num =
range->base + (pin - range->pin_base);
} }
if (gpio_num != -1)
break;
} }
if (gpio_num >= 0) if (gpio_num >= 0)
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment