2020-09-29 09:32:14

by Peng Fan

[permalink] [raw]
Subject: [PATCH] tty: serial: fsl_lpuart: fix lpuart32_poll_get_char

The watermark is set to 1, so we need to input two chars to trigger RDRF
using the original logic. With the new logic, we could always get the
char when there is data in FIFO.

Suggested-by: Fugang Duan <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
---
drivers/tty/serial/fsl_lpuart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 645bbb24b433..1c37280b6c0c 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -680,7 +680,7 @@ static void lpuart32_poll_put_char(struct uart_port *port, unsigned char c)

static int lpuart32_poll_get_char(struct uart_port *port)
{
- if (!(lpuart32_read(port, UARTSTAT) & UARTSTAT_RDRF))
+ if (!(lpuart32_read(port, UARTWATER) >> UARTWATER_RXCNT_OFF))
return NO_POLL_CHAR;

return lpuart32_read(port, UARTDATA);
--
2.28.0


2020-09-29 09:38:23

by Andy Duan

[permalink] [raw]
Subject: RE: [PATCH] tty: serial: fsl_lpuart: fix lpuart32_poll_get_char

From: Peng Fan <[email protected]> Sent: Tuesday, September 29, 2020 5:55 PM
> The watermark is set to 1, so we need to input two chars to trigger RDRF using
> the original logic. With the new logic, we could always get the char when there
> is data in FIFO.
>
> Suggested-by: Fugang Duan <[email protected]>
> Signed-off-by: Peng Fan <[email protected]>
> ---
> drivers/tty/serial/fsl_lpuart.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index
> 645bbb24b433..1c37280b6c0c 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -680,7 +680,7 @@ static void lpuart32_poll_put_char(struct uart_port
> *port, unsigned char c)
>
> static int lpuart32_poll_get_char(struct uart_port *port) {
> - if (!(lpuart32_read(port, UARTSTAT) & UARTSTAT_RDRF))
> + if (!(lpuart32_read(port, UARTWATER) >> UARTWATER_RXCNT_OFF))

Please remove redundant blank space.

> return NO_POLL_CHAR;
>
> return lpuart32_read(port, UARTDATA);
> --
> 2.28.0