Re: [PATCH v1] gpio: mmio: handle "ngpios" properly in bgpio_init

From: Andy Shevchenko
Date: Fri Feb 24 2023 - 13:17:05 EST


On Fri, Feb 24, 2023 at 7:40 PM Asmaa Mnebhi <asmaa@xxxxxxxxxx> wrote:
>
> bgpio_init uses "sz" argument to populate ngpio, which is not accurate.

bgpio_init() uses the

(Note parentheses, same for other func() mentions)

> Instead, read the "ngpios" property from the DT and if it
> doesn't exist, use the "sz" argument. With this change, drivers no
> longer need to overwrite the ngpio variable after calling bgpio_init.

Thank you!

...

> + ret = device_property_read_u32(dev, "ngpios", &ngpios);
> + if (!ret)
> + gc->ngpio = ngpios;
> + else
> + gc->ngpio = gc->bgpio_bits;

This duplicates the GPIO library. What probably better to have is to
just check the property existence

device_property_present() and do accordingly.

--
With Best Regards,
Andy Shevchenko