[PATCH] pinctrl: sunxi: Implement gpiochip::get_direction()

Chen-Yu Tsai wens at kernel.org
Tue Feb 17 08:43:31 PST 2026


On Wed, Feb 18, 2026 at 12:32 AM Andre Przywara <andre.przywara at arm.com> wrote:
>
> On Tue, 17 Feb 2026 00:09:45 +0800
> Chen-Yu Tsai <wens at kernel.org> wrote:
>
> > After commit e623c4303ed1 ("gpiolib: sanitize the return value of
> > gpio_chip::get_direction()"), a warning will be printed if the
> > gpio driver does not implement this callback.
>
> I am curious how this could slip through? Did the get_direction()
> callback become mandatory at one point, but no one noticed that it was
> missing for sunxi? It looks like the situation was even worse before that
> patch, as it was dereferencing the function pointer without any check?

Digging deeper, my attribution is incorrect. The actual commit that
triggers the warning is 471e998c0e31 ("gpiolib: remove redundant callback
check"), in which a check of .get_direction before calling it was removed.
So I believe this just landed for the next release.

Thanks for spotting that. I'll send a v2 to add that information.

> > Implement it for the sunxi driver. This is simply a matter of reading
> > out the mux value from the registers, then checking if it is one of
> > the GPIO functions and which direction it is.
>
> Mmh, it feels a bit backwards to resort to the function name *string* for
> comparison, when it's always 0 for in and 1 for out (which we actually set
> in pinctrl-sunxi-dt.c now). But the mux value for IRQ is different between
> SoC generations, and I guess for historic reasons function strings are a
> thing in pinctrl, so this is probably the best solution after all:

Yeah, I was a bit undecided, but using the raw values for in / out and then
having a string comparison for irq made things even weirder.

> > Signed-off-by: Chen-Yu Tsai <wens at kernel.org>
>
> FWIW:
> Reviewed-by: Andre Przywara <andre.przywara at arm.com>


Thanks!



More information about the linux-arm-kernel mailing list