Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d22f8f10 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

serial: 8250: Fix lost rx state



When max_count is reached, the rx loop exits. However, UART_LSR has
already been read so those char flags are lost, and subsequent rx
status will be for the wrong byte until the rx fifo drains.

Reported-by: default avatarGeorge Spelvin <linux@horizon.com>
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3f6b3ce0
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1478,16 +1478,17 @@ static void serial8250_read_char(struct uart_8250_port *up, unsigned char 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)
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);
		if (--max_count == 0)
			break;
		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));
	spin_unlock(&port->lock);
	tty_flip_buffer_push(&port->state->port);
	spin_lock(&port->lock);