Re: [PATCH] gpio: mmio: do not calculate bgpio_bits via "ngpios"
From: Linus Walleij
Date: Wed Jul 03 2024 - 08:39:15 EST
On Tue, Jun 25, 2024 at 3:22 AM Shiji Yang <yangshiji66@xxxxxxxxxxx> wrote:
> bgpio_bits must be aligned with the data bus width. For example, on a
> 32 bit big endian system and we only have 16 GPIOs. If we only assume
> bgpio_bits=16 we can never control the GPIO because the base address
> is the lowest address.
>
> low address high address
> -------------------------------------------------
> | byte3 | byte2 | byte1 | byte0 |
> -------------------------------------------------
> | NaN | NaN | gpio8-15 | gpio0-7 |
> -------------------------------------------------
>
> Fixes: 55b2395e4e92 ("gpio: mmio: handle "ngpios" properly in bgpio_init()")
> Fixes: https://github.com/openwrt/openwrt/issues/15739
> Reported-by: Mark Mentovai <mark@xxxxxxxxxxxx>
> Signed-off-by: Shiji Yang <yangshiji66@xxxxxxxxxxx>
> Suggested-By: Mark Mentovai <mark@xxxxxxxxxxxx>
> Reviewed-by: Jonas Gorski <jonas.gorski@xxxxxxxxx>
> Tested-by: Lóránd Horváth <lorand.horvath82@xxxxxxxxx>
I'm convinced this is the right thing to do. (By Jonas Gorski.)
Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
Bart, can you apply it for fixes?
(Or for -next if you wanna be really careful.)
Yours,
Linus Walleij