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 <denis.osterland@diehl.com>
Co-developed-by: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
Fixes: eae9d2ba0c ("LinuxPPS: core support")
Link: https://lore.kernel.org/all/f6bed779-6d59-4f0f-8a59-b6312bd83b4e@enneenne.com/
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Link: https://lore.kernel.org/r/c3c50ad1eb19ef553eca8a57c17f4c006413ab70.camel@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-01 12:29:29 +02:00
..
clients pps: clients: gpio: fix interrupt handling order in remove path 2025-07-01 12:29:24 +02:00
generators pps: generators: tio: fix platform_set_drvdata() 2025-04-15 18:22:32 +02:00
kapi.c pps: Fix a use-after-free 2025-01-07 15:16:48 +01:00
kc.c pps: Fix a use-after-free 2025-01-07 15:16:48 +01:00
kc.h
Kconfig
Makefile drivers pps: add PPS generators support 2025-01-08 13:18:09 +01:00
pps.c pps: fix poll support 2025-07-01 12:29:29 +02:00
sysfs.c