USB: serial: pl2303: clean up urb->status usage
Greg Kroah-Hartman [Fri, 15 Jun 2007 22:44:13 +0000 (15:44 -0700)]
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: Greg Kroah-Hartman <gregkh@suse.de>

drivers/usb/serial/pl2303.c

index 3022d65..4348c1f 100644 (file)
@@ -961,11 +961,12 @@ static void pl2303_read_int_callback(struct urb *urb)
        struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
        unsigned char *data = urb->transfer_buffer;
        unsigned int actual_length = urb->actual_length;
-       int status;
+       int status = urb->status;
+       int retval;
 
        dbg("%s (%d)", __FUNCTION__, port->number);
 
-       switch (urb->status) {
+       switch (status) {
        case 0:
                /* success */
                break;
@@ -974,11 +975,11 @@ static void pl2303_read_int_callback(struct urb *urb)
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
                dbg("%s - urb shutting down with status: %d", __FUNCTION__,
-                   urb->status);
+                   status);
                return;
        default:
                dbg("%s - nonzero urb status received: %d", __FUNCTION__,
-                   urb->status);
+                   status);
                goto exit;
        }
 
@@ -988,11 +989,11 @@ static void pl2303_read_int_callback(struct urb *urb)
        pl2303_update_line_status(port, data, actual_length);
 
 exit:
-       status = usb_submit_urb(urb, GFP_ATOMIC);
-       if (status)
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
+       if (retval)
                dev_err(&urb->dev->dev,
                        "%s - usb_submit_urb failed with result %d\n",
-                       __FUNCTION__, status);
+                       __FUNCTION__, retval);
 }
 
 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;
        int i;
        int result;
-       u8 status;
+       int status = urb->status;
+       u8 line_status;
        char tty_flag;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
-       if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+       if (status) {
+               dbg("%s - urb status = %d", __FUNCTION__, status);
                if (!port->open_count) {
                        dbg("%s - port is closed, exiting.", __FUNCTION__);
                        return;
                }
-               if (urb->status == -EPROTO) {
+               if (status == -EPROTO) {
                        /* PL2303 mysteriously fails with -EPROTO reschedule
                         * the read */
                        dbg("%s - caught -EPROTO, resubmitting the urb",
                            __FUNCTION__);
-                       urb->status = 0;
                        urb->dev = port->serial->dev;
                        result = usb_submit_urb(urb, GFP_ATOMIC);
                        if (result)
@@ -1040,18 +1041,18 @@ static void pl2303_read_bulk_callback(struct urb *urb)
        tty_flag = TTY_NORMAL;
 
        spin_lock_irqsave(&priv->lock, flags);
-       status = priv->line_status;
+       line_status = priv->line_status;
        priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
        spin_unlock_irqrestore(&priv->lock, flags);
        wake_up_interruptible(&priv->delta_msr_wait);
 
        /* break takes precedence over parity, */
        /* which takes precedence over framing errors */
-       if (status & UART_BREAK_ERROR )
+       if (line_status & UART_BREAK_ERROR )
                tty_flag = TTY_BREAK;
-       else if (status & UART_PARITY_ERROR)
+       else if (line_status & UART_PARITY_ERROR)
                tty_flag = TTY_PARITY;
-       else if (status & UART_FRAME_ERROR)
+       else if (line_status & UART_FRAME_ERROR)
                tty_flag = TTY_FRAME;
        dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag);
 
@@ -1059,7 +1060,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length + 1);
                /* 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);
                for (i = 0; i < urb->actual_length; ++i)
                        tty_insert_flip_char(tty, data[i], tty_flag);
@@ -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 pl2303_private *priv = usb_get_serial_port_data(port);
        int result;
+       int status = urb->status;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
-       switch (urb->status) {
+       switch (status) {
        case 0:
                /* success */
                break;
@@ -1095,14 +1097,14 @@ static void pl2303_write_bulk_callback(struct urb *urb)
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
                dbg("%s - urb shutting down with status: %d", __FUNCTION__,
-                   urb->status);
+                   status);
                priv->write_urb_in_use = 0;
                return;
        default:
                /* error in the urb, so we have to resubmit it */
                dbg("%s - Overflow in write", __FUNCTION__);
                dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
-                   urb->status);
+                   status);
                port->write_urb->transfer_buffer_length = 1;
                port->write_urb->dev = port->serial->dev;
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);