[PATCH 0/4] USB: ftdio_sio: GPIO validity fixes

From: Marc Zyngier
Date: Fri Dec 04 2020 - 11:48:45 EST


Having recently tried to use the CBUS GPIOs that come thanks to the
ftdio_sio driver, it occurred to me that the driver has a couple of
usability issues:

- it advertises potential GPIOs that are reserved to other uses (LED
control, or something else)

- it returns an odd error (-ENODEV), instead of the expected -EINVAL
when a line is unavailable, leading to a difficult diagnostic

We address the issues in a number of ways:

- Stop reporting invalid GPIO lines as valid to userspace. It
definitely seems odd to do so. Instead, report the line as being
used, making the userspace interface a bit more consistent.

- Implement the init_valid_mask() callback in the ftdi_sio driver,
allowing it to report which lines are actually valid.

- As suggested by Linus, give an indication to the user of why some of
the GPIO lines are unavailable, and point them to a useful tool
(once per boot). It is a bit sad that there next to no documentation
on how to use these CBUS pins.

- Drop the error reporting code, which has become useless at this
point.

Tested with a couple of FTDI devices (FT230X and FT231X) and various
CBUS configurations.

Marc Zyngier (4):
gpiolib: cdev: Flag invalid GPIOs as used
USB: serial: ftdi_sio: Report the valid GPIO lines to gpiolib
USB: serial: ftdi_sio: Log the CBUS GPIO validity
USB: serial: ftdi_sio: Drop GPIO line checking dead code

drivers/gpio/gpiolib-cdev.c | 1 +
drivers/usb/serial/ftdi_sio.c | 26 +++++++++++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)

--
2.28.0