Skip to content

Commit 7f1e45f

Browse files
foxhoundskBartosz Golaszewski
authored andcommitted
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. Signed-off-by: Huichun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 54a687c commit 7f1e45f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Documentation/userspace-api/gpio/sysfs.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ and have the following read/write attributes:
9797
poll(2) will return whenever the interrupt was triggered. If
9898
you use poll(2), set the events POLLPRI and POLLERR. If you
9999
use select(2), set the file descriptor in exceptfds. After
100-
poll(2) returns, either lseek(2) to the beginning of the sysfs
101-
file and read the new value or close the file and re-open it
102-
to read the value.
100+
poll(2) returns, use pread(2) to read the value at offset
101+
zero. Alternatively, either lseek(2) to the beginning of the
102+
sysfs file and read the new value or close the file and
103+
re-open it to read the value.
103104

104105
"edge" ...
105106
reads as either "none", "rising", "falling", or

0 commit comments

Comments
 (0)