Skip to content

Commit 3dc4db3

Browse files
fujitakazuhirogregkh
authored andcommitted
serial: sh-sci: Make sure status register SCxSR is read in correct sequence
For SCIF and HSCIF interfaces the SCxSR register holds the status of data that is to be read next from SCxRDR register, But where as for SCIFA and SCIFB interfaces SCxSR register holds status of data that is previously read from SCxRDR register. This patch makes sure the status register is read depending on the port types so that errors are caught accordingly. Cc: <[email protected]> Signed-off-by: Kazuhiro Fujita <[email protected]> Signed-off-by: Hao Bui <[email protected]> Signed-off-by: KAZUMI HARADA <[email protected]> Signed-off-by: Lad Prabhakar <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0f87aa6 commit 3dc4db3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,16 @@ static void sci_receive_chars(struct uart_port *port)
870870
tty_insert_flip_char(tport, c, TTY_NORMAL);
871871
} else {
872872
for (i = 0; i < count; i++) {
873-
char c = serial_port_in(port, SCxRDR);
874-
875-
status = serial_port_in(port, SCxSR);
873+
char c;
874+
875+
if (port->type == PORT_SCIF ||
876+
port->type == PORT_HSCIF) {
877+
status = serial_port_in(port, SCxSR);
878+
c = serial_port_in(port, SCxRDR);
879+
} else {
880+
c = serial_port_in(port, SCxRDR);
881+
status = serial_port_in(port, SCxSR);
882+
}
876883
if (uart_handle_sysrq_char(port, c)) {
877884
count--; i--;
878885
continue;

0 commit comments

Comments
 (0)