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()
823 void usb_kill_anchored_urbs(struct usb_anchor *anchor) in usb_kill_anchored_urbs() argument
829 spin_lock_irq(&anchor->lock); in usb_kill_anchored_urbs()
830 while (!list_empty(&anchor->urb_list)) { in usb_kill_anchored_urbs()
831 victim = list_entry(anchor->urb_list.prev, in usb_kill_anchored_urbs()
835 spin_unlock_irq(&anchor->lock); in usb_kill_anchored_urbs()
839 spin_lock_irq(&anchor->lock); in usb_kill_anchored_urbs()
841 surely_empty = usb_anchor_check_wakeup(anchor); in usb_kill_anchored_urbs()
843 spin_unlock_irq(&anchor->lock); in usb_kill_anchored_urbs()
861 void usb_poison_anchored_urbs(struct usb_anchor *anchor) in usb_poison_anchored_urbs() argument
867 spin_lock_irq(&anchor->lock); in usb_poison_anchored_urbs()
868 anchor->poisoned = 1; in usb_poison_anchored_urbs()
869 while (!list_empty(&anchor->urb_list)) { in usb_poison_anchored_urbs()
870 victim = list_entry(anchor->urb_list.prev, in usb_poison_anchored_urbs()
874 spin_unlock_irq(&anchor->lock); in usb_poison_anchored_urbs()
878 spin_lock_irq(&anchor->lock); in usb_poison_anchored_urbs()
880 surely_empty = usb_anchor_check_wakeup(anchor); in usb_poison_anchored_urbs()
882 spin_unlock_irq(&anchor->lock); in usb_poison_anchored_urbs()
895 void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) in usb_unpoison_anchored_urbs() argument
900 spin_lock_irqsave(&anchor->lock, flags); in usb_unpoison_anchored_urbs()
901 list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) { in usb_unpoison_anchored_urbs()
904 anchor->poisoned = 0; in usb_unpoison_anchored_urbs()
905 spin_unlock_irqrestore(&anchor->lock, flags); in usb_unpoison_anchored_urbs()
920 void usb_unlink_anchored_urbs(struct usb_anchor *anchor) in usb_unlink_anchored_urbs() argument
924 while ((victim = usb_get_from_anchor(anchor)) != NULL) { in usb_unlink_anchored_urbs()
939 void usb_anchor_suspend_wakeups(struct usb_anchor *anchor) in usb_anchor_suspend_wakeups() argument
941 if (anchor) in usb_anchor_suspend_wakeups()
942 atomic_inc(&anchor->suspend_wakeups); in usb_anchor_suspend_wakeups()
953 void usb_anchor_resume_wakeups(struct usb_anchor *anchor) in usb_anchor_resume_wakeups() argument
955 if (!anchor) in usb_anchor_resume_wakeups()
958 atomic_dec(&anchor->suspend_wakeups); in usb_anchor_resume_wakeups()
959 if (usb_anchor_check_wakeup(anchor)) in usb_anchor_resume_wakeups()
960 wake_up(&anchor->wait); in usb_anchor_resume_wakeups()
974 int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, in usb_wait_anchor_empty_timeout() argument
977 return wait_event_timeout(anchor->wait, in usb_wait_anchor_empty_timeout()
978 usb_anchor_check_wakeup(anchor), in usb_wait_anchor_empty_timeout()
993 struct urb *usb_get_from_anchor(struct usb_anchor *anchor) in usb_get_from_anchor() argument
998 spin_lock_irqsave(&anchor->lock, flags); in usb_get_from_anchor()
999 if (!list_empty(&anchor->urb_list)) { in usb_get_from_anchor()
1000 victim = list_entry(anchor->urb_list.next, struct urb, in usb_get_from_anchor()
1003 __usb_unanchor_urb(victim, anchor); in usb_get_from_anchor()
1007 spin_unlock_irqrestore(&anchor->lock, flags); in usb_get_from_anchor()
1020 void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) in usb_scuttle_anchored_urbs() argument
1027 spin_lock_irqsave(&anchor->lock, flags); in usb_scuttle_anchored_urbs()
1028 while (!list_empty(&anchor->urb_list)) { in usb_scuttle_anchored_urbs()
1029 victim = list_entry(anchor->urb_list.prev, in usb_scuttle_anchored_urbs()
1031 __usb_unanchor_urb(victim, anchor); in usb_scuttle_anchored_urbs()
1033 surely_empty = usb_anchor_check_wakeup(anchor); in usb_scuttle_anchored_urbs()
1035 spin_unlock_irqrestore(&anchor->lock, flags); in usb_scuttle_anchored_urbs()
1048 int usb_anchor_empty(struct usb_anchor *anchor) in usb_anchor_empty() argument
1050 return list_empty(&anchor->urb_list); in usb_anchor_empty()