Files
erofs-linux/drivers/pps
Denis OSTERLAND-HEIM 12c409aa1e pps: fix poll support
Because pps_cdev_poll() returns unconditionally EPOLLIN,
a user space program that calls select/poll get always an immediate data
ready-to-read response. As a result the intended use to wait until next
data becomes ready does not work.

User space snippet:

    struct pollfd pollfd = {
      .fd = open("/dev/pps0", O_RDONLY),
      .events = POLLIN|POLLERR,
      .revents = 0 };
    while(1) {
      poll(&pollfd, 1, 2000/*ms*/); // returns immediate, but should wait
      if(revents & EPOLLIN) { // always true
        struct pps_fdata fdata;
        memset(&fdata, 0, sizeof(memdata));
        ioctl(PPS_FETCH, &fdata); // currently fetches data at max speed
      }
    }

Lets remember the last fetch event counter and compare this value
in pps_cdev_poll() with most recent event counter
and return 0 if they are equal.

Signed-off-by: Denis OSTERLAND-HEIM <[email protected]>
Co-developed-by: Rodolfo Giometti <[email protected]>
Signed-off-by: Rodolfo Giometti <[email protected]>
Fixes: eae9d2ba0c ("LinuxPPS: core support")
Link: https://lore.kernel.org/all/[email protected]/
Acked-by: Rodolfo Giometti <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
2025-07-01 12:29:29 +02:00
..
2025-01-07 15:16:48 +01:00
2025-01-07 15:16:48 +01:00
…
…
2025-07-01 12:29:29 +02:00
…