USB: drop tty argument from usb_serial_handle_sysrq_char()
[firefly-linux-kernel-4.4.55.git] / drivers / usb / serial / generic.c
index a817ced82835addd1be02ed338071e09427b9cca..1abe34c38c08f3a4d5698e70ee9fb6ae683d4440 100644 (file)
@@ -208,18 +208,23 @@ retry:
        urb->transfer_buffer_length = count;
        usb_serial_debug_data(debug, &port->dev, __func__, count,
                                                urb->transfer_buffer);
+       spin_lock_irqsave(&port->lock, flags);
+       port->tx_bytes += count;
+       spin_unlock_irqrestore(&port->lock, flags);
+
+       clear_bit(i, &port->write_urbs_free);
        result = usb_submit_urb(urb, GFP_ATOMIC);
        if (result) {
                dev_err(&port->dev, "%s - error submitting urb: %d\n",
                                                __func__, result);
+               set_bit(i, &port->write_urbs_free);
+               spin_lock_irqsave(&port->lock, flags);
+               port->tx_bytes -= count;
+               spin_unlock_irqrestore(&port->lock, flags);
+
                clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
                return result;
        }
-       clear_bit(i, &port->write_urbs_free);
-
-       spin_lock_irqsave(&port->lock, flags);
-       port->tx_bytes += count;
-       spin_unlock_irqrestore(&port->lock, flags);
 
        /* Try sending off another urb, unless in irq context (in which case
         * there will be no free urb). */
@@ -338,7 +343,7 @@ void usb_serial_generic_process_read_urb(struct urb *urb)
                tty_insert_flip_string(tty, ch, urb->actual_length);
        else {
                for (i = 0; i < urb->actual_length; i++, ch++) {
-                       if (!usb_serial_handle_sysrq_char(tty, port, *ch))
+                       if (!usb_serial_handle_sysrq_char(port, *ch))
                                tty_insert_flip_char(tty, *ch, TTY_NORMAL);
                }
        }
@@ -443,12 +448,11 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
 EXPORT_SYMBOL_GPL(usb_serial_generic_unthrottle);
 
 #ifdef CONFIG_MAGIC_SYSRQ
-int usb_serial_handle_sysrq_char(struct tty_struct *tty,
-                       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 (ch && time_before(jiffies, port->sysrq)) {
-                       handle_sysrq(ch, tty);
+                       handle_sysrq(ch);
                        port->sysrq = 0;
                        return 1;
                }
@@ -457,8 +461,7 @@ int usb_serial_handle_sysrq_char(struct tty_struct *tty,
        return 0;
 }
 #else
-int usb_serial_handle_sysrq_char(struct tty_struct *tty,
-                       struct usb_serial_port *port, unsigned int ch)
+int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
 {
        return 0;
 }