Skip to content

Commit b67210c

Browse files
Fabien Dessennelinusw
authored andcommitted
pinctrl: stm32: consider the GPIO offset to expose all the GPIO lines
Consider the GPIO controller offset (from "gpio-ranges") to compute the maximum GPIO line number. This fixes an issue where gpio-ranges uses a non-null offset. e.g.: gpio-ranges = <&pinctrl 6 86 10> In that case the last valid GPIO line is not 9 but 15 (6 + 10 - 1) Cc: [email protected] Fixes: 67e2996 ("pinctrl: stm32: fix the reported number of GPIO lines per bank") Reported-by: Christoph Fritz <[email protected]> Signed-off-by: Fabien Dessenne <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 266423e commit b67210c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/pinctrl/stm32/pinctrl-stm32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,10 +1251,10 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
12511251
bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK;
12521252
bank->gpio_chip.base = args.args[1];
12531253

1254-
npins = args.args[2];
1255-
while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
1256-
++i, &args))
1257-
npins += args.args[2];
1254+
/* get the last defined gpio line (offset + nb of pins) */
1255+
npins = args.args[0] + args.args[2];
1256+
while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, ++i, &args))
1257+
npins = max(npins, (int)(args.args[0] + args.args[2]));
12581258
} else {
12591259
bank_nr = pctl->nbanks;
12601260
bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;

0 commit comments

Comments
 (0)