diff options
author | Oliver Neukum <oliver@neukum.org> | 2008-04-10 08:07:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:50 -0400 |
commit | eda769593bbae8aee4e336b0732f6016353301a3 (patch) | |
tree | 04b5aae8d2cf133b86527b56505c26841b9f45f8 | |
parent | 9424ea29658ce5bcdcf527ddf9617b9507ddf1aa (diff) |
USB: add extension of anchor API, usb_unlink_anchored_urbs
This adds the ability to trigger asynchronous unlinks of anchored URBs. This
is needed for error handling in the comntext of completion handlers, which
cannot sleep.
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/urb.c | 24 | ||||
-rw-r--r-- | include/linux/usb.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 9d7e63292c01..1d3ed1322fbe 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -590,6 +590,30 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor) | |||
590 | EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); | 590 | EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); |
591 | 591 | ||
592 | /** | 592 | /** |
593 | * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse | ||
594 | * @anchor: anchor the requests are bound to | ||
595 | * | ||
596 | * this allows all outstanding URBs to be unlinked starting | ||
597 | * from the back of the queue. This function is asynchronous. | ||
598 | * The unlinking is just tiggered. It may happen after this | ||
599 | * function has returned. | ||
600 | */ | ||
601 | void usb_unlink_anchored_urbs(struct usb_anchor *anchor) | ||
602 | { | ||
603 | struct urb *victim; | ||
604 | |||
605 | spin_lock_irq(&anchor->lock); | ||
606 | while (!list_empty(&anchor->urb_list)) { | ||
607 | victim = list_entry(anchor->urb_list.prev, struct urb, | ||
608 | anchor_list); | ||
609 | /* this will unanchor the URB */ | ||
610 | usb_unlink_urb(victim); | ||
611 | } | ||
612 | spin_unlock_irq(&anchor->lock); | ||
613 | } | ||
614 | EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); | ||
615 | |||
616 | /** | ||
593 | * usb_wait_anchor_empty_timeout - wait for an anchor to be unused | 617 | * usb_wait_anchor_empty_timeout - wait for an anchor to be unused |
594 | * @anchor: the anchor you want to become unused | 618 | * @anchor: the anchor you want to become unused |
595 | * @timeout: how long you are willing to wait in milliseconds | 619 | * @timeout: how long you are willing to wait in milliseconds |
diff --git a/include/linux/usb.h b/include/linux/usb.h index dd9733cc0ac2..52c449e4bdcd 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -1451,6 +1451,7 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); | |||
1451 | extern int usb_unlink_urb(struct urb *urb); | 1451 | extern int usb_unlink_urb(struct urb *urb); |
1452 | extern void usb_kill_urb(struct urb *urb); | 1452 | extern void usb_kill_urb(struct urb *urb); |
1453 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); | 1453 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); |
1454 | extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); | ||
1454 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); | 1455 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); |
1455 | extern void usb_unanchor_urb(struct urb *urb); | 1456 | extern void usb_unanchor_urb(struct urb *urb); |
1456 | extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | 1457 | extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, |