提交 90500797 编写于 作者: S Stefan-gabriel Mirea 提交者: Greg Kroah-Hartman

tty: serial: linflexuart: Fix magic SysRq handling

Following an incorrect indentation reported to me by Dan Carpenter, I
noticed that the SysRq lines were inherited from the lpuart driver[1] (note
how the 'continue' is aligned to 'sport->port.sysrq = 0') and we have never
actually tested the SysRq support.

'sport->sysrq = 0' is not necessary neither before nor after 'continue',
because sysrq will already be 0 after uart_handle_sysrq_char() will finish.
Also, since the LINFlexD driver never called uart_handle_break(), sysrq
would have never been set to a nonzero value, so uart_handle_sysrq_char()
was not going to do anything.

Break conditions are detected based on a null data byte along with a
framing error (stop bit sampled to 0).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/fsl_lpuart.c?h=b3e3bf2ef2c74f5ce5c19510edbbb9bfc1d249c2#n659

Fixes: 09864c1c ("tty: serial: Add linflexuart driver for S32V234")
Signed-off-by: NStefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Reported-by: Nkbuild test robot <lkp@intel.com>
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20190918184439.7465-1-stefan-gabriel.mirea@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 392fb8df
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Freescale linflexuart serial port driver * Freescale linflexuart serial port driver
* *
* Copyright 2012-2016 Freescale Semiconductor, Inc. * Copyright 2012-2016 Freescale Semiconductor, Inc.
* Copyright 2017-2018 NXP * Copyright 2017-2019 NXP
*/ */
#if defined(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE) && \ #if defined(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE) && \
...@@ -246,12 +246,14 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id) ...@@ -246,12 +246,14 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
struct tty_port *port = &sport->state->port; struct tty_port *port = &sport->state->port;
unsigned long flags, status; unsigned long flags, status;
unsigned char rx; unsigned char rx;
bool brk;
spin_lock_irqsave(&sport->lock, flags); spin_lock_irqsave(&sport->lock, flags);
status = readl(sport->membase + UARTSR); status = readl(sport->membase + UARTSR);
while (status & LINFLEXD_UARTSR_RMB) { while (status & LINFLEXD_UARTSR_RMB) {
rx = readb(sport->membase + BDRM); rx = readb(sport->membase + BDRM);
brk = false;
flg = TTY_NORMAL; flg = TTY_NORMAL;
sport->icount.rx++; sport->icount.rx++;
...@@ -261,8 +263,11 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id) ...@@ -261,8 +263,11 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
status |= LINFLEXD_UARTSR_SZF; status |= LINFLEXD_UARTSR_SZF;
if (status & LINFLEXD_UARTSR_BOF) if (status & LINFLEXD_UARTSR_BOF)
status |= LINFLEXD_UARTSR_BOF; status |= LINFLEXD_UARTSR_BOF;
if (status & LINFLEXD_UARTSR_FEF) if (status & LINFLEXD_UARTSR_FEF) {
if (!rx)
brk = true;
status |= LINFLEXD_UARTSR_FEF; status |= LINFLEXD_UARTSR_FEF;
}
if (status & LINFLEXD_UARTSR_PE) if (status & LINFLEXD_UARTSR_PE)
status |= LINFLEXD_UARTSR_PE; status |= LINFLEXD_UARTSR_PE;
} }
...@@ -271,13 +276,15 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id) ...@@ -271,13 +276,15 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
sport->membase + UARTSR); sport->membase + UARTSR);
status = readl(sport->membase + UARTSR); status = readl(sport->membase + UARTSR);
if (uart_handle_sysrq_char(sport, (unsigned char)rx)) if (brk) {
continue; uart_handle_break(sport);
} else {
#ifdef SUPPORT_SYSRQ #ifdef SUPPORT_SYSRQ
sport->sysrq = 0; if (uart_handle_sysrq_char(sport, (unsigned char)rx))
continue;
#endif #endif
tty_insert_flip_char(port, rx, flg); tty_insert_flip_char(port, rx, flg);
}
} }
spin_unlock_irqrestore(&sport->lock, flags); spin_unlock_irqrestore(&sport->lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册