Skip to content

Commit 70dbf7e

Browse files
mmahadevan108dleach02
authored andcommitted
drivers: uart_imx: Fix the poll_in function
Current poll_in function implementation blocks when there is no data available. The Zephyr documentation for poll_in expects the function to return -1 when no data is available. Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent a8c7f82 commit 70dbf7e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/serial/uart_imx.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,18 @@ static void uart_imx_poll_out(const struct device *dev, unsigned char c)
113113
static int uart_imx_poll_in(const struct device *dev, unsigned char *c)
114114
{
115115
UART_Type *uart = UART_STRUCT(dev);
116+
int ret = -1;
116117

117-
while (!UART_GetStatusFlag(uart, uartStatusRxDataReady)) {
118-
}
119-
*c = UART_Getchar(uart);
118+
if (UART_GetStatusFlag(uart, uartStatusRxDataReady)) {
119+
*c = UART_Getchar(uart);
120120

121-
if (UART_GetStatusFlag(uart, uartStatusRxOverrun)) {
122-
UART_ClearStatusFlag(uart, uartStatusRxOverrun);
121+
if (UART_GetStatusFlag(uart, uartStatusRxOverrun)) {
122+
UART_ClearStatusFlag(uart, uartStatusRxOverrun);
123+
}
124+
ret = 0;
123125
}
124126

125-
return 0;
127+
return ret;
126128
}
127129

128130
#ifdef CONFIG_UART_INTERRUPT_DRIVEN

0 commit comments

Comments
 (0)