Commit b770081f authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: ch341: clean up line-status handling

Clean up line-status handling.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ac035628
...@@ -444,25 +444,31 @@ static void ch341_update_line_status(struct usb_serial_port *port, ...@@ -444,25 +444,31 @@ static void ch341_update_line_status(struct usb_serial_port *port,
unsigned char *data, size_t len) unsigned char *data, size_t len)
{ {
struct ch341_private *priv = usb_get_serial_port_data(port); struct ch341_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty;
unsigned long flags; unsigned long flags;
u8 prev_line_status = priv->line_status; u8 status;
u8 delta;
if (len < 4) if (len < 4)
return; return;
status = ~data[2] & CH341_BITS_MODEM_STAT;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
priv->line_status = (~(data[2])) & CH341_BITS_MODEM_STAT; delta = status ^ priv->line_status;
if ((data[1] & CH341_MULT_STAT)) priv->line_status = status;
if (data[1] & CH341_MULT_STAT)
priv->multi_status_change = 1; priv->multi_status_change = 1;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
if ((priv->line_status ^ prev_line_status) & CH341_BIT_DCD) { if (delta & CH341_BIT_DCD) {
struct tty_struct *tty = tty_port_tty_get(&port->port); tty = tty_port_tty_get(&port->port);
if (tty) if (tty) {
usb_serial_handle_dcd_change(port, tty, usb_serial_handle_dcd_change(port, tty,
priv->line_status & CH341_BIT_DCD); status & CH341_BIT_DCD);
tty_kref_put(tty); tty_kref_put(tty);
} }
}
wake_up_interruptible(&port->port.delta_msr_wait); wake_up_interruptible(&port->port.delta_msr_wait);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment