提交 6020c3be 编写于 作者: J Johan Hovold 提交者: Greg Kroah-Hartman

USB: pl2303: clean up line-status handling

Clean up line-status handling somewhat.
Get tty-reference only when actually needed.
Signed-off-by: NJohan Hovold <jhovold@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 b6934681
...@@ -808,7 +808,8 @@ static void pl2303_update_line_status(struct usb_serial_port *port, ...@@ -808,7 +808,8 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
struct tty_struct *tty; struct tty_struct *tty;
unsigned long flags; unsigned long flags;
unsigned int status_idx = UART_STATE_INDEX; unsigned int status_idx = UART_STATE_INDEX;
u8 prev_line_status; u8 status;
u8 delta;
if (spriv->quirks & PL2303_QUIRK_UART_STATE_IDX0) if (spriv->quirks & PL2303_QUIRK_UART_STATE_IDX0)
status_idx = 0; status_idx = 0;
...@@ -816,24 +817,27 @@ static void pl2303_update_line_status(struct usb_serial_port *port, ...@@ -816,24 +817,27 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
if (actual_length < status_idx + 1) if (actual_length < status_idx + 1)
return; return;
status = data[status_idx];
/* Save off the uart status for others to look at */ /* Save off the uart status for others to look at */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
prev_line_status = priv->line_status; delta = priv->line_status ^ status;
priv->line_status = data[status_idx]; priv->line_status = status;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
if (priv->line_status & UART_BREAK_ERROR) if (status & UART_BREAK_ERROR)
usb_serial_handle_break(port); usb_serial_handle_break(port);
wake_up_interruptible(&port->port.delta_msr_wait); wake_up_interruptible(&port->port.delta_msr_wait);
tty = tty_port_tty_get(&port->port); if (delta & UART_DCD) {
if (!tty) tty = tty_port_tty_get(&port->port);
return; if (tty) {
if ((priv->line_status ^ prev_line_status) & UART_DCD) usb_serial_handle_dcd_change(port, tty,
usb_serial_handle_dcd_change(port, tty, status & UART_DCD);
priv->line_status & UART_DCD); tty_kref_put(tty);
tty_kref_put(tty); }
}
} }
static void pl2303_read_int_callback(struct urb *urb) static void pl2303_read_int_callback(struct urb *urb)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册