diff mbox series

serial: sh: Improve FIFO empty check on RX

Message ID 20200809112259.7763-1-marek.vasut+renesas@gmail.com
State Accepted
Commit f5ba5c90d4b9c4d691a62eaca47dc095eefba8b1
Delegated to: Marek Vasut
Headers show
Series serial: sh: Improve FIFO empty check on RX | expand

Commit Message

Marek Vasut Aug. 9, 2020, 11:22 a.m. UTC
If the SCIF is receiving data quickly enough, it may happen that the
SCxSR_RDxF flag is cleared in sh_serial_getc_generic(), while the
FIFO still contains data. If that happens, the serial_getc_check()
reports no data in the FIFO as the flag is no longer set. Add one
more check, if the SCxSR_RDxF is not set, read out the FIFO level
and if there are still characters in the FIFO, permit reading them

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
 drivers/serial/serial_sh.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index 13b179f03d..e27d256574 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -116,7 +116,10 @@  static int serial_getc_check(struct uart_port *port)
 	if (sci_in(port, SCLSR) & SCxSR_ORER(port))
-	return status & (SCIF_DR | SCxSR_RDxF(port));
+	status &= (SCIF_DR | SCxSR_RDxF(port));
+	if (status)
+		return status;
+	return scif_rxfill(port);
 static int sh_serial_getc_generic(struct uart_port *port)