]> Pileus Git - ~andy/linux/blobdiff - drivers/usb/serial/spcp8x5.c
TTY: switch tty_flip_buffer_push
[~andy/linux] / drivers / usb / serial / spcp8x5.c
index 04e3731527245527b3cb85c17daa7b1ca1cbc32d..91ff8e3bddbd76a4daa3502d17dd2aaab96ac154 100644 (file)
@@ -462,7 +462,6 @@ static void spcp8x5_process_read_urb(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
-       struct tty_struct *tty;
        unsigned char *data = urb->transfer_buffer;
        unsigned long flags;
        u8 status;
@@ -481,9 +480,6 @@ static void spcp8x5_process_read_urb(struct urb *urb)
        if (!urb->actual_length)
                return;
 
-       tty = tty_port_tty_get(&port->port);
-       if (!tty)
-               return;
 
        if (status & UART_STATE_TRANSIENT_MASK) {
                /* break takes precedence over parity, which takes precedence
@@ -500,15 +496,19 @@ static void spcp8x5_process_read_urb(struct urb *urb)
                if (status & UART_OVERRUN_ERROR)
                        tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
 
-               if (status & UART_DCD)
-                       usb_serial_handle_dcd_change(port, tty,
-                                  priv->line_status & MSR_STATUS_LINE_DCD);
+               if (status & UART_DCD) {
+                       struct tty_struct *tty = tty_port_tty_get(&port->port);
+                       if (tty) {
+                               usb_serial_handle_dcd_change(port, tty,
+                                      priv->line_status & MSR_STATUS_LINE_DCD);
+                               tty_kref_put(tty);
+                       }
+               }
        }
 
        tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag,
                                                        urb->actual_length);
-       tty_flip_buffer_push(tty);
-       tty_kref_put(tty);
+       tty_flip_buffer_push(&port->port);
 }
 
 static int spcp8x5_wait_modem_info(struct usb_serial_port *port,