pinctrl: stm32: fix the reported number of GPIO lines per bank

Each GPIO bank supports a variable number of lines which is usually 16, but
is less in some cases : this is specified by the last argument of the
"gpio-ranges" bank node property.
Report to the framework, the actual number of lines, so the libgpiod
gpioinfo command lists the actually existing GPIO lines.

Fixes: 1dc9d289154b ("pinctrl: stm32: add possibility to use gpio-ranges to declare bank range")
Signed-off-by: Fabien Dessenne <fabien.dessenne@foss.st.com>
Link: https://lore.kernel.org/r/20210617144629.2557693-1-fabien.dessenne@foss.st.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by Fabien Dessenne and committed by Linus Walleij 67e2996f 76b7f8fa

Changed files
+7 -2
drivers
pinctrl
+7 -2
drivers/pinctrl/stm32/pinctrl-stm32.c
··· 1224 1224 struct device *dev = pctl->dev; 1225 1225 struct resource res; 1226 1226 int npins = STM32_GPIO_PINS_PER_BANK; 1227 - int bank_nr, err; 1227 + int bank_nr, err, i = 0; 1228 1228 1229 1229 if (!IS_ERR(bank->rstc)) 1230 1230 reset_control_deassert(bank->rstc); ··· 1246 1246 1247 1247 of_property_read_string(np, "st,bank-name", &bank->gpio_chip.label); 1248 1248 1249 - if (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args)) { 1249 + if (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, i, &args)) { 1250 1250 bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK; 1251 1251 bank->gpio_chip.base = args.args[1]; 1252 + 1253 + npins = args.args[2]; 1254 + while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 1255 + ++i, &args)) 1256 + npins += args.args[2]; 1252 1257 } else { 1253 1258 bank_nr = pctl->nbanks; 1254 1259 bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;