diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-06-15 18:44:13 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:34:36 -0400 |
commit | 461d696aeeae294ad22dfcaae462d1757f955778 (patch) | |
tree | c2c223bd8a0c1114c636f26bf0ce0f0d67996947 /drivers/usb/serial/pl2303.c | |
parent | 78c26aebd9f4d29f9bd163c7c47f2c89991fcdb1 (diff) |
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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/pl2303.c')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 3022d65bb697..4348c1feab4e 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -961,11 +961,12 @@ static void pl2303_read_int_callback(struct urb *urb) | |||
961 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; | 961 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; |
962 | unsigned char *data = urb->transfer_buffer; | 962 | unsigned char *data = urb->transfer_buffer; |
963 | unsigned int actual_length = urb->actual_length; | 963 | unsigned int actual_length = urb->actual_length; |
964 | int status; | 964 | int status = urb->status; |
965 | int retval; | ||
965 | 966 | ||
966 | dbg("%s (%d)", __FUNCTION__, port->number); | 967 | dbg("%s (%d)", __FUNCTION__, port->number); |
967 | 968 | ||
968 | switch (urb->status) { | 969 | switch (status) { |
969 | case 0: | 970 | case 0: |
970 | /* success */ | 971 | /* success */ |
971 | break; | 972 | break; |
@@ -974,11 +975,11 @@ static void pl2303_read_int_callback(struct urb *urb) | |||
974 | case -ESHUTDOWN: | 975 | case -ESHUTDOWN: |
975 | /* this urb is terminated, clean up */ | 976 | /* this urb is terminated, clean up */ |
976 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, | 977 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, |
977 | urb->status); | 978 | status); |
978 | return; | 979 | return; |
979 | default: | 980 | default: |
980 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, | 981 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, |
981 | urb->status); | 982 | status); |
982 | goto exit; | 983 | goto exit; |
983 | } | 984 | } |
984 | 985 | ||
@@ -988,11 +989,11 @@ static void pl2303_read_int_callback(struct urb *urb) | |||
988 | pl2303_update_line_status(port, data, actual_length); | 989 | pl2303_update_line_status(port, data, actual_length); |
989 | 990 | ||
990 | exit: | 991 | exit: |
991 | status = usb_submit_urb(urb, GFP_ATOMIC); | 992 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
992 | if (status) | 993 | if (retval) |
993 | dev_err(&urb->dev->dev, | 994 | dev_err(&urb->dev->dev, |
994 | "%s - usb_submit_urb failed with result %d\n", | 995 | "%s - usb_submit_urb failed with result %d\n", |
995 | __FUNCTION__, status); | 996 | __FUNCTION__, retval); |
996 | } | 997 | } |
997 | 998 | ||
998 | static void pl2303_read_bulk_callback(struct urb *urb) | 999 | static void pl2303_read_bulk_callback(struct urb *urb) |
@@ -1004,23 +1005,23 @@ static void pl2303_read_bulk_callback(struct urb *urb) | |||
1004 | unsigned long flags; | 1005 | unsigned long flags; |
1005 | int i; | 1006 | int i; |
1006 | int result; | 1007 | int result; |
1007 | u8 status; | 1008 | int status = urb->status; |
1009 | u8 line_status; | ||
1008 | char tty_flag; | 1010 | char tty_flag; |
1009 | 1011 | ||
1010 | dbg("%s - port %d", __FUNCTION__, port->number); | 1012 | dbg("%s - port %d", __FUNCTION__, port->number); |
1011 | 1013 | ||
1012 | if (urb->status) { | 1014 | if (status) { |
1013 | dbg("%s - urb->status = %d", __FUNCTION__, urb->status); | 1015 | dbg("%s - urb status = %d", __FUNCTION__, status); |
1014 | if (!port->open_count) { | 1016 | if (!port->open_count) { |
1015 | dbg("%s - port is closed, exiting.", __FUNCTION__); | 1017 | dbg("%s - port is closed, exiting.", __FUNCTION__); |
1016 | return; | 1018 | return; |
1017 | } | 1019 | } |
1018 | if (urb->status == -EPROTO) { | 1020 | if (status == -EPROTO) { |
1019 | /* PL2303 mysteriously fails with -EPROTO reschedule | 1021 | /* PL2303 mysteriously fails with -EPROTO reschedule |
1020 | * the read */ | 1022 | * the read */ |
1021 | dbg("%s - caught -EPROTO, resubmitting the urb", | 1023 | dbg("%s - caught -EPROTO, resubmitting the urb", |
1022 | __FUNCTION__); | 1024 | __FUNCTION__); |
1023 | urb->status = 0; | ||
1024 | urb->dev = port->serial->dev; | 1025 | urb->dev = port->serial->dev; |
1025 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1026 | result = usb_submit_urb(urb, GFP_ATOMIC); |
1026 | if (result) | 1027 | if (result) |
@@ -1040,18 +1041,18 @@ static void pl2303_read_bulk_callback(struct urb *urb) | |||
1040 | tty_flag = TTY_NORMAL; | 1041 | tty_flag = TTY_NORMAL; |
1041 | 1042 | ||
1042 | spin_lock_irqsave(&priv->lock, flags); | 1043 | spin_lock_irqsave(&priv->lock, flags); |
1043 | status = priv->line_status; | 1044 | line_status = priv->line_status; |
1044 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; | 1045 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; |
1045 | spin_unlock_irqrestore(&priv->lock, flags); | 1046 | spin_unlock_irqrestore(&priv->lock, flags); |
1046 | wake_up_interruptible(&priv->delta_msr_wait); | 1047 | wake_up_interruptible(&priv->delta_msr_wait); |
1047 | 1048 | ||
1048 | /* break takes precedence over parity, */ | 1049 | /* break takes precedence over parity, */ |
1049 | /* which takes precedence over framing errors */ | 1050 | /* which takes precedence over framing errors */ |
1050 | if (status & UART_BREAK_ERROR ) | 1051 | if (line_status & UART_BREAK_ERROR ) |
1051 | tty_flag = TTY_BREAK; | 1052 | tty_flag = TTY_BREAK; |
1052 | else if (status & UART_PARITY_ERROR) | 1053 | else if (line_status & UART_PARITY_ERROR) |
1053 | tty_flag = TTY_PARITY; | 1054 | tty_flag = TTY_PARITY; |
1054 | else if (status & UART_FRAME_ERROR) | 1055 | else if (line_status & UART_FRAME_ERROR) |
1055 | tty_flag = TTY_FRAME; | 1056 | tty_flag = TTY_FRAME; |
1056 | dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); | 1057 | dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag); |
1057 | 1058 | ||
@@ -1059,7 +1060,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) | |||
1059 | if (tty && urb->actual_length) { | 1060 | if (tty && urb->actual_length) { |
1060 | tty_buffer_request_room(tty, urb->actual_length + 1); | 1061 | tty_buffer_request_room(tty, urb->actual_length + 1); |
1061 | /* overrun is special, not associated with a char */ | 1062 | /* overrun is special, not associated with a char */ |
1062 | if (status & UART_OVERRUN_ERROR) | 1063 | if (line_status & UART_OVERRUN_ERROR) |
1063 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | 1064 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
1064 | for (i = 0; i < urb->actual_length; ++i) | 1065 | for (i = 0; i < urb->actual_length; ++i) |
1065 | tty_insert_flip_char(tty, data[i], tty_flag); | 1066 | tty_insert_flip_char(tty, data[i], tty_flag); |
@@ -1083,10 +1084,11 @@ static void pl2303_write_bulk_callback(struct urb *urb) | |||
1083 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; | 1084 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; |
1084 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 1085 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
1085 | int result; | 1086 | int result; |
1087 | int status = urb->status; | ||
1086 | 1088 | ||
1087 | dbg("%s - port %d", __FUNCTION__, port->number); | 1089 | dbg("%s - port %d", __FUNCTION__, port->number); |
1088 | 1090 | ||
1089 | switch (urb->status) { | 1091 | switch (status) { |
1090 | case 0: | 1092 | case 0: |
1091 | /* success */ | 1093 | /* success */ |
1092 | break; | 1094 | break; |
@@ -1095,14 +1097,14 @@ static void pl2303_write_bulk_callback(struct urb *urb) | |||
1095 | case -ESHUTDOWN: | 1097 | case -ESHUTDOWN: |
1096 | /* this urb is terminated, clean up */ | 1098 | /* this urb is terminated, clean up */ |
1097 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, | 1099 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, |
1098 | urb->status); | 1100 | status); |
1099 | priv->write_urb_in_use = 0; | 1101 | priv->write_urb_in_use = 0; |
1100 | return; | 1102 | return; |
1101 | default: | 1103 | default: |
1102 | /* error in the urb, so we have to resubmit it */ | 1104 | /* error in the urb, so we have to resubmit it */ |
1103 | dbg("%s - Overflow in write", __FUNCTION__); | 1105 | dbg("%s - Overflow in write", __FUNCTION__); |
1104 | dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, | 1106 | dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, |
1105 | urb->status); | 1107 | status); |
1106 | port->write_urb->transfer_buffer_length = 1; | 1108 | port->write_urb->transfer_buffer_length = 1; |
1107 | port->write_urb->dev = port->serial->dev; | 1109 | port->write_urb->dev = port->serial->dev; |
1108 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1110 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |