Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: <stable@vger.kernel.org>
Signed-off-by: Kazuhiro Fujita <kazuhiro.fujita.jg@renesas.com>
Signed-off-by: Hao Bui <hao.bui.yg@renesas.com>
Signed-off-by: KAZUMI HARADA <kazumi.harada.rh@renesas.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/1585333048-31828-1-git-send-email-kazuhiro.fujita.jg@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kazuhiro Fujita and committed by
Greg Kroah-Hartman
3dc4db36 0f87aa66

+9 -2
+9 -2
drivers/tty/serial/sh-sci.c
··· 870 870 tty_insert_flip_char(tport, c, TTY_NORMAL); 871 871 } else { 872 872 for (i = 0; i < count; i++) { 873 - char c = serial_port_in(port, SCxRDR); 873 + char c; 874 874 875 - status = serial_port_in(port, SCxSR); 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 + } 876 883 if (uart_handle_sysrq_char(port, c)) { 877 884 count--; i--; 878 885 continue;