Lines Matching refs:anchor
127 void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor) in usb_anchor_urb() argument
131 spin_lock_irqsave(&anchor->lock, flags); in usb_anchor_urb()
133 list_add_tail(&urb->anchor_list, &anchor->urb_list); in usb_anchor_urb()
134 urb->anchor = anchor; in usb_anchor_urb()
136 if (unlikely(anchor->poisoned)) in usb_anchor_urb()
139 spin_unlock_irqrestore(&anchor->lock, flags); in usb_anchor_urb()
143 static int usb_anchor_check_wakeup(struct usb_anchor *anchor) in usb_anchor_check_wakeup() argument
145 return atomic_read(&anchor->suspend_wakeups) == 0 && in usb_anchor_check_wakeup()
146 list_empty(&anchor->urb_list); in usb_anchor_check_wakeup()
150 static void __usb_unanchor_urb(struct urb *urb, struct usb_anchor *anchor) in __usb_unanchor_urb() argument
152 urb->anchor = NULL; in __usb_unanchor_urb()
155 if (usb_anchor_check_wakeup(anchor)) in __usb_unanchor_urb()
156 wake_up(&anchor->wait); in __usb_unanchor_urb()
168 struct usb_anchor *anchor; in usb_unanchor_urb() local
173 anchor = urb->anchor; in usb_unanchor_urb()
174 if (!anchor) in usb_unanchor_urb()
177 spin_lock_irqsave(&anchor->lock, flags); in usb_unanchor_urb()
183 if (likely(anchor == urb->anchor)) in usb_unanchor_urb()
184 __usb_unanchor_urb(urb, anchor); in usb_unanchor_urb()
185 spin_unlock_irqrestore(&anchor->lock, flags); in usb_unanchor_urb()
808 void usb_kill_anchored_urbs(struct usb_anchor *anchor) in usb_kill_anchored_urbs() argument
814 spin_lock_irq(&anchor->lock); in usb_kill_anchored_urbs()
815 while (!list_empty(&anchor->urb_list)) { in usb_kill_anchored_urbs()
816 victim = list_entry(anchor->urb_list.prev, in usb_kill_anchored_urbs()
820 spin_unlock_irq(&anchor->lock); in usb_kill_anchored_urbs()
824 spin_lock_irq(&anchor->lock); in usb_kill_anchored_urbs()
826 surely_empty = usb_anchor_check_wakeup(anchor); in usb_kill_anchored_urbs()
828 spin_unlock_irq(&anchor->lock); in usb_kill_anchored_urbs()
846 void usb_poison_anchored_urbs(struct usb_anchor *anchor) in usb_poison_anchored_urbs() argument
852 spin_lock_irq(&anchor->lock); in usb_poison_anchored_urbs()
853 anchor->poisoned = 1; in usb_poison_anchored_urbs()
854 while (!list_empty(&anchor->urb_list)) { in usb_poison_anchored_urbs()
855 victim = list_entry(anchor->urb_list.prev, in usb_poison_anchored_urbs()
859 spin_unlock_irq(&anchor->lock); in usb_poison_anchored_urbs()
863 spin_lock_irq(&anchor->lock); in usb_poison_anchored_urbs()
865 surely_empty = usb_anchor_check_wakeup(anchor); in usb_poison_anchored_urbs()
867 spin_unlock_irq(&anchor->lock); in usb_poison_anchored_urbs()
880 void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) in usb_unpoison_anchored_urbs() argument
885 spin_lock_irqsave(&anchor->lock, flags); in usb_unpoison_anchored_urbs()
886 list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) { in usb_unpoison_anchored_urbs()
889 anchor->poisoned = 0; in usb_unpoison_anchored_urbs()
890 spin_unlock_irqrestore(&anchor->lock, flags); in usb_unpoison_anchored_urbs()
905 void usb_unlink_anchored_urbs(struct usb_anchor *anchor) in usb_unlink_anchored_urbs() argument
909 while ((victim = usb_get_from_anchor(anchor)) != NULL) { in usb_unlink_anchored_urbs()
924 void usb_anchor_suspend_wakeups(struct usb_anchor *anchor) in usb_anchor_suspend_wakeups() argument
926 if (anchor) in usb_anchor_suspend_wakeups()
927 atomic_inc(&anchor->suspend_wakeups); in usb_anchor_suspend_wakeups()
938 void usb_anchor_resume_wakeups(struct usb_anchor *anchor) in usb_anchor_resume_wakeups() argument
940 if (!anchor) in usb_anchor_resume_wakeups()
943 atomic_dec(&anchor->suspend_wakeups); in usb_anchor_resume_wakeups()
944 if (usb_anchor_check_wakeup(anchor)) in usb_anchor_resume_wakeups()
945 wake_up(&anchor->wait); in usb_anchor_resume_wakeups()
959 int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, in usb_wait_anchor_empty_timeout() argument
962 return wait_event_timeout(anchor->wait, in usb_wait_anchor_empty_timeout()
963 usb_anchor_check_wakeup(anchor), in usb_wait_anchor_empty_timeout()
978 struct urb *usb_get_from_anchor(struct usb_anchor *anchor) in usb_get_from_anchor() argument
983 spin_lock_irqsave(&anchor->lock, flags); in usb_get_from_anchor()
984 if (!list_empty(&anchor->urb_list)) { in usb_get_from_anchor()
985 victim = list_entry(anchor->urb_list.next, struct urb, in usb_get_from_anchor()
988 __usb_unanchor_urb(victim, anchor); in usb_get_from_anchor()
992 spin_unlock_irqrestore(&anchor->lock, flags); in usb_get_from_anchor()
1005 void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) in usb_scuttle_anchored_urbs() argument
1012 spin_lock_irqsave(&anchor->lock, flags); in usb_scuttle_anchored_urbs()
1013 while (!list_empty(&anchor->urb_list)) { in usb_scuttle_anchored_urbs()
1014 victim = list_entry(anchor->urb_list.prev, in usb_scuttle_anchored_urbs()
1016 __usb_unanchor_urb(victim, anchor); in usb_scuttle_anchored_urbs()
1018 surely_empty = usb_anchor_check_wakeup(anchor); in usb_scuttle_anchored_urbs()
1020 spin_unlock_irqrestore(&anchor->lock, flags); in usb_scuttle_anchored_urbs()
1033 int usb_anchor_empty(struct usb_anchor *anchor) in usb_anchor_empty() argument
1035 return list_empty(&anchor->urb_list); in usb_anchor_empty()