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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 Documentation/driver-api/gpio/legacy.rst   | 6 ++++--
 Documentation/userspace-api/gpio/sysfs.rst | 7 ++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
index b6505914791c..c1a083444b0c 100644
--- a/Documentation/driver-api/gpio/legacy.rst
+++ b/Documentation/driver-api/gpio/legacy.rst
@@ -648,8 +648,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. 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.
+		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
 		"both". Write these strings to select the signal edge(s)
diff --git a/Documentation/userspace-api/gpio/sysfs.rst b/Documentation/userspace-api/gpio/sysfs.rst
index 116921048b18..bd64896de91a 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





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux