full autosuspend for btusb
Subsystems (2)
RFC 1/1 full autosuspend for btusb
Hi,
in the great tradition of totally untested patches here's a version that should do ultraaggressive runtime powersave. In all likelihood it doesn't work. I'll test it, but only tomorrow.
Regards
Oliver
----
drivers/usb/core/urb.c renamed from drivers/usb/core/urb.c.alt3 +44 -0
@@ -633,3 +633,47 @@ int usb_wait_anchor_empty_timeout(struct msecs_to_jiffies(timeout)); }EXPORT_SYMBOL_GPL (usb_wait_anchor_empty_timeout); + +struct urb *usb_get_from_anchor (struct usb_anchor *anchor) +{ +struct urb *victim; +unsigned long flags; + +spin_lock_irqsave (&anchor->lock, flags); +if (!list_empty (&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.next, struct urb, + anchor_list); +usb_get_urb (victim); +spin_unlock_irqrestore (&anchor->lock, flags); +usb_unanchor_urb (victim); + }else { +spin_unlock_irqrestore (&anchor->lock, flags); + victim =NULL ; + } + +return victim; +} + +EXPORT_SYMBOL_GPL (usb_get_from_anchor); + +void usb_scuttle_anchored_urbs (struct usb_anchor *anchor) +{ +struct urb *victim; +unsigned long flags; + +spin_lock_irqsave (&anchor->lock, flags); +while (!list_empty (&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); +usb_get_urb (victim); +spin_unlock_irqrestore (&anchor->lock, flags); +/* this will unanchor the URB */ +usb_unanchor_urb (victim); +usb_put_urb (victim); +spin_lock_irqsave (&anchor->lock, flags); + } +spin_unlock_irqrestore (&anchor->lock, flags); +} + +EXPORT_SYMBOL_GPL (usb_scuttle_anchored_urbs); +
include/linux/usb.h renamed from include/linux/usb.h.alt +2 -0
@@ -1460,6 +1460,8 @@ extern void usb_anchor_urb(struct urb *uextern void usb_unanchor_urb (struct urb *urb);extern int usb_wait_anchor_empty_timeout (struct usb_anchor *anchor,unsigned int timeout); +extern struct urb *usb_get_from_anchor (struct usb_anchor *anchor); +extern void usb_scuttle_anchored_urbs (struct usb_anchor *anchor);/** * usb_urb_dir_in - check if an URB describes an IN transfer
drivers/bluetooth/btusb.c renamed from drivers/bluetooth/btusb.c.alt2 +203 -20
422 lines not on this page · raw message