Re: [PATCH] gpio: pcf857x: implement get_direction()
From: Linus Walleij
Date: Thu Jun 04 2026 - 04:27:50 EST
On Thu, Jun 4, 2026 at 7:25 AM Tapio Reijonen
<tapio.reijonen@xxxxxxxxxxx> wrote:
> The GPIO core warns (and taints the kernel) when a gpiochip lacks
> .get_direction() and a consumer queries a line's direction, for example
> via /sys/kernel/debug/gpio. pcf857x provided direction_input/output but
> no get_direction.
>
> These quasi-bidirectional expanders cannot report direction in hardware,
> and the 'out' software latch alone is ambiguous - a released (input)
> line and an output driven high both read back as a set bit. Track the
> direction explicitly in a 'dir' latch updated by the direction_input(),
> direction_output() and set_multiple() paths, and return it from
> get_direction(). Initialise it from the same reset state as 'out':
> released lines are inputs, lines flagged in the power-on latch are
> driven-low outputs.
>
> Fixes: 15fae37d9f5f ("gpiolib: pcf857x i2c gpio expander support")
> Signed-off-by: Tapio Reijonen <tapio.reijonen@xxxxxxxxxxx>
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Yours,
Linus Walleij