Commit 86e1740c authored by Robert Hancock's avatar Robert Hancock Committed by Carles Cufi
Browse files

serial: xilinx: uartlite: Fix infinite spin in xlnx_uartlite_fifo_read

The xlnx_uartlite_fifo_read function would spin indefinitely if there
was less data available in the RX FIFO than the size of the passed-in
buffer. This call is supposed to be non-blocking.

Fixed to break out of the loop if there are no more bytes left in the RX
FIFO.

Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
parent c18e7f3e
Loading
Loading
Loading
Loading
+3 −0
Changes for drivers/serial/uart_xlnx_uartlite.c: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -214,6 +214,9 @@ static int xlnx_uartlite_fifo_read(const struct device *dev, uint8_t *rx_data,
			rx_data[count++] = xlnx_uartlite_read_rx_fifo(dev);
		}
		k_spin_unlock(&data->rx_lock, key);
		if (!(status & STAT_REG_RX_FIFO_VALID_DATA)) {
			break;
		}
	}

	return count;