AT91 GPIO driver reading back struct gpio_chip::base

Bartosz Golaszewski brgl at bgdev.pl
Wed May 7 07:13:07 PDT 2025


On Wed, May 7, 2025 at 3:15 PM Ahmad Fatoum <a.fatoum at pengutronix.de> wrote:
>
> Hi,
>
> just stumbled upon this comment in drivers/gpio/gpiolib.c:
>
>   /*
>    * TODO: it should not be necessary to reflect the
>    * assigned base outside of the GPIO subsystem. Go over
>    * drivers and see if anyone makes use of this, else
>    * drop this and assign a poison instead.
>    */
>   gc->base = base;
>
> and thought to mention that there are drivers that indeed rely on the
> base, e.g. drivers/pinctrl/pinctrl-at91.c uses struct gpio_chip::base
> to find out which bit to set in a register:
>
>   dev_dbg(npct->dev, "enable pin %u as GPIO\n", offset);
>
>   mask = 1 << (offset - chip->base);
>
> This needs to be fixed of course, but I don't have time for that right
> now. Thus settling instead for writing this heads up. Maybe someone is
> motivated to fix this and then do the equivalent of
>
> https://lore.kernel.org/all/20250507-b4-imx-gpio-base-warning-v2-1-d43d09e2c6bf@pengutronix.de/
>
> for AT91 as well, given that the driver is DT-only. :-)
>
> Cheers,
> Ahmad
>
> --
> Pengutronix e.K.                  |                             |
> Steuerwalder Str. 21              | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |
>
>

Thanks! Would you mind adding a task to the TODO list under drivers/gpio/?

Bart



More information about the linux-arm-kernel mailing list