Skip to content

Commit

Permalink
[Bluetooth] Add suspend/resume support to the HCI USB driver
Browse files Browse the repository at this point in the history
This patch implements the suspend/resume methods for the HCI USB
driver by killing all outstanding URBs on suspend, and re-issuing
them on resume.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Marcel Holtmann authored and David S. Miller committed Jul 4, 2006
1 parent 2b86ad2 commit dcdcf63
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions drivers/bluetooth/hci_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,81 @@ static void hci_usb_disconnect(struct usb_interface *intf)
hci_free_dev(hdev);
}

static int hci_usb_suspend(struct usb_interface *intf, pm_message_t message)
{
struct hci_usb *husb = usb_get_intfdata(intf);
struct list_head killed;
unsigned long flags;
int i;

if (!husb || intf == husb->isoc_iface)
return 0;

hci_suspend_dev(husb->hdev);

INIT_LIST_HEAD(&killed);

for (i = 0; i < 4; i++) {
struct _urb_queue *q = &husb->pending_q[i];
struct _urb *_urb, *_tmp;

while ((_urb = _urb_dequeue(q))) {
/* reset queue since _urb_dequeue sets it to NULL */
_urb->queue = q;
usb_kill_urb(&_urb->urb);
list_add(&_urb->list, &killed);
}

spin_lock_irqsave(&q->lock, flags);

list_for_each_entry_safe(_urb, _tmp, &killed, list) {
list_move_tail(&_urb->list, &q->head);
}

spin_unlock_irqrestore(&q->lock, flags);
}

return 0;
}

static int hci_usb_resume(struct usb_interface *intf)
{
struct hci_usb *husb = usb_get_intfdata(intf);
unsigned long flags;
int i, err = 0;

if (!husb || intf == husb->isoc_iface)
return 0;

for (i = 0; i < 4; i++) {
struct _urb_queue *q = &husb->pending_q[i];
struct _urb *_urb;

spin_lock_irqsave(&q->lock, flags);

list_for_each_entry(_urb, &q->head, list) {
err = usb_submit_urb(&_urb->urb, GFP_ATOMIC);
if (err)
break;
}

spin_unlock_irqrestore(&q->lock, flags);

if (err)
return -EIO;
}

hci_resume_dev(husb->hdev);

return 0;
}

static struct usb_driver hci_usb_driver = {
.name = "hci_usb",
.probe = hci_usb_probe,
.disconnect = hci_usb_disconnect,
.suspend = hci_usb_suspend,
.resume = hci_usb_resume,
.id_table = bluetooth_ids,
};

Expand Down

0 comments on commit dcdcf63

Please sign in to comment.