diff options
author | Johan Hovold <johan@kernel.org> | 2020-07-08 14:49:54 +0200 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2020-07-09 09:19:54 +0200 |
commit | 37ae231554f401104bf21847f9093d647a47faa4 (patch) | |
tree | f8d49b26c7a882f96dc3470bf8b8426f93cda877 /drivers/usb/serial | |
parent | 733fff67941dad64b8a630450b8372b1873edc41 (diff) |
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/f81232.c | 4 | ||||
-rw-r--r-- | drivers/usb/serial/f81534.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/generic.c | 11 | ||||
-rw-r--r-- | drivers/usb/serial/mxuport.c | 6 | ||||
-rw-r--r-- | drivers/usb/serial/pl2303.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/ssu100.c | 5 |
7 files changed, 18 insertions, 14 deletions
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index dcda7fb164b4..0c7eacc630e0 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -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], diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 2b39bda035c7..5661fd03e545 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -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; } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 07b146d7033a..ade68405b015 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -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)) diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 5cdf180cda23..05a2a3aa3963 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -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; diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c index 2513ee902779..5d38c2a0f590 100644 --- a/drivers/usb/serial/mxuport.c +++ b/drivers/usb/serial/mxuport.c @@ -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); } diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index c5a2995dfa2e..048452d8a4a4 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -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], diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index f6aea9f1be1a..01472b96bf38 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -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); } |