Marc Zyngier a0db197f53 gpiolib: cdev: Flag invalid GPIOs as used
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@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201204164739.781812-2-maz@kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-12-09 10:23:04 +01:00
..
2020-07-20 15:34:59 +02:00
2020-07-23 15:03:25 +02:00
2018-05-16 14:35:24 +02:00
2020-01-15 11:24:19 +01:00
2019-09-03 16:04:19 +02:00
2020-07-30 00:13:10 +02:00
2019-11-07 09:27:48 +01:00
2020-01-15 13:45:01 +01:00
2018-01-09 14:51:00 +01:00
2019-11-07 09:27:48 +01:00
2019-12-09 10:40:18 +01:00
2020-12-05 22:41:22 +01:00
2020-12-06 00:13:17 +01:00