Skip to content

Commit 67e2996

Browse files
Fabien Dessennelinusw
authored andcommitted
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: 1dc9d28 ("pinctrl: stm32: add possibility to use gpio-ranges to declare bank range") Signed-off-by: Fabien Dessenne <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 76b7f8f commit 67e2996

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/pinctrl/stm32/pinctrl-stm32.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
12241224
struct device *dev = pctl->dev;
12251225
struct resource res;
12261226
int npins = STM32_GPIO_PINS_PER_BANK;
1227-
int bank_nr, err;
1227+
int bank_nr, err, i = 0;
12281228

12291229
if (!IS_ERR(bank->rstc))
12301230
reset_control_deassert(bank->rstc);
@@ -1246,9 +1246,14 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
12461246

12471247
of_property_read_string(np, "st,bank-name", &bank->gpio_chip.label);
12481248

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)) {
12501250
bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK;
12511251
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];
12521257
} else {
12531258
bank_nr = pctl->nbanks;
12541259
bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;

0 commit comments

Comments
 (0)