diff options
author | Xabier Marquiegui <reibax@gmail.com> | 2023-10-12 00:39:54 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-10-15 20:07:52 +0100 |
commit | d26ab5a35ad9920940a9e07665130d501b2ae1a3 (patch) | |
tree | ed55561086f7c6f05dde1c40235ad3eea3cecfa5 /drivers/ptp/ptp_chardev.c | |
parent | 60c6946675fc06dd2fd2b7a4b6fd1c1f046f1056 (diff) | |
download | lwn-d26ab5a35ad9920940a9e07665130d501b2ae1a3.tar.gz lwn-d26ab5a35ad9920940a9e07665130d501b2ae1a3.zip |
ptp: Replace timestamp event queue with linked list
Introduce linked lists to access the timestamp event queue.
Signed-off-by: Xabier Marquiegui <reibax@gmail.com>
Suggested-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ptp/ptp_chardev.c')
-rw-r--r-- | drivers/ptp/ptp_chardev.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 0ba3e7064df2..aa1990d2ab46 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -439,10 +439,14 @@ __poll_t ptp_poll(struct posix_clock_context *pccontext, struct file *fp, { struct ptp_clock *ptp = container_of(pccontext->clk, struct ptp_clock, clock); + struct timestamp_event_queue *queue; poll_wait(fp, &ptp->tsev_wq, wait); - return queue_cnt(&ptp->tsevq) ? EPOLLIN : 0; + /* Extract only the first element in the queue list */ + queue = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue, qlist); + + return queue_cnt(queue) ? EPOLLIN : 0; } #define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS * sizeof(struct ptp_extts_event)) @@ -452,12 +456,16 @@ ssize_t ptp_read(struct posix_clock_context *pccontext, uint rdflags, { struct ptp_clock *ptp = container_of(pccontext->clk, struct ptp_clock, clock); - struct timestamp_event_queue *queue = &ptp->tsevq; + struct timestamp_event_queue *queue; struct ptp_extts_event *event; unsigned long flags; size_t qcnt, i; int result; + /* Extract only the first element in the queue list */ + queue = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue, + qlist); + if (cnt % sizeof(struct ptp_extts_event) != 0) return -EINVAL; |