[PATCH 0/2] gpiolib: misc fixups

From: Matti Vaittinen
Date: Mon Mar 29 2021 - 07:42:06 EST


Patch 1/2:
The deprecated and obsoleted - but still used (especially in older
releases) /sys/class/gpio interface allows modifying GPIOs which are
excluded by the "valid_mask". This makes the valid_mask not suitable for
cases where toggling GPIO can cause damage. Patch adds validity
check to export.

I assume many people are still using the /sys/class/gpio at least for
testing purposes - especially with older releases. Thus it might be
worth the hassle to exclude invalid GPIOs - they're probably set invalid
for a good reason. (Actually, I noticed this when trying to use the
valid_mask to invalidate undocumented GPO on BD71815 - which may be
connected to GND. The people using BD71815 are likely to be using some
stable-release, which probably supports the (deprected, obsolete) sysfs
until the end of the days => valid_mask is not safe way unless fix to
this is backported to stable).

Patch 2/2:
checkpatch nowadays reminds us that ENOTSUPP is not valid error and
should be replaced by EOPNOTSUPP. It'd be nice if GPIO drivers could
return also the EOPNOTSUPP from config and avoid being nagged by
checkpatch.

Matti Vaittinen (2):
gpio: sysfs: Obey valid_mask
gpiolib: Allow drivers to return EOPNOTSUPP from config

drivers/gpio/gpiolib-sysfs.c | 8 ++++++++
drivers/gpio/gpiolib.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)

--
2.25.4


--
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =]