Commit 53cf6b72 authored by Théo Lebrun's avatar Théo Lebrun Committed by Linus Walleij

gpio: nomadik: fix offset bug in nmk_pmx_set()

Previously, the statement looked like:

    slpm[x] &= ~BIT(g->grp.pins[i]);

Where:
 - slpm is a unsigned int pointer;
 - g->grp.pins[i] is a pin number. It can grow to more than 32.

The expected shift amount is a pin bank offset.

This bug does not occur on every group or pin: the altsetting must be
NMK_GPIO_ALT_C and the pin must be 32 or above. It might have occured.
For example, in pinctrl-nomadik-db8500.c, pin group i2c3_c_2 has the
right altsetting and pins 229 and 230.

Fixes: dbfe8ca2 ("pinctrl/nomadik: implement pin multiplexing")
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarThéo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-5-3ba757474006@bootlin.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 6abd174c
...@@ -1579,8 +1579,10 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function, ...@@ -1579,8 +1579,10 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
* Then mask the pins that need to be sleeping now when we're * Then mask the pins that need to be sleeping now when we're
* switching to the ALT C function. * switching to the ALT C function.
*/ */
for (i = 0; i < g->grp.npins; i++) for (i = 0; i < g->grp.npins; i++) {
slpm[g->grp.pins[i] / NMK_GPIO_PER_CHIP] &= ~BIT(g->grp.pins[i]); unsigned int bit = g->grp.pins[i] % NMK_GPIO_PER_CHIP;
slpm[g->grp.pins[i] / NMK_GPIO_PER_CHIP] &= ~BIT(bit);
}
nmk_gpio_glitch_slpm_init(slpm); nmk_gpio_glitch_slpm_init(slpm);
} }
......
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