aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-01-02 16:49:29 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-03 15:42:24 -0500
commitb770081f88b75212d61a63a84274e491eb54b25a (patch)
tree8eeb43423756f4a7839d26c4cd1989001f8ec7d7
parentac035628a95f20ff4c53b80c4b80e12287231e1a (diff)
USB: ch341: clean up line-status handling
Clean up line-status handling. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/ch341.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index f647dbdcb27d..9dd94a7e08b9 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -444,24 +444,30 @@ static void ch341_update_line_status(struct usb_serial_port *port,
444 unsigned char *data, size_t len) 444 unsigned char *data, size_t len)
445{ 445{
446 struct ch341_private *priv = usb_get_serial_port_data(port); 446 struct ch341_private *priv = usb_get_serial_port_data(port);
447 struct tty_struct *tty;
447 unsigned long flags; 448 unsigned long flags;
448 u8 prev_line_status = priv->line_status; 449 u8 status;
450 u8 delta;
449 451
450 if (len < 4) 452 if (len < 4)
451 return; 453 return;
452 454
455 status = ~data[2] & CH341_BITS_MODEM_STAT;
456
453 spin_lock_irqsave(&priv->lock, flags); 457 spin_lock_irqsave(&priv->lock, flags);
454 priv->line_status = (~(data[2])) & CH341_BITS_MODEM_STAT; 458 delta = status ^ priv->line_status;
455 if ((data[1] & CH341_MULT_STAT)) 459 priv->line_status = status;
460 if (data[1] & CH341_MULT_STAT)
456 priv->multi_status_change = 1; 461 priv->multi_status_change = 1;
457 spin_unlock_irqrestore(&priv->lock, flags); 462 spin_unlock_irqrestore(&priv->lock, flags);
458 463
459 if ((priv->line_status ^ prev_line_status) & CH341_BIT_DCD) { 464 if (delta & CH341_BIT_DCD) {
460 struct tty_struct *tty = tty_port_tty_get(&port->port); 465 tty = tty_port_tty_get(&port->port);
461 if (tty) 466 if (tty) {
462 usb_serial_handle_dcd_change(port, tty, 467 usb_serial_handle_dcd_change(port, tty,
463 priv->line_status & CH341_BIT_DCD); 468 status & CH341_BIT_DCD);
464 tty_kref_put(tty); 469 tty_kref_put(tty);
470 }
465 } 471 }
466 472
467 wake_up_interruptible(&port->port.delta_msr_wait); 473 wake_up_interruptible(&port->port.delta_msr_wait);