Commit 37ae2315 authored by Johan Hovold's avatar Johan Hovold

USB: serial: only set sysrq timestamp for consoles

Only set the sysrq timestamp for console ports to avoid having every
driver also check the console flag when processing incoming data.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 733fff67
......@@ -424,7 +424,7 @@ static void f81232_process_read_urb(struct urb *urb)
lsr = data[i];
tty_flag = f81232_handle_lsr(port, lsr);
if (port->port.console && port->sysrq) {
if (port->sysrq) {
if (usb_serial_handle_sysrq_char(port, data[i + 1]))
continue;
}
......@@ -461,7 +461,7 @@ static void f81534a_process_read_urb(struct urb *urb)
lsr = data[len - 1];
tty_flag = f81232_handle_lsr(port, lsr);
if (port->port.console && port->sysrq) {
if (port->sysrq) {
for (i = 1; i < len - 1; ++i) {
if (!usb_serial_handle_sysrq_char(port, data[i])) {
tty_insert_flip_char(&port->port, data[i],
......
......@@ -1238,7 +1238,7 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
schedule_work(&port_priv->lsr_work);
}
if (port->port.console && port->sysrq) {
if (port->sysrq) {
if (usb_serial_handle_sysrq_char(port, data[i]))
continue;
}
......
......@@ -2561,7 +2561,7 @@ static int ftdi_process_packet(struct usb_serial_port *port,
port->icount.rx += len - 2;
if (brkint || (port->port.console && port->sysrq)) {
if (brkint || port->sysrq) {
for (i = 2; i < len; i++) {
if (brkint && i == len - 1) {
if (usb_serial_handle_break(port))
......
......@@ -355,13 +355,13 @@ void usb_serial_generic_process_read_urb(struct urb *urb)
* stuff like 3G modems, so shortcircuit it in the 99.9999999% of
* cases where the USB serial is not a console anyway.
*/
if (!port->port.console || !port->sysrq) {
tty_insert_flip_string(&port->port, ch, urb->actual_length);
} else {
if (port->sysrq) {
for (i = 0; i < urb->actual_length; i++, ch++) {
if (!usb_serial_handle_sysrq_char(port, *ch))
tty_insert_flip_char(&port->port, *ch, TTY_NORMAL);
}
} else {
tty_insert_flip_string(&port->port, ch, urb->actual_length);
}
tty_flip_buffer_push(&port->port);
}
......@@ -574,7 +574,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
#ifdef CONFIG_MAGIC_SYSRQ
int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
{
if (port->sysrq && port->port.console) {
if (port->sysrq) {
if (ch && time_before(jiffies, port->sysrq)) {
handle_sysrq(ch);
port->sysrq = 0;
......@@ -594,6 +594,9 @@ EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
int usb_serial_handle_break(struct usb_serial_port *port)
{
if (!port->port.console)
return 0;
if (!port->sysrq) {
port->sysrq = jiffies + HZ*5;
return 1;
......
......@@ -327,14 +327,14 @@ static void mxuport_process_read_urb_data(struct usb_serial_port *port,
{
int i;
if (!port->port.console || !port->sysrq) {
tty_insert_flip_string(&port->port, data, size);
} else {
if (port->sysrq) {
for (i = 0; i < size; i++, data++) {
if (!usb_serial_handle_sysrq_char(port, *data))
tty_insert_flip_char(&port->port, *data,
TTY_NORMAL);
}
} else {
tty_insert_flip_string(&port->port, data, size);
}
tty_flip_buffer_push(&port->port);
}
......
......@@ -1101,7 +1101,7 @@ static void pl2303_process_read_urb(struct urb *urb)
if (line_status & UART_OVERRUN_ERROR)
tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
if (port->port.console && port->sysrq) {
if (port->sysrq) {
for (i = 0; i < urb->actual_length; ++i)
if (!usb_serial_handle_sysrq_char(port, data[i]))
tty_insert_flip_char(&port->port, data[i],
......
......@@ -517,13 +517,14 @@ static void ssu100_process_read_urb(struct urb *urb)
if (!len)
return; /* status only */
if (port->port.console && port->sysrq) {
if (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);
}
} else
} else {
tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
}
tty_flip_buffer_push(&port->port);
}
......
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