linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] gpiolib: cdev: directionless line reconfiguration
@ 2024-06-26  5:29 Kent Gibson
  2024-06-26  5:29 ` [PATCH 1/4] gpiolib: cdev: Disallow reconfiguration without direction (uAPI v1) Kent Gibson
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Kent Gibson @ 2024-06-26  5:29 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, brgl, linus.walleij; +Cc: Kent Gibson

The behaviour of request reconfiguration without a direction flag set is
ill-defined and badly behaved, for both uAPI v1 and v2.  I'll will refer
to such a configuration as 'directionless' here.  That refers to the
configuration requested, not the actual state of the line.

The configuration validation used during reconfiguration is borrowed from
the line request operation, where, to verify the intent of the user, the
direction must be set to in order to effect a change to the electrical
configuration of a line. But that validation does not allow for the
directionless case, making it possible to clear flags set previously
without specifying the line direction.

Adding to the inconsistency, those changes are not immediately applied,
but will take effect when the line value is next get or set.

For example, by requesting a reconfiguration with no flags set, an output
line requested with active low and open drain flags set could have those
flags cleared, inverting the sense of the line and changing the line drive
to push-pull on the next line value set.

This series addresses directionless reconfiguration behaviour for both
uAPI versions.

Patch 1 disallows reconfiguration without direction for uAPI v1.

Patch 2 ignores reconfiguration of a line without direction for uAPI v2.
A different approach is used, compared to uAPI v1, as v2 allows for
reconfiguration of multiple lines with different configurations.
It is more useful to skip directionless lines rather than returning an
error, as it allows for reconfiguration of a subset of requested lines.

Patches 3 and 4 update the documentation for uAPI v1 and v2, respectively,
to describe the updated behaviour.

Cheers,
Kent.

Kent Gibson (4):
  gpiolib: cdev: Disallow reconfiguration without direction (uAPI v1)
  gpiolib: cdev: Ignore reconfiguration without direction
  Documentation: gpio: Reconfiguration with unset direction (uAPI v1)
  Documentation: gpio: Reconfiguration with unset direction (uAPI v2)

 .../gpio/gpio-handle-set-config-ioctl.rst     |  5 +++-
 .../gpio/gpio-v2-line-set-config-ioctl.rst    |  7 +++--
 drivers/gpio/gpiolib-cdev.c                   | 28 +++++++++++--------
 3 files changed, 26 insertions(+), 14 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-07-01  7:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26  5:29 [PATCH 0/4] gpiolib: cdev: directionless line reconfiguration Kent Gibson
2024-06-26  5:29 ` [PATCH 1/4] gpiolib: cdev: Disallow reconfiguration without direction (uAPI v1) Kent Gibson
2024-06-26  5:29 ` [PATCH 2/4] gpiolib: cdev: Ignore reconfiguration without direction Kent Gibson
2024-06-27 14:06   ` Bartosz Golaszewski
2024-06-27 14:22     ` Kent Gibson
2024-06-27 14:44       ` Bartosz Golaszewski
2024-06-27 14:49         ` Kent Gibson
2024-06-27 14:51           ` Bartosz Golaszewski
2024-06-26  5:29 ` [PATCH 3/4] Documentation: gpio: Reconfiguration with unset direction (uAPI v1) Kent Gibson
2024-06-26  5:29 ` [PATCH 4/4] Documentation: gpio: Reconfiguration with unset direction (uAPI v2) Kent Gibson
2024-06-27 15:23 ` [PATCH 0/4] gpiolib: cdev: directionless line reconfiguration Bartosz Golaszewski
2024-07-01  7:39 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).