summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/generic.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2020-07-08 14:49:54 +0200
committerJohan Hovold <johan@kernel.org>2020-07-09 09:19:54 +0200
commit37ae231554f401104bf21847f9093d647a47faa4 (patch)
treef8d49b26c7a882f96dc3470bf8b8426f93cda877 /drivers/usb/serial/generic.c
parent733fff67941dad64b8a630450b8372b1873edc41 (diff)
downloadlinux-37ae231554f401104bf21847f9093d647a47faa4.tar.gz
linux-37ae231554f401104bf21847f9093d647a47faa4.tar.bz2
linux-37ae231554f401104bf21847f9093d647a47faa4.zip
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/generic.c')
-rw-r--r--drivers/usb/serial/generic.c11
1 files changed, 7 insertions, 4 deletions
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;