Commit 7f1e45f4 authored by Huichun Feng's avatar Huichun Feng Committed by Bartosz Golaszewski

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: default avatarHuichun Feng <foxhoundsk.tw@gmail.com>
Link: https://lore.kernel.org/r/20240609173728.2950808-1-foxhoundsk.tw@gmail.comSigned-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 54a687cd
...@@ -97,9 +97,10 @@ and have the following read/write attributes: ...@@ -97,9 +97,10 @@ and have the following read/write attributes:
poll(2) will return whenever the interrupt was triggered. If poll(2) will return whenever the interrupt was triggered. If
you use poll(2), set the events POLLPRI and POLLERR. If you you use poll(2), set the events POLLPRI and POLLERR. If you
use select(2), set the file descriptor in exceptfds. After use select(2), set the file descriptor in exceptfds. After
poll(2) returns, either lseek(2) to the beginning of the sysfs poll(2) returns, use pread(2) to read the value at offset
file and read the new value or close the file and re-open it zero. Alternatively, either lseek(2) to the beginning of the
to read the value. sysfs file and read the new value or close the file and
re-open it to read the value.
"edge" ... "edge" ...
reads as either "none", "rising", "falling", or reads as either "none", "rising", "falling", or
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment