* [PATCH v2] docs: gpio: prefer pread(2) for interrupt reading
@ 2024-06-09 17:37 Huichun Feng
2024-06-10 7:38 ` Bartosz Golaszewski
0 siblings, 1 reply; 2+ messages in thread
From: Huichun Feng @ 2024-06-09 17:37 UTC (permalink / raw)
To: brgl
Cc: corbet, foxhoundsk.tw, linus.walleij, linux-doc, linux-gpio,
linux-kernel, warthog618
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 <foxhoundsk.tw@gmail.com>
---
Changes in v2:
- rebase against the latest tree.
v1 link:
https://lore.kernel.org/linux-gpio/20240514041223.800811-1-foxhoundsk.tw@gmail.com/T/#mfa19d877e6056936d3a2025cb64ca8c5b8718644
---
Documentation/userspace-api/gpio/sysfs.rst | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/userspace-api/gpio/sysfs.rst b/Documentation/userspace-api/gpio/sysfs.rst
index 116921048..bd64896de 100644
--- a/Documentation/userspace-api/gpio/sysfs.rst
+++ b/Documentation/userspace-api/gpio/sysfs.rst
@@ -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
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] docs: gpio: prefer pread(2) for interrupt reading
2024-06-09 17:37 [PATCH v2] docs: gpio: prefer pread(2) for interrupt reading Huichun Feng
@ 2024-06-10 7:38 ` Bartosz Golaszewski
0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2024-06-10 7:38 UTC (permalink / raw)
To: brgl, Huichun Feng
Cc: Bartosz Golaszewski, corbet, linus.walleij, linux-doc,
linux-gpio, linux-kernel, warthog618
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Mon, 10 Jun 2024 01:37:28 +0800, Huichun Feng wrote:
> 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,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-10 7:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-09 17:37 [PATCH v2] docs: gpio: prefer pread(2) for interrupt reading Huichun Feng
2024-06-10 7:38 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®