linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] docs: gpio: prefer pread(2) for interrupt reading
@ 2024-05-14  4:12 Huichun Feng
  2024-05-14  5:26 ` Bagas Sanjaya
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Huichun Feng @ 2024-05-14  4:12 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Jonathan Corbet, Kent Gibson,
	linux-gpio, linux-doc, linux-kernel
  Cc: foxhoundsk.tw

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>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] docs: gpio: prefer pread(2) for interrupt reading
  2024-05-14  4:12 [PATCH] docs: gpio: prefer pread(2) for interrupt reading Huichun Feng
@ 2024-05-14  5:26 ` Bagas Sanjaya
  2024-05-27  7:05 ` Huichun Feng
  2024-05-27 14:54 ` Bartosz Golaszewski
  2 siblings, 0 replies; 7+ messages in thread
From: Bagas Sanjaya @ 2024-05-14  5:26 UTC (permalink / raw)
  To: Huichun Feng, Linus Walleij, Bartosz Golaszewski, Jonathan Corbet,
	Kent Gibson, linux-gpio, linux-doc, linux-kernel
  Cc: Mao Zhu, Ran Sun, Xiang wangx, Shaomin Deng, Charles Han,
	Attreyee M, LihaSika

[-- Attachment #1: Type: text/plain, Size: 738 bytes --]

On Tue, May 14, 2024 at 12:12:23PM +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.
> 
> Signed-off-by: Huichun Feng <foxhoundsk.tw@gmail.com>

LGTM, thanks!

Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com>

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] docs: gpio: prefer pread(2) for interrupt reading
  2024-05-14  4:12 [PATCH] docs: gpio: prefer pread(2) for interrupt reading Huichun Feng
  2024-05-14  5:26 ` Bagas Sanjaya
@ 2024-05-27  7:05 ` Huichun Feng
  2024-05-27  7:34   ` Bartosz Golaszewski
  2024-05-27 14:54 ` Bartosz Golaszewski
  2 siblings, 1 reply; 7+ messages in thread
From: Huichun Feng @ 2024-05-27  7:05 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Jonathan Corbet, Kent Gibson,
	linux-gpio, linux-doc, linux-kernel

Kindly ping.

Sorry that the last ping wasn't sent in plain text.


Huichun Feng <foxhoundsk.tw@gmail.com> 於 2024年5月14日 週二 下午12:12寫道:
>
> 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>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] docs: gpio: prefer pread(2) for interrupt reading
  2024-05-27  7:05 ` Huichun Feng
@ 2024-05-27  7:34   ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2024-05-27  7:34 UTC (permalink / raw)
  To: Huichun Feng
  Cc: Linus Walleij, Jonathan Corbet, Kent Gibson, linux-gpio,
	linux-doc, linux-kernel

On Mon, May 27, 2024 at 9:05 AM Huichun Feng <foxhoundsk.tw@gmail.com> wrote:
>
> Kindly ping.
>
> Sorry that the last ping wasn't sent in plain text.
>
>

Please don't ping me on the morning of the day after the merge window
closes. I don't pick up patches for the next release during the merge
window (like most maintainers) and I need some time to catch up on my
queue during rc1.

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] docs: gpio: prefer pread(2) for interrupt reading
  2024-05-14  4:12 [PATCH] docs: gpio: prefer pread(2) for interrupt reading Huichun Feng
  2024-05-14  5:26 ` Bagas Sanjaya
  2024-05-27  7:05 ` Huichun Feng
@ 2024-05-27 14:54 ` Bartosz Golaszewski
  2024-06-02  7:49   ` Huichun Feng
  2 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2024-05-27 14:54 UTC (permalink / raw)
  To: Huichun Feng
  Cc: Linus Walleij, Jonathan Corbet, Kent Gibson, linux-gpio,
	linux-doc, linux-kernel

On Tue, May 14, 2024 at 6:12 AM Huichun Feng <foxhoundsk.tw@gmail.com> 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.
>
> Signed-off-by: Huichun Feng <foxhoundsk.tw@gmail.com>
> ---

This doesn't apply on top of gpio/for-next, please rebase and resend.

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] docs: gpio: prefer pread(2) for interrupt reading
  2024-05-27 14:54 ` Bartosz Golaszewski
@ 2024-06-02  7:49   ` Huichun Feng
  2024-06-03  8:31     ` Bartosz Golaszewski
  0 siblings, 1 reply; 7+ messages in thread
From: Huichun Feng @ 2024-06-02  7:49 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>
---
 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 related	[flat|nested] 7+ messages in thread

* Re: [PATCH] docs: gpio: prefer pread(2) for interrupt reading
  2024-06-02  7:49   ` Huichun Feng
@ 2024-06-03  8:31     ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2024-06-03  8:31 UTC (permalink / raw)
  To: Huichun Feng
  Cc: corbet, linus.walleij, linux-doc, linux-gpio, linux-kernel,
	warthog618

On Sun, Jun 2, 2024 at 9:49 AM Huichun Feng <foxhoundsk.tw@gmail.com> 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.
>
> Signed-off-by: Huichun Feng <foxhoundsk.tw@gmail.com>
> ---
>  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
>

Please don't send new versions of a patch as responses in an email
thread. Otherwise tools such as b4 cannot tell if it's a new version
or part of a larger series. Please always start a new thread with get
send-email or - better yet - start using b4 and let it manage the
series for you. Please resend this correctly.

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-03  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14  4:12 [PATCH] docs: gpio: prefer pread(2) for interrupt reading Huichun Feng
2024-05-14  5:26 ` Bagas Sanjaya
2024-05-27  7:05 ` Huichun Feng
2024-05-27  7:34   ` Bartosz Golaszewski
2024-05-27 14:54 ` Bartosz Golaszewski
2024-06-02  7:49   ` Huichun Feng
2024-06-03  8:31     ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).