summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/pl2303.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-01-02 22:49:21 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-03 12:42:23 -0800
commit6020c3bec359873c1e4081785f220db99694c4e4 (patch)
treeadb208e59a8b8fcfad8878482b481b21e15f3c1b /drivers/usb/serial/pl2303.c
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>
Diffstat (limited to 'drivers/usb/serial/pl2303.c')
-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,
struct tty_struct *tty;
unsigned long flags;
unsigned int status_idx = UART_STATE_INDEX;
- u8 prev_line_status;
+ u8 status;
+ u8 delta;
if (spriv->quirks & PL2303_QUIRK_UART_STATE_IDX0)
status_idx = 0;
@@ -816,24 +817,27 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
if (actual_length < status_idx + 1)
return;
+ status = data[status_idx];
+
/* Save off the uart status for others to look at */
spin_lock_irqsave(&priv->lock, flags);
- prev_line_status = priv->line_status;
- priv->line_status = data[status_idx];
+ delta = priv->line_status ^ status;
+ priv->line_status = status;
spin_unlock_irqrestore(&priv->lock, flags);
- if (priv->line_status & UART_BREAK_ERROR)
+ if (status & UART_BREAK_ERROR)
usb_serial_handle_break(port);
wake_up_interruptible(&port->port.delta_msr_wait);
- tty = tty_port_tty_get(&port->port);
- if (!tty)
- return;
- if ((priv->line_status ^ prev_line_status) & UART_DCD)
- usb_serial_handle_dcd_change(port, tty,
- priv->line_status & UART_DCD);
- tty_kref_put(tty);
+ if (delta & UART_DCD) {
+ tty = tty_port_tty_get(&port->port);
+ if (tty) {
+ usb_serial_handle_dcd_change(port, tty,
+ status & UART_DCD);
+ tty_kref_put(tty);
+ }
+ }
}
static void pl2303_read_int_callback(struct urb *urb)