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) ...@@ -424,7 +424,7 @@ static void f81232_process_read_urb(struct urb *urb)
lsr = data[i]; lsr = data[i];
tty_flag = f81232_handle_lsr(port, lsr); 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])) if (usb_serial_handle_sysrq_char(port, data[i + 1]))
continue; continue;
} }
...@@ -461,7 +461,7 @@ static void f81534a_process_read_urb(struct urb *urb) ...@@ -461,7 +461,7 @@ static void f81534a_process_read_urb(struct urb *urb)
lsr = data[len - 1]; lsr = data[len - 1];
tty_flag = f81232_handle_lsr(port, lsr); tty_flag = f81232_handle_lsr(port, lsr);
if (port->port.console && port->sysrq) { if (port->sysrq) {
for (i = 1; i < len - 1; ++i) { for (i = 1; i < len - 1; ++i) {
if (!usb_serial_handle_sysrq_char(port, data[i])) { if (!usb_serial_handle_sysrq_char(port, data[i])) {
tty_insert_flip_char(&port->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, ...@@ -1238,7 +1238,7 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
schedule_work(&port_priv->lsr_work); schedule_work(&port_priv->lsr_work);
} }
if (port->port.console && port->sysrq) { if (port->sysrq) {
if (usb_serial_handle_sysrq_char(port, data[i])) if (usb_serial_handle_sysrq_char(port, data[i]))
continue; continue;
} }
......
...@@ -2561,7 +2561,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, ...@@ -2561,7 +2561,7 @@ static int ftdi_process_packet(struct usb_serial_port *port,
port->icount.rx += len - 2; port->icount.rx += len - 2;
if (brkint || (port->port.console && port->sysrq)) { if (brkint || port->sysrq) {
for (i = 2; i < len; i++) { for (i = 2; i < len; i++) {
if (brkint && i == len - 1) { if (brkint && i == len - 1) {
if (usb_serial_handle_break(port)) if (usb_serial_handle_break(port))
......
...@@ -355,13 +355,13 @@ void usb_serial_generic_process_read_urb(struct urb *urb) ...@@ -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 * stuff like 3G modems, so shortcircuit it in the 99.9999999% of
* cases where the USB serial is not a console anyway. * cases where the USB serial is not a console anyway.
*/ */
if (!port->port.console || !port->sysrq) { if (port->sysrq) {
tty_insert_flip_string(&port->port, ch, urb->actual_length);
} else {
for (i = 0; i < urb->actual_length; i++, ch++) { for (i = 0; i < urb->actual_length; i++, ch++) {
if (!usb_serial_handle_sysrq_char(port, *ch)) if (!usb_serial_handle_sysrq_char(port, *ch))
tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); 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); tty_flip_buffer_push(&port->port);
} }
...@@ -574,7 +574,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount); ...@@ -574,7 +574,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
#ifdef CONFIG_MAGIC_SYSRQ #ifdef CONFIG_MAGIC_SYSRQ
int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) 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)) { if (ch && time_before(jiffies, port->sysrq)) {
handle_sysrq(ch); handle_sysrq(ch);
port->sysrq = 0; port->sysrq = 0;
...@@ -594,6 +594,9 @@ EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); ...@@ -594,6 +594,9 @@ EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
int usb_serial_handle_break(struct usb_serial_port *port) int usb_serial_handle_break(struct usb_serial_port *port)
{ {
if (!port->port.console)
return 0;
if (!port->sysrq) { if (!port->sysrq) {
port->sysrq = jiffies + HZ*5; port->sysrq = jiffies + HZ*5;
return 1; return 1;
......
...@@ -327,14 +327,14 @@ static void mxuport_process_read_urb_data(struct usb_serial_port *port, ...@@ -327,14 +327,14 @@ static void mxuport_process_read_urb_data(struct usb_serial_port *port,
{ {
int i; int i;
if (!port->port.console || !port->sysrq) { if (port->sysrq) {
tty_insert_flip_string(&port->port, data, size);
} else {
for (i = 0; i < size; i++, data++) { for (i = 0; i < size; i++, data++) {
if (!usb_serial_handle_sysrq_char(port, *data)) if (!usb_serial_handle_sysrq_char(port, *data))
tty_insert_flip_char(&port->port, *data, tty_insert_flip_char(&port->port, *data,
TTY_NORMAL); TTY_NORMAL);
} }
} else {
tty_insert_flip_string(&port->port, data, size);
} }
tty_flip_buffer_push(&port->port); tty_flip_buffer_push(&port->port);
} }
......
...@@ -1101,7 +1101,7 @@ static void pl2303_process_read_urb(struct urb *urb) ...@@ -1101,7 +1101,7 @@ static void pl2303_process_read_urb(struct urb *urb)
if (line_status & UART_OVERRUN_ERROR) if (line_status & UART_OVERRUN_ERROR)
tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 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) for (i = 0; i < urb->actual_length; ++i)
if (!usb_serial_handle_sysrq_char(port, data[i])) if (!usb_serial_handle_sysrq_char(port, data[i]))
tty_insert_flip_char(&port->port, data[i], tty_insert_flip_char(&port->port, data[i],
......
...@@ -517,13 +517,14 @@ static void ssu100_process_read_urb(struct urb *urb) ...@@ -517,13 +517,14 @@ static void ssu100_process_read_urb(struct urb *urb)
if (!len) if (!len)
return; /* status only */ return; /* status only */
if (port->port.console && port->sysrq) { if (port->sysrq) {
for (i = 0; i < len; i++, ch++) { for (i = 0; i < len; i++, ch++) {
if (!usb_serial_handle_sysrq_char(port, *ch)) if (!usb_serial_handle_sysrq_char(port, *ch))
tty_insert_flip_char(&port->port, *ch, flag); tty_insert_flip_char(&port->port, *ch, flag);
} }
} else } else {
tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len);
}
tty_flip_buffer_push(&port->port); 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