diff mbox series

[v1] gpio: mmio: fix calculation of bgpio_bits

Message ID 20230323205733.20763-1-asmaa@nvidia.com
State Superseded
Headers show
Series [v1] gpio: mmio: fix calculation of bgpio_bits | expand

Commit Message

Asmaa Mnebhi March 23, 2023, 8:57 p.m. UTC
If the "ngpios" property is specified, bgpio_bits is calculated
as the round up value of ngpio. At the moment, the only requirement
specified is that the round up value must be a multiple of 8 but
it should also be a power of 2 because we provide accessors based
on the bank size in bgpio_setup_accessors().

Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
---
 drivers/gpio/gpio-mmio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Linus Walleij March 29, 2023, 8:44 a.m. UTC | #1
On Thu, Mar 23, 2023 at 9:57 PM Asmaa Mnebhi <asmaa@nvidia.com> wrote:

> If the "ngpios" property is specified, bgpio_bits is calculated
> as the round up value of ngpio. At the moment, the only requirement
> specified is that the round up value must be a multiple of 8 but
> it should also be a power of 2 because we provide accessors based
> on the bank size in bgpio_setup_accessors().
>
> Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>

Neat fixup,
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Asmaa Mnebhi July 10, 2023, 5:26 p.m. UTC | #2
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
Hi Bart,

Could you please add this patch to the tree?

Thanks.
Asmaa
Bartosz Golaszewski July 10, 2023, 7:11 p.m. UTC | #3
On Mon, Jul 10, 2023 at 7:26 PM Asmaa Mnebhi <asmaa@nvidia.com> wrote:
>
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> >
> Hi Bart,
>
> Could you please add this patch to the tree?
>
> Thanks.
> Asmaa

You still haven't sent it to my address and it's not rebased on top of v6.5-rc1.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index b52a3dd511ca..74fdf0d87b2c 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -623,7 +623,7 @@  int bgpio_init(struct gpio_chip *gc, struct device *dev,
 	if (ret)
 		gc->ngpio = gc->bgpio_bits;
 	else
-		gc->bgpio_bits = round_up(gc->ngpio, 8);
+		gc->bgpio_bits = roundup_pow_of_two(round_up(gc->ngpio, 8));
 
 	ret = bgpio_setup_io(gc, dat, set, clr, flags);
 	if (ret)