linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
@ 2023-03-23 20:57 Asmaa Mnebhi
  2023-03-24 12:07 ` Andy Shevchenko
  2023-03-29  8:44 ` Linus Walleij
  0 siblings, 2 replies; 7+ messages in thread
From: Asmaa Mnebhi @ 2023-03-23 20:57 UTC (permalink / raw)
  To: andy.shevchenko, linus.walleij, linux-gpio, linux-kernel; +Cc: Asmaa Mnebhi

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(-)

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)
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
  2023-03-23 20:57 [PATCH v1] gpio: mmio: fix calculation of bgpio_bits Asmaa Mnebhi
@ 2023-03-24 12:07 ` Andy Shevchenko
  2023-03-24 12:09   ` Andy Shevchenko
  2023-07-10 17:26   ` Asmaa Mnebhi
  2023-03-29  8:44 ` Linus Walleij
  1 sibling, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-03-24 12:07 UTC (permalink / raw)
  To: Asmaa Mnebhi; +Cc: linus.walleij, linux-gpio, linux-kernel

On Thu, Mar 23, 2023 at 10: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().

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

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


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
  2023-03-24 12:07 ` Andy Shevchenko
@ 2023-03-24 12:09   ` Andy Shevchenko
  2023-03-24 13:43     ` Asmaa Mnebhi
  2023-07-10 17:26   ` Asmaa Mnebhi
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2023-03-24 12:09 UTC (permalink / raw)
  To: Asmaa Mnebhi; +Cc: linus.walleij, linux-gpio, linux-kernel

On Fri, Mar 24, 2023 at 2:07 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Thu, Mar 23, 2023 at 10: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().
>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Btw, I do not see the initial patch in Bart's tree. I suppose you may
simply send a v5 of the original one with this fix applied inplace.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
  2023-03-24 12:09   ` Andy Shevchenko
@ 2023-03-24 13:43     ` Asmaa Mnebhi
  0 siblings, 0 replies; 7+ messages in thread
From: Asmaa Mnebhi @ 2023-03-24 13:43 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linus.walleij, linux-gpio, linux-kernel

> > >
> > > 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().
> >
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> Btw, I do not see the initial patch in Bart's tree. I suppose you may simply
> send a v5 of the original one with this fix applied inplace.
> 
Yes I was not able to find it on any branch yet so I just sent this patch based the other one.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
  2023-03-23 20:57 [PATCH v1] gpio: mmio: fix calculation of bgpio_bits Asmaa Mnebhi
  2023-03-24 12:07 ` Andy Shevchenko
@ 2023-03-29  8:44 ` Linus Walleij
  1 sibling, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2023-03-29  8:44 UTC (permalink / raw)
  To: Asmaa Mnebhi; +Cc: andy.shevchenko, linux-gpio, linux-kernel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
  2023-03-24 12:07 ` Andy Shevchenko
  2023-03-24 12:09   ` Andy Shevchenko
@ 2023-07-10 17:26   ` Asmaa Mnebhi
  2023-07-10 19:11     ` Bartosz Golaszewski
  1 sibling, 1 reply; 7+ messages in thread
From: Asmaa Mnebhi @ 2023-07-10 17:26 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski
  Cc: linus.walleij, linux-gpio, linux-kernel

> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
Hi Bart,

Could you please add this patch to the tree?

Thanks.
Asmaa

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1] gpio: mmio: fix calculation of bgpio_bits
  2023-07-10 17:26   ` Asmaa Mnebhi
@ 2023-07-10 19:11     ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2023-07-10 19:11 UTC (permalink / raw)
  To: Asmaa Mnebhi; +Cc: Andy Shevchenko, linus.walleij, linux-gpio, linux-kernel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-10 19:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23 20:57 [PATCH v1] gpio: mmio: fix calculation of bgpio_bits Asmaa Mnebhi
2023-03-24 12:07 ` Andy Shevchenko
2023-03-24 12:09   ` Andy Shevchenko
2023-03-24 13:43     ` Asmaa Mnebhi
2023-07-10 17:26   ` Asmaa Mnebhi
2023-07-10 19:11     ` Bartosz Golaszewski
2023-03-29  8:44 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).