Skip to contentSkip to conversation

docs: gpio: prefer pread(2) for interrupt reading

PATCH Applied Huichun Feng 2 participants 2 messages Jun 9, 2024 – Jun 10, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 docs: gpio: prefer pread(2) for interrupt reading

In legacy sysfs GPIO, when using poll(2) on the sysfs GPIO value for state change awaiting, a subsequent read(2) is required for consuming the event, which the doc recommends the use of lseek(2) or close-and-reopen to reset the file offset afterwards.

The recommendations however, require at least 2 syscalls to consume the event. Gladly, use of pread(2) require only 1 syscall for the consumption. Let's advertise this usage by prioritizing its placement.

---
Changes in v2:
- rebase against the latest tree.

v1 link:
https://lore.kernel.org/linux-gpio/[email protected]/T/#mfa19d877e6056936d3a2025cb64ca8c5b8718644

---
 Documentation/userspace-api/gpio/sysfs.rst | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/userspace-api/gpio/sysfs.rst +4 -3
index 116921048..bd64896de 100644
@@ -97,9 +97,10 @@ and have the following read/write attributes:
 		poll(2) will return whenever the interrupt was triggered. If
 		you use poll(2), set the events POLLPRI and POLLERR. If you
 		use select(2), set the file descriptor in exceptfds. After
-		poll(2) returns, either lseek(2) to the beginning of the sysfs
-		file and read the new value or close the file and re-open it
-		to read the value.
+		poll(2) returns, use pread(2) to read the value at offset
+		zero. Alternatively, either lseek(2) to the beginning of the
+		sysfs file and read the new value or close the file and
+		re-open it to read the value.
 
 	"edge" ...
 		reads as either "none", "rising", "falling", or
Signature · 1 line
2.34.1
#1 lore raw

From: Bartosz Golaszewski <[email protected]>

Quoted 10 lines · Huichun Feng

In legacy sysfs GPIO, when using poll(2) on the sysfs GPIO value for state change awaiting, a subsequent read(2) is required for consuming the event, which the doc recommends the use of lseek(2) or close-and-reopen to reset the file offset afterwards.

The recommendations however, require at least 2 syscalls to consume the event. Gladly, use of pread(2) require only 1 syscall for the consumption. Let's advertise this usage by prioritizing its placement.

[...]

Applied, thanks!

[1/1] docs: gpio: prefer pread(2) for interrupt reading

      commit: 7f1e45f4ae7671550e15354ef87194bccd99ecec

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>