From 0e2a3ecdf8d3522f8621a2a474ec166d1f2ea0fc Mon Sep 17 00:00:00 2001 From: Kenneth Thompson Date: Wed, 20 Oct 2021 19:55:54 -0700 Subject: [PATCH] drivers/can: Fix can_poll() POLLOUT calculation can_poll() would indicate that there is no space in the TX FIFO if there is already one element in the FIFO. --- drivers/can/can.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/can/can.c b/drivers/can/can.c index 5d3f7c7c37..b10154af2f 100644 --- a/drivers/can/can.c +++ b/drivers/can/can.c @@ -1129,13 +1129,13 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds, while (ret < 0); dev->cd_ntxwaiters--; - ndx = dev->cd_xmit.tx_head + 1; + ndx = dev->cd_xmit.tx_tail + 1; if (ndx >= CONFIG_CAN_FIFOSIZE) { ndx = 0; } - if (ndx != dev->cd_xmit.tx_tail) + if (ndx != dev->cd_xmit.tx_head) { eventset |= fds->events & POLLOUT; }