aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-01-02 16:49:21 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-03 15:42:23 -0500
commit6020c3bec359873c1e4081785f220db99694c4e4 (patch)
treeadb208e59a8b8fcfad8878482b481b21e15f3c1b
parentb693468155f5650dcaf01089ecf2b56ab66f9271 (diff)
USB: pl2303: clean up line-status handling
Clean up line-status handling somewhat. Get tty-reference only when actually needed. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/pl2303.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 9951dfddc784..11de1f169308 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -808,7 +808,8 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
808 struct tty_struct *tty; 808 struct tty_struct *tty;
809 unsigned long flags; 809 unsigned long flags;
810 unsigned int status_idx = UART_STATE_INDEX; 810 unsigned int status_idx = UART_STATE_INDEX;
811 u8 prev_line_status; 811 u8 status;
812 u8 delta;
812 813
813 if (spriv->quirks & PL2303_QUIRK_UART_STATE_IDX0) 814 if (spriv->quirks & PL2303_QUIRK_UART_STATE_IDX0)
814 status_idx = 0; 815 status_idx = 0;
@@ -816,24 +817,27 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
816 if (actual_length < status_idx + 1) 817 if (actual_length < status_idx + 1)
817 return; 818 return;
818 819
820 status = data[status_idx];
821
819 /* Save off the uart status for others to look at */ 822 /* Save off the uart status for others to look at */
820 spin_lock_irqsave(&priv->lock, flags); 823 spin_lock_irqsave(&priv->lock, flags);
821 prev_line_status = priv->line_status; 824 delta = priv->line_status ^ status;
822 priv->line_status = data[status_idx]; 825 priv->line_status = status;
823 spin_unlock_irqrestore(&priv->lock, flags); 826 spin_unlock_irqrestore(&priv->lock, flags);
824 827
825 if (priv->line_status & UART_BREAK_ERROR) 828 if (status & UART_BREAK_ERROR)
826 usb_serial_handle_break(port); 829 usb_serial_handle_break(port);
827 830
828 wake_up_interruptible(&port->port.delta_msr_wait); 831 wake_up_interruptible(&port->port.delta_msr_wait);
829 832
830 tty = tty_port_tty_get(&port->port); 833 if (delta & UART_DCD) {
831 if (!tty) 834 tty = tty_port_tty_get(&port->port);
832 return; 835 if (tty) {
833 if ((priv->line_status ^ prev_line_status) & UART_DCD) 836 usb_serial_handle_dcd_change(port, tty,
834 usb_serial_handle_dcd_change(port, tty, 837 status & UART_DCD);
835 priv->line_status & UART_DCD); 838 tty_kref_put(tty);
836 tty_kref_put(tty); 839 }
840 }
837} 841}
838 842
839static void pl2303_read_int_callback(struct urb *urb) 843static void pl2303_read_int_callback(struct urb *urb)