mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 19:06:14 +00:00
[PATCH] usb-storage: get rid of the timer during URB submission
This patch uses completion timeout instead of a timer to implement a timeout when submitting an URB. It also put the task in interruptible state instead of an uninterruptible one while waiting for the completion. Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com> Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
80b47853b1
commit
3428cc43d2
1 changed files with 10 additions and 28 deletions
|
@ -115,19 +115,6 @@ static void usb_stor_blocking_completion(struct urb *urb, struct pt_regs *regs)
|
||||||
|
|
||||||
complete(urb_done_ptr);
|
complete(urb_done_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is the timeout handler which will cancel an URB when its timeout
|
|
||||||
* expires.
|
|
||||||
*/
|
|
||||||
static void timeout_handler(unsigned long us_)
|
|
||||||
{
|
|
||||||
struct us_data *us = (struct us_data *) us_;
|
|
||||||
|
|
||||||
if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->flags)) {
|
|
||||||
US_DEBUGP("Timeout -- cancelling URB\n");
|
|
||||||
usb_unlink_urb(us->current_urb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is the common part of the URB message submission code
|
/* This is the common part of the URB message submission code
|
||||||
*
|
*
|
||||||
|
@ -138,7 +125,7 @@ static void timeout_handler(unsigned long us_)
|
||||||
static int usb_stor_msg_common(struct us_data *us, int timeout)
|
static int usb_stor_msg_common(struct us_data *us, int timeout)
|
||||||
{
|
{
|
||||||
struct completion urb_done;
|
struct completion urb_done;
|
||||||
struct timer_list to_timer;
|
long timeleft;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
/* don't submit URBs during abort/disconnect processing */
|
/* don't submit URBs during abort/disconnect processing */
|
||||||
|
@ -185,22 +172,17 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* submit the timeout timer, if a timeout was requested */
|
|
||||||
if (timeout > 0) {
|
|
||||||
init_timer(&to_timer);
|
|
||||||
to_timer.expires = jiffies + timeout;
|
|
||||||
to_timer.function = timeout_handler;
|
|
||||||
to_timer.data = (unsigned long) us;
|
|
||||||
add_timer(&to_timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wait for the completion of the URB */
|
/* wait for the completion of the URB */
|
||||||
wait_for_completion(&urb_done);
|
timeleft = wait_for_completion_interruptible_timeout(
|
||||||
clear_bit(US_FLIDX_URB_ACTIVE, &us->flags);
|
&urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT);
|
||||||
|
|
||||||
/* clean up the timeout timer */
|
clear_bit(US_FLIDX_URB_ACTIVE, &us->flags);
|
||||||
if (timeout > 0)
|
|
||||||
del_timer_sync(&to_timer);
|
if (timeleft <= 0) {
|
||||||
|
US_DEBUGP("%s -- cancelling URB\n",
|
||||||
|
timeleft == 0 ? "Timeout" : "Signal");
|
||||||
|
usb_unlink_urb(us->current_urb);
|
||||||
|
}
|
||||||
|
|
||||||
/* return the URB status */
|
/* return the URB status */
|
||||||
return us->current_urb->status;
|
return us->current_urb->status;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue