]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tty: serial: fsl_lpuart: correct the count of break characters
authorSherry Sun <sherry.sun@nxp.com>
Mon, 25 Jul 2022 05:01:15 +0000 (13:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:12 +0000 (14:24 +0200)
[ Upstream commit 4a4cd6b2c99e3fc9a912a83dc99c71f7658f39d0 ]

The LPUART can't distinguish between a break signal and a framing error,
so need to count the break characters if there is a framing error and
received data is zero instead of the parity error.

Fixes: ee10bc2bc733 ("serial: fsl_lpuart: handle break and make sysrq work")
Reviewed-by: Michael Walle <michael@walle.cc>
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Link: https://lore.kernel.org/r/20220725050115.12396-1-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/fsl_lpuart.c

index 481107fdd69bced6965d2e4d7c9b4122bd159404..4155bd10711daf2ac412cf6cc49f54eddec8abf7 100644 (file)
@@ -982,12 +982,12 @@ static void lpuart32_rxint(struct lpuart_port *sport)
 
                if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) {
                        if (sr & UARTSTAT_PE) {
+                               sport->port.icount.parity++;
+                       } else if (sr & UARTSTAT_FE) {
                                if (is_break)
                                        sport->port.icount.brk++;
                                else
-                                       sport->port.icount.parity++;
-                       } else if (sr & UARTSTAT_FE) {
-                               sport->port.icount.frame++;
+                                       sport->port.icount.frame++;
                        }
 
                        if (sr & UARTSTAT_OR)
@@ -1002,12 +1002,12 @@ static void lpuart32_rxint(struct lpuart_port *sport)
                        sr &= sport->port.read_status_mask;
 
                        if (sr & UARTSTAT_PE) {
+                               flg = TTY_PARITY;
+                       } else if (sr & UARTSTAT_FE) {
                                if (is_break)
                                        flg = TTY_BREAK;
                                else
-                                       flg = TTY_PARITY;
-                       } else if (sr & UARTSTAT_FE) {
-                               flg = TTY_FRAME;
+                                       flg = TTY_FRAME;
                        }
 
                        if (sr & UARTSTAT_OR)