Re: [PATCH 1/4] gpiolib: cdev: Flag invalid GPIOs as used
From: Linus Walleij
Date: Wed Dec 09 2020 - 04:26:15 EST
On Fri, Dec 4, 2020 at 5:47 PM Marc Zyngier <maz@xxxxxxxxxx> wrote:
> When reporting the state of a GPIO to userspace, we never check
> for the actual validity of the line, meaning we report invalid
> lines as being usable. A subsequent request will fail though,
> which is an inconsistent behaviour from a userspace perspective.
>
> Instead, let's check for the validity of the line and report it
> as used if it is invalid. This allows a tool such as gpioinfo
> to report something sensible:
>
> gpiochip3 - 4 lines:
> line 0: unnamed unused input active-high
> line 1: unnamed kernel input active-high [used]
> line 2: unnamed kernel input active-high [used]
> line 3: unnamed unused input active-high
>
> In this example, lines 1 and 2 are invalid, and cannot be used by
> userspace.
>
> Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
This makes sense, so patch applied (unless Bartosz tells me
otherwise, then I'll pull it out again).
Yours,
Linus Walleij