提交 461d696a 编写于 作者: G Greg Kroah-Hartman

USB: serial: pl2303: clean up urb->status usage

This done in anticipation of removal of urb->status, which will make
that patch easier to review and apply in the future.


Cc: <linux-usb-devel@lists.sourceforge.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 78c26aeb
...@@ -961,11 +961,12 @@ static void pl2303_read_int_callback(struct urb *urb) ...@@ -961,11 +961,12 @@ static void pl2303_read_int_callback(struct urb *urb)
struct usb_serial_port *port = (struct usb_serial_port *) urb->context; struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
unsigned int actual_length = urb->actual_length; unsigned int actual_length = urb->actual_length;
int status; int status = urb->status;
int retval;
dbg("%s (%d)", __FUNCTION__, port->number); dbg("%s (%d)", __FUNCTION__, port->number);
switch (urb->status) { switch (status) {
case 0: case 0:
/* success */ /* success */
break; break;
...@@ -974,11 +975,11 @@ static void pl2303_read_int_callback(struct urb *urb) ...@@ -974,11 +975,11 @@ static void pl2303_read_int_callback(struct urb *urb)
case -ESHUTDOWN: case -ESHUTDOWN:
/* this urb is terminated, clean up */ /* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d", __FUNCTION__, dbg("%s - urb shutting down with status: %d", __FUNCTION__,
urb->status); status);
return; return;
default: default:
dbg("%s - nonzero urb status received: %d", __FUNCTION__, dbg("%s - nonzero urb status received: %d", __FUNCTION__,
urb->status); status);
goto exit; goto exit;
} }
...@@ -988,11 +989,11 @@ static void pl2303_read_int_callback(struct urb *urb) ...@@ -988,11 +989,11 @@ static void pl2303_read_int_callback(struct urb *urb)
pl2303_update_line_status(port, data, actual_length); pl2303_update_line_status(port, data, actual_length);
exit: exit:
status = usb_submit_urb(urb, GFP_ATOMIC); retval = usb_submit_urb(urb, GFP_ATOMIC);
if (status) if (retval)
dev_err(&urb->dev->dev, dev_err(&urb->dev->dev,
"%s - usb_submit_urb failed with result %d\n", "%s - usb_submit_urb failed with result %d\n",
__FUNCTION__, status); __FUNCTION__, retval);
} }
static void pl2303_read_bulk_callback(struct urb *urb) static void pl2303_read_bulk_callback(struct urb *urb)
...@@ -1004,23 +1005,23 @@ static void pl2303_read_bulk_callback(struct urb *urb) ...@@ -1004,23 +1005,23 @@ static void pl2303_read_bulk_callback(struct urb *urb)
unsigned long flags; unsigned long flags;
int i; int i;
int result; int result;
u8 status; int status = urb->status;
u8 line_status;
char tty_flag; char tty_flag;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (urb->status) { if (status) {
dbg("%s - urb->status = %d", __FUNCTION__, urb->status); dbg("%s - urb status = %d", __FUNCTION__, status);
if (!port->open_count) { if (!port->open_count) {
dbg("%s - port is closed, exiting.", __FUNCTION__); dbg("%s - port is closed, exiting.", __FUNCTION__);
return; return;
} }
if (urb->status == -EPROTO) { if (status == -EPROTO) {
/* PL2303 mysteriously fails with -EPROTO reschedule /* PL2303 mysteriously fails with -EPROTO reschedule
* the read */ * the read */
dbg("%s - caught -EPROTO, resubmitting the urb", dbg("%s - caught -EPROTO, resubmitting the urb",
__FUNCTION__); __FUNCTION__);
urb->status = 0;
urb->dev = port->serial->dev; urb->dev = port->serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) if (result)
...@@ -1040,18 +1041,18 @@ static void pl2303_read_bulk_callback(struct urb *urb) ...@@ -1040,18 +1041,18 @@ static void pl2303_read_bulk_callback(struct urb *urb)
tty_flag = TTY_NORMAL; tty_flag = TTY_NORMAL;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
status = priv->line_status; line_status = priv->line_status;
priv->line_status &= ~UART_STATE_TRANSIENT_MASK; priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
wake_up_interruptible(&priv->delta_msr_wait); wake_up_interruptible(&priv->delta_msr_wait);
/* break takes precedence over parity, */ /* break takes precedence over parity, */
/* which takes precedence over framing errors */ /* which takes precedence over framing errors */
if (status & UART_BREAK_ERROR ) if (line_status & UART_BREAK_ERROR )
tty_flag = TTY_BREAK; tty_flag = TTY_BREAK;
else if (status & UART_PARITY_ERROR) else if (line_status & UART_PARITY_ERROR)
tty_flag = TTY_PARITY; tty_flag = TTY_PARITY;
else if (status & UART_FRAME_ERROR) else if (line_status & UART_FRAME_ERROR)
tty_flag = TTY_FRAME; tty_flag = TTY_FRAME;
dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag);
...@@ -1059,7 +1060,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) ...@@ -1059,7 +1060,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
tty_buffer_request_room(tty, urb->actual_length + 1); tty_buffer_request_room(tty, urb->actual_length + 1);
/* overrun is special, not associated with a char */ /* overrun is special, not associated with a char */
if (status & UART_OVERRUN_ERROR) if (line_status & UART_OVERRUN_ERROR)
tty_insert_flip_char(tty, 0, TTY_OVERRUN); tty_insert_flip_char(tty, 0, TTY_OVERRUN);
for (i = 0; i < urb->actual_length; ++i) for (i = 0; i < urb->actual_length; ++i)
tty_insert_flip_char(tty, data[i], tty_flag); tty_insert_flip_char(tty, data[i], tty_flag);
...@@ -1083,10 +1084,11 @@ static void pl2303_write_bulk_callback(struct urb *urb) ...@@ -1083,10 +1084,11 @@ static void pl2303_write_bulk_callback(struct urb *urb)
struct usb_serial_port *port = (struct usb_serial_port *) urb->context; struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
struct pl2303_private *priv = usb_get_serial_port_data(port); struct pl2303_private *priv = usb_get_serial_port_data(port);
int result; int result;
int status = urb->status;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
switch (urb->status) { switch (status) {
case 0: case 0:
/* success */ /* success */
break; break;
...@@ -1095,14 +1097,14 @@ static void pl2303_write_bulk_callback(struct urb *urb) ...@@ -1095,14 +1097,14 @@ static void pl2303_write_bulk_callback(struct urb *urb)
case -ESHUTDOWN: case -ESHUTDOWN:
/* this urb is terminated, clean up */ /* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d", __FUNCTION__, dbg("%s - urb shutting down with status: %d", __FUNCTION__,
urb->status); status);
priv->write_urb_in_use = 0; priv->write_urb_in_use = 0;
return; return;
default: default:
/* error in the urb, so we have to resubmit it */ /* error in the urb, so we have to resubmit it */
dbg("%s - Overflow in write", __FUNCTION__); dbg("%s - Overflow in write", __FUNCTION__);
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
urb->status); status);
port->write_urb->transfer_buffer_length = 1; port->write_urb->transfer_buffer_length = 1;
port->write_urb->dev = port->serial->dev; port->write_urb->dev = port->serial->dev;
result = usb_submit_urb(port->write_urb, GFP_ATOMIC); result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册