Commit 6c00bc59 authored by Johan Hovold's avatar Johan Hovold Committed by Kelsey Skunberg

USB: serial: ftdi_sio: clean up receive processing

BugLink: https://bugs.launchpad.net/bugs/1892822

[ Upstream commit ce054039 ]

Clean up receive processing by dropping the character pointer and
keeping the length argument unchanged throughout the function.

Also make it more apparent that sysrq processing can consume a
characters by adding an explicit continue.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent fba0796b
......@@ -2054,7 +2054,6 @@ static int ftdi_process_packet(struct usb_serial_port *port,
struct ftdi_private *priv, unsigned char *buf, int len)
{
unsigned char status;
unsigned char *ch;
int i;
char flag;
......@@ -2097,8 +2096,7 @@ static int ftdi_process_packet(struct usb_serial_port *port,
else
priv->transmit_empty = 0;
len -= 2;
if (!len)
if (len == 2)
return 0; /* status only */
/*
......@@ -2127,19 +2125,20 @@ static int ftdi_process_packet(struct usb_serial_port *port,
}
}
port->icount.rx += len;
ch = buf + 2;
port->icount.rx += len - 2;
if (port->port.console && port->sysrq) {
for (i = 0; i < len; i++, ch++) {
if (!usb_serial_handle_sysrq_char(port, *ch))
tty_insert_flip_char(&port->port, *ch, flag);
for (i = 2; i < len; i++) {
if (usb_serial_handle_sysrq_char(port, buf[i]))
continue;
tty_insert_flip_char(&port->port, buf[i], flag);
}
} else {
tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag,
len - 2);
}
return len;
return len - 2;
}
static void ftdi_process_read_urb(struct urb *urb)
......
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