Commit 3f6b3ce0 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

serial: 8250: Refactor serial8250_rx_chars() inner loop

Factor the read/process one char inner loop to a separate helper
function serial8250_read_char(). No functional change.
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 87108bc9
...@@ -1412,20 +1412,12 @@ static void serial8250_enable_ms(struct uart_port *port) ...@@ -1412,20 +1412,12 @@ static void serial8250_enable_ms(struct uart_port *port)
serial8250_rpm_put(up); serial8250_rpm_put(up);
} }
/* static void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr)
* serial8250_rx_chars: processes according to the passed in LSR
* value, and returns the remaining LSR bits not handled
* by this Rx routine.
*/
unsigned char
serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
{ {
struct uart_port *port = &up->port; struct uart_port *port = &up->port;
unsigned char ch; unsigned char ch;
int max_count = 256; char flag = TTY_NORMAL;
char flag;
do {
if (likely(lsr & UART_LSR_DR)) if (likely(lsr & UART_LSR_DR))
ch = serial_in(up, UART_RX); ch = serial_in(up, UART_RX);
else else
...@@ -1438,7 +1430,6 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1438,7 +1430,6 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
*/ */
ch = 0; ch = 0;
flag = TTY_NORMAL;
port->icount.rx++; port->icount.rx++;
lsr |= up->lsr_saved_flags; lsr |= up->lsr_saved_flags;
...@@ -1455,7 +1446,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1455,7 +1446,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
* or read_status_mask. * or read_status_mask.
*/ */
if (uart_handle_break(port)) if (uart_handle_break(port))
goto ignore_char; return;
} else if (lsr & UART_LSR_PE) } else if (lsr & UART_LSR_PE)
port->icount.parity++; port->icount.parity++;
else if (lsr & UART_LSR_FE) else if (lsr & UART_LSR_FE)
...@@ -1477,11 +1468,24 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1477,11 +1468,24 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
flag = TTY_FRAME; flag = TTY_FRAME;
} }
if (uart_handle_sysrq_char(port, ch)) if (uart_handle_sysrq_char(port, ch))
goto ignore_char; return;
uart_insert_char(port, lsr, UART_LSR_OE, ch, flag); uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
}
ignore_char: /*
* serial8250_rx_chars: processes according to the passed in LSR
* value, and returns the remaining LSR bits not handled
* by this Rx routine.
*/
unsigned char
serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
{
struct uart_port *port = &up->port;
int max_count = 256;
do {
serial8250_read_char(up, lsr);
lsr = serial_in(up, UART_LSR); lsr = serial_in(up, UART_LSR);
} while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (--max_count > 0)); } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (--max_count > 0));
spin_unlock(&port->lock); spin_unlock(&port->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment