diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/usb/storage/transport.c | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 7ca896a342e3..038f4582ca0b 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
| @@ -115,19 +115,6 @@ static void usb_stor_blocking_completion(struct urb *urb, struct pt_regs *regs) | |||
| 115 | 115 | ||
| 116 | complete(urb_done_ptr); | 116 | complete(urb_done_ptr); |
| 117 | } | 117 | } |
| 118 | |||
| 119 | /* This is the timeout handler which will cancel an URB when its timeout | ||
| 120 | * expires. | ||
| 121 | */ | ||
| 122 | static void timeout_handler(unsigned long us_) | ||
| 123 | { | ||
| 124 | struct us_data *us = (struct us_data *) us_; | ||
| 125 | |||
| 126 | if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->flags)) { | ||
| 127 | US_DEBUGP("Timeout -- cancelling URB\n"); | ||
| 128 | usb_unlink_urb(us->current_urb); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | 118 | ||
| 132 | /* This is the common part of the URB message submission code | 119 | /* This is the common part of the URB message submission code |
| 133 | * | 120 | * |
| @@ -138,7 +125,7 @@ static void timeout_handler(unsigned long us_) | |||
| 138 | static int usb_stor_msg_common(struct us_data *us, int timeout) | 125 | static int usb_stor_msg_common(struct us_data *us, int timeout) |
| 139 | { | 126 | { |
| 140 | struct completion urb_done; | 127 | struct completion urb_done; |
| 141 | struct timer_list to_timer; | 128 | long timeleft; |
| 142 | int status; | 129 | int status; |
| 143 | 130 | ||
| 144 | /* don't submit URBs during abort/disconnect processing */ | 131 | /* don't submit URBs during abort/disconnect processing */ |
| @@ -185,22 +172,17 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) | |||
| 185 | } | 172 | } |
| 186 | } | 173 | } |
| 187 | 174 | ||
| 188 | /* submit the timeout timer, if a timeout was requested */ | ||
| 189 | if (timeout > 0) { | ||
| 190 | init_timer(&to_timer); | ||
| 191 | to_timer.expires = jiffies + timeout; | ||
| 192 | to_timer.function = timeout_handler; | ||
| 193 | to_timer.data = (unsigned long) us; | ||
| 194 | add_timer(&to_timer); | ||
| 195 | } | ||
| 196 | |||
| 197 | /* wait for the completion of the URB */ | 175 | /* wait for the completion of the URB */ |
| 198 | wait_for_completion(&urb_done); | 176 | timeleft = wait_for_completion_interruptible_timeout( |
| 199 | clear_bit(US_FLIDX_URB_ACTIVE, &us->flags); | 177 | &urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT); |
| 200 | 178 | ||
| 201 | /* clean up the timeout timer */ | 179 | clear_bit(US_FLIDX_URB_ACTIVE, &us->flags); |
| 202 | if (timeout > 0) | 180 | |
| 203 | del_timer_sync(&to_timer); | 181 | if (timeleft <= 0) { |
| 182 | US_DEBUGP("%s -- cancelling URB\n", | ||
| 183 | timeleft == 0 ? "Timeout" : "Signal"); | ||
| 184 | usb_unlink_urb(us->current_urb); | ||
| 185 | } | ||
| 204 | 186 | ||
| 205 | /* return the URB status */ | 187 | /* return the URB status */ |
| 206 | return us->current_urb->status; | 188 | return us->current_urb->status; |
