4 * This driver supports USB CDC WCM Device Management.
6 * Copyright (c) 2007-2009 Oliver Neukum
8 * Some code taken from cdc-acm.c
10 * Released under the GPLv2.
12 * Many thanks to Carl Nordbeck
14 #include <linux/kernel.h>
15 #include <linux/errno.h>
16 #include <linux/slab.h>
17 #include <linux/module.h>
18 #include <linux/mutex.h>
19 #include <linux/uaccess.h>
20 #include <linux/bitops.h>
21 #include <linux/poll.h>
22 #include <linux/usb.h>
23 #include <linux/usb/cdc.h>
24 #include <asm/byteorder.h>
25 #include <asm/unaligned.h>
26 #include <linux/usb/cdc-wdm.h>
31 #define DRIVER_VERSION "v0.03"
32 #define DRIVER_AUTHOR "Oliver Neukum"
33 #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management"
35 static const struct usb_device_id wdm_ids[] = {
37 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
38 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
39 .bInterfaceClass = USB_CLASS_COMM,
40 .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM
45 MODULE_DEVICE_TABLE (usb, wdm_ids);
47 #define WDM_MINOR_BASE 176
51 #define WDM_DISCONNECTING 2
54 #define WDM_INT_STALL 5
55 #define WDM_POLL_RUNNING 6
56 #define WDM_RESPONDING 7
57 #define WDM_SUSPENDING 8
58 #define WDM_RESETTING 9
62 /* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
63 #define WDM_DEFAULT_BUFSIZE 256
65 static DEFINE_MUTEX(wdm_mutex);
66 static DEFINE_SPINLOCK(wdm_device_list_lock);
67 static LIST_HEAD(wdm_device_list);
69 /* --- method tables --- */
72 u8 *inbuf; /* buffer for response */
73 u8 *outbuf; /* buffer for command */
74 u8 *sbuf; /* buffer for status */
75 u8 *ubuf; /* buffer for copy to user space */
80 struct usb_interface *intf;
81 struct usb_ctrlrequest *orq;
82 struct usb_ctrlrequest *irq;
98 wait_queue_head_t wait;
99 struct work_struct rxwork;
103 struct list_head device_list;
104 int (*manage_power)(struct usb_interface *, int);
107 static struct usb_driver wdm_driver;
109 /* return intfdata if we own the interface, else look up intf in the list */
110 static struct wdm_device *wdm_find_device(struct usb_interface *intf)
112 struct wdm_device *desc = NULL;
114 spin_lock(&wdm_device_list_lock);
115 list_for_each_entry(desc, &wdm_device_list, device_list)
116 if (desc->intf == intf)
118 spin_unlock(&wdm_device_list_lock);
123 static struct wdm_device *wdm_find_device_by_minor(int minor)
125 struct wdm_device *desc = NULL;
127 spin_lock(&wdm_device_list_lock);
128 list_for_each_entry(desc, &wdm_device_list, device_list)
129 if (desc->intf->minor == minor)
131 spin_unlock(&wdm_device_list_lock);
136 /* --- callbacks --- */
137 static void wdm_out_callback(struct urb *urb)
139 struct wdm_device *desc;
141 spin_lock(&desc->iuspin);
142 desc->werr = urb->status;
143 spin_unlock(&desc->iuspin);
146 clear_bit(WDM_IN_USE, &desc->flags);
147 wake_up(&desc->wait);
150 static void wdm_in_callback(struct urb *urb)
152 struct wdm_device *desc = urb->context;
153 int status = urb->status;
155 spin_lock(&desc->iuspin);
156 clear_bit(WDM_RESPONDING, &desc->flags);
161 dev_dbg(&desc->intf->dev,
162 "nonzero urb status received: -ENOENT");
165 dev_dbg(&desc->intf->dev,
166 "nonzero urb status received: -ECONNRESET");
169 dev_dbg(&desc->intf->dev,
170 "nonzero urb status received: -ESHUTDOWN");
173 dev_err(&desc->intf->dev,
174 "nonzero urb status received: -EPIPE\n");
177 dev_err(&desc->intf->dev,
178 "Unexpected error %d\n", status);
184 desc->reslength = urb->actual_length;
185 memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
186 desc->length += desc->reslength;
188 wake_up(&desc->wait);
190 set_bit(WDM_READ, &desc->flags);
191 spin_unlock(&desc->iuspin);
194 static void wdm_int_callback(struct urb *urb)
197 int status = urb->status;
198 struct wdm_device *desc;
199 struct usb_cdc_notification *dr;
202 dr = (struct usb_cdc_notification *)desc->sbuf;
211 set_bit(WDM_INT_STALL, &desc->flags);
212 dev_err(&desc->intf->dev, "Stall on int endpoint\n");
213 goto sw; /* halt is cleared in work */
215 dev_err(&desc->intf->dev,
216 "nonzero urb status received: %d\n", status);
221 if (urb->actual_length < sizeof(struct usb_cdc_notification)) {
222 dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n",
227 switch (dr->bNotificationType) {
228 case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
229 dev_dbg(&desc->intf->dev,
230 "NOTIFY_RESPONSE_AVAILABLE received: index %d len %d",
231 dr->wIndex, dr->wLength);
234 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
236 dev_dbg(&desc->intf->dev,
237 "NOTIFY_NETWORK_CONNECTION %s network",
238 dr->wValue ? "connected to" : "disconnected from");
241 clear_bit(WDM_POLL_RUNNING, &desc->flags);
242 dev_err(&desc->intf->dev,
243 "unknown notification %d received: index %d len %d\n",
244 dr->bNotificationType, dr->wIndex, dr->wLength);
248 spin_lock(&desc->iuspin);
249 clear_bit(WDM_READ, &desc->flags);
250 set_bit(WDM_RESPONDING, &desc->flags);
251 if (!test_bit(WDM_DISCONNECTING, &desc->flags)
252 && !test_bit(WDM_SUSPENDING, &desc->flags)) {
253 rv = usb_submit_urb(desc->response, GFP_ATOMIC);
254 dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
257 spin_unlock(&desc->iuspin);
259 clear_bit(WDM_RESPONDING, &desc->flags);
264 rv = schedule_work(&desc->rxwork);
266 dev_err(&desc->intf->dev,
267 "Cannot schedule work\n");
271 rv = usb_submit_urb(urb, GFP_ATOMIC);
273 dev_err(&desc->intf->dev,
274 "%s - usb_submit_urb failed with result %d\n",
279 static void kill_urbs(struct wdm_device *desc)
281 /* the order here is essential */
282 usb_kill_urb(desc->command);
283 usb_kill_urb(desc->validity);
284 usb_kill_urb(desc->response);
287 static void free_urbs(struct wdm_device *desc)
289 usb_free_urb(desc->validity);
290 usb_free_urb(desc->response);
291 usb_free_urb(desc->command);
294 static void cleanup(struct wdm_device *desc)
305 static ssize_t wdm_write
306 (struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
309 int rv = -EMSGSIZE, r, we;
310 struct wdm_device *desc = file->private_data;
311 struct usb_ctrlrequest *req;
313 if (count > desc->wMaxCommand)
314 count = desc->wMaxCommand;
316 spin_lock_irq(&desc->iuspin);
319 spin_unlock_irq(&desc->iuspin);
323 buf = kmalloc(count, GFP_KERNEL);
329 r = copy_from_user(buf, buffer, count);
336 /* concurrent writes and disconnect */
337 r = mutex_lock_interruptible(&desc->wlock);
344 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
350 r = usb_autopm_get_interface(desc->intf);
353 rv = usb_translate_errors(r);
357 if (!(file->f_flags & O_NONBLOCK))
358 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
361 if (test_bit(WDM_IN_USE, &desc->flags))
364 if (test_bit(WDM_RESETTING, &desc->flags))
374 usb_fill_control_urb(
376 interface_to_usbdev(desc->intf),
377 /* using common endpoint 0 */
378 usb_sndctrlpipe(interface_to_usbdev(desc->intf), 0),
379 (unsigned char *)req,
386 req->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS |
387 USB_RECIP_INTERFACE);
388 req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;
390 req->wIndex = desc->inum;
391 req->wLength = cpu_to_le16(count);
392 set_bit(WDM_IN_USE, &desc->flags);
395 rv = usb_submit_urb(desc->command, GFP_KERNEL);
399 clear_bit(WDM_IN_USE, &desc->flags);
400 dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
401 rv = usb_translate_errors(rv);
403 dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
407 usb_autopm_put_interface(desc->intf);
409 mutex_unlock(&desc->wlock);
411 return rv < 0 ? rv : count;
414 static ssize_t wdm_read
415 (struct file *file, char __user *buffer, size_t count, loff_t *ppos)
419 struct wdm_device *desc = file->private_data;
422 rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
426 cntr = ACCESS_ONCE(desc->length);
430 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
435 if (file->f_flags & O_NONBLOCK) {
436 if (!test_bit(WDM_READ, &desc->flags)) {
437 rv = cntr ? cntr : -EAGAIN;
442 rv = wait_event_interruptible(desc->wait,
443 test_bit(WDM_READ, &desc->flags));
446 /* may have happened while we slept */
447 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
451 if (test_bit(WDM_RESETTING, &desc->flags)) {
455 usb_mark_last_busy(interface_to_usbdev(desc->intf));
461 spin_lock_irq(&desc->iuspin);
463 if (desc->rerr) { /* read completed, error happened */
465 spin_unlock_irq(&desc->iuspin);
470 * recheck whether we've lost the race
471 * against the completion handler
473 if (!test_bit(WDM_READ, &desc->flags)) { /* lost race */
474 spin_unlock_irq(&desc->iuspin);
477 if (!desc->reslength) { /* zero length read */
478 dev_dbg(&desc->intf->dev, "%s: zero length - clearing WDM_READ\n", __func__);
479 clear_bit(WDM_READ, &desc->flags);
480 spin_unlock_irq(&desc->iuspin);
484 spin_unlock_irq(&desc->iuspin);
489 rv = copy_to_user(buffer, desc->ubuf, cntr);
495 spin_lock_irq(&desc->iuspin);
497 for (i = 0; i < desc->length - cntr; i++)
498 desc->ubuf[i] = desc->ubuf[i + cntr];
500 desc->length -= cntr;
501 /* in case we had outstanding data */
503 clear_bit(WDM_READ, &desc->flags);
505 spin_unlock_irq(&desc->iuspin);
510 mutex_unlock(&desc->rlock);
514 static int wdm_flush(struct file *file, fl_owner_t id)
516 struct wdm_device *desc = file->private_data;
518 wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
520 /* cannot dereference desc->intf if WDM_DISCONNECTING */
521 if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
522 dev_err(&desc->intf->dev, "Error in flush path: %d\n",
525 return usb_translate_errors(desc->werr);
528 static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
530 struct wdm_device *desc = file->private_data;
532 unsigned int mask = 0;
534 spin_lock_irqsave(&desc->iuspin, flags);
535 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
536 mask = POLLHUP | POLLERR;
537 spin_unlock_irqrestore(&desc->iuspin, flags);
540 if (test_bit(WDM_READ, &desc->flags))
541 mask = POLLIN | POLLRDNORM;
542 if (desc->rerr || desc->werr)
544 if (!test_bit(WDM_IN_USE, &desc->flags))
545 mask |= POLLOUT | POLLWRNORM;
546 spin_unlock_irqrestore(&desc->iuspin, flags);
548 poll_wait(file, &desc->wait, wait);
554 static int wdm_open(struct inode *inode, struct file *file)
556 int minor = iminor(inode);
558 struct usb_interface *intf;
559 struct wdm_device *desc;
561 mutex_lock(&wdm_mutex);
562 desc = wdm_find_device_by_minor(minor);
567 if (test_bit(WDM_DISCONNECTING, &desc->flags))
569 file->private_data = desc;
571 rv = usb_autopm_get_interface(desc->intf);
573 dev_err(&desc->intf->dev, "Error autopm - %d\n", rv);
577 /* using write lock to protect desc->count */
578 mutex_lock(&desc->wlock);
579 if (!desc->count++) {
582 rv = usb_submit_urb(desc->validity, GFP_KERNEL);
585 dev_err(&desc->intf->dev,
586 "Error submitting int urb - %d\n", rv);
587 rv = usb_translate_errors(rv);
592 mutex_unlock(&desc->wlock);
593 if (desc->count == 1)
594 desc->manage_power(intf, 1);
595 usb_autopm_put_interface(desc->intf);
597 mutex_unlock(&wdm_mutex);
601 static int wdm_release(struct inode *inode, struct file *file)
603 struct wdm_device *desc = file->private_data;
605 mutex_lock(&wdm_mutex);
607 /* using write lock to protect desc->count */
608 mutex_lock(&desc->wlock);
610 mutex_unlock(&desc->wlock);
613 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
614 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
616 desc->manage_power(desc->intf, 0);
618 /* must avoid dev_printk here as desc->intf is invalid */
619 pr_debug(KBUILD_MODNAME " %s: device gone - cleaning up\n", __func__);
623 mutex_unlock(&wdm_mutex);
627 static const struct file_operations wdm_fops = {
628 .owner = THIS_MODULE,
633 .release = wdm_release,
635 .llseek = noop_llseek,
638 static struct usb_class_driver wdm_class = {
641 .minor_base = WDM_MINOR_BASE,
644 /* --- error handling --- */
645 static void wdm_rxwork(struct work_struct *work)
647 struct wdm_device *desc = container_of(work, struct wdm_device, rxwork);
651 spin_lock_irqsave(&desc->iuspin, flags);
652 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
653 spin_unlock_irqrestore(&desc->iuspin, flags);
655 spin_unlock_irqrestore(&desc->iuspin, flags);
656 rv = usb_submit_urb(desc->response, GFP_KERNEL);
657 if (rv < 0 && rv != -EPERM) {
658 spin_lock_irqsave(&desc->iuspin, flags);
659 if (!test_bit(WDM_DISCONNECTING, &desc->flags))
660 schedule_work(&desc->rxwork);
661 spin_unlock_irqrestore(&desc->iuspin, flags);
666 /* --- hotplug --- */
668 static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor *ep,
669 u16 bufsize, int (*manage_power)(struct usb_interface *, int))
672 struct wdm_device *desc;
674 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
677 INIT_LIST_HEAD(&desc->device_list);
678 mutex_init(&desc->rlock);
679 mutex_init(&desc->wlock);
680 spin_lock_init(&desc->iuspin);
681 init_waitqueue_head(&desc->wait);
682 desc->wMaxCommand = bufsize;
683 /* this will be expanded and needed in hardware endianness */
684 desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber);
686 INIT_WORK(&desc->rxwork, wdm_rxwork);
689 if (!usb_endpoint_is_int_in(ep))
692 desc->wMaxPacketSize = usb_endpoint_maxp(ep);
694 desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
697 desc->irq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
701 desc->validity = usb_alloc_urb(0, GFP_KERNEL);
705 desc->response = usb_alloc_urb(0, GFP_KERNEL);
709 desc->command = usb_alloc_urb(0, GFP_KERNEL);
713 desc->ubuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
717 desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL);
721 desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
727 interface_to_usbdev(intf),
728 usb_rcvintpipe(interface_to_usbdev(intf), ep->bEndpointAddress),
730 desc->wMaxPacketSize,
736 desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
737 desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE;
738 desc->irq->wValue = 0;
739 desc->irq->wIndex = desc->inum;
740 desc->irq->wLength = cpu_to_le16(desc->wMaxCommand);
742 usb_fill_control_urb(
744 interface_to_usbdev(intf),
745 /* using common endpoint 0 */
746 usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0),
747 (unsigned char *)desc->irq,
754 desc->manage_power = manage_power;
756 spin_lock(&wdm_device_list_lock);
757 list_add(&desc->device_list, &wdm_device_list);
758 spin_unlock(&wdm_device_list_lock);
760 rv = usb_register_dev(intf, &wdm_class);
764 dev_info(&intf->dev, "%s: USB WDM device\n", dev_name(intf->usb_dev));
768 spin_lock(&wdm_device_list_lock);
769 list_del(&desc->device_list);
770 spin_unlock(&wdm_device_list_lock);
775 static int wdm_manage_power(struct usb_interface *intf, int on)
777 /* need autopm_get/put here to ensure the usbcore sees the new value */
778 int rv = usb_autopm_get_interface(intf);
782 intf->needs_remote_wakeup = on;
783 usb_autopm_put_interface(intf);
788 static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
791 struct usb_host_interface *iface;
792 struct usb_endpoint_descriptor *ep;
793 struct usb_cdc_dmm_desc *dmhd;
794 u8 *buffer = intf->altsetting->extra;
795 int buflen = intf->altsetting->extralen;
796 u16 maxcom = WDM_DEFAULT_BUFSIZE;
801 if (buffer[1] != USB_DT_CS_INTERFACE) {
802 dev_err(&intf->dev, "skipping garbage\n");
807 case USB_CDC_HEADER_TYPE:
809 case USB_CDC_DMM_TYPE:
810 dmhd = (struct usb_cdc_dmm_desc *)buffer;
811 maxcom = le16_to_cpu(dmhd->wMaxCommand);
813 "Finding maximum buffer length: %d", maxcom);
817 "Ignoring extra header, type %d, length %d\n",
818 buffer[2], buffer[0]);
826 iface = intf->cur_altsetting;
827 if (iface->desc.bNumEndpoints != 1)
829 ep = &iface->endpoint[0].desc;
831 rv = wdm_create(intf, ep, maxcom, &wdm_manage_power);
838 * usb_cdc_wdm_register - register a WDM subdriver
839 * @intf: usb interface the subdriver will associate with
840 * @ep: interrupt endpoint to monitor for notifications
841 * @bufsize: maximum message size to support for read/write
843 * Create WDM usb class character device and associate it with intf
844 * without binding, allowing another driver to manage the interface.
846 * The subdriver will manage the given interrupt endpoint exclusively
847 * and will issue control requests referring to the given intf. It
848 * will otherwise avoid interferring, and in particular not do
849 * usb_set_intfdata/usb_get_intfdata on intf.
851 * The return value is a pointer to the subdriver's struct usb_driver.
852 * The registering driver is responsible for calling this subdriver's
853 * disconnect, suspend, resume, pre_reset and post_reset methods from
856 struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf,
857 struct usb_endpoint_descriptor *ep,
859 int (*manage_power)(struct usb_interface *, int))
863 rv = wdm_create(intf, ep, bufsize, manage_power);
871 EXPORT_SYMBOL(usb_cdc_wdm_register);
873 static void wdm_disconnect(struct usb_interface *intf)
875 struct wdm_device *desc;
878 usb_deregister_dev(intf, &wdm_class);
879 desc = wdm_find_device(intf);
880 mutex_lock(&wdm_mutex);
882 /* the spinlock makes sure no new urbs are generated in the callbacks */
883 spin_lock_irqsave(&desc->iuspin, flags);
884 set_bit(WDM_DISCONNECTING, &desc->flags);
885 set_bit(WDM_READ, &desc->flags);
886 /* to terminate pending flushes */
887 clear_bit(WDM_IN_USE, &desc->flags);
888 spin_unlock_irqrestore(&desc->iuspin, flags);
889 wake_up_all(&desc->wait);
890 mutex_lock(&desc->rlock);
891 mutex_lock(&desc->wlock);
893 cancel_work_sync(&desc->rxwork);
894 mutex_unlock(&desc->wlock);
895 mutex_unlock(&desc->rlock);
897 /* the desc->intf pointer used as list key is now invalid */
898 spin_lock(&wdm_device_list_lock);
899 list_del(&desc->device_list);
900 spin_unlock(&wdm_device_list_lock);
905 dev_dbg(&intf->dev, "%s: %d open files - postponing cleanup\n", __func__, desc->count);
906 mutex_unlock(&wdm_mutex);
910 static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
912 struct wdm_device *desc = wdm_find_device(intf);
915 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
917 /* if this is an autosuspend the caller does the locking */
918 if (!PMSG_IS_AUTO(message)) {
919 mutex_lock(&desc->rlock);
920 mutex_lock(&desc->wlock);
922 spin_lock_irq(&desc->iuspin);
924 if (PMSG_IS_AUTO(message) &&
925 (test_bit(WDM_IN_USE, &desc->flags)
926 || test_bit(WDM_RESPONDING, &desc->flags))) {
927 spin_unlock_irq(&desc->iuspin);
931 set_bit(WDM_SUSPENDING, &desc->flags);
932 spin_unlock_irq(&desc->iuspin);
933 /* callback submits work - order is essential */
935 cancel_work_sync(&desc->rxwork);
937 if (!PMSG_IS_AUTO(message)) {
938 mutex_unlock(&desc->wlock);
939 mutex_unlock(&desc->rlock);
946 static int recover_from_urb_loss(struct wdm_device *desc)
951 rv = usb_submit_urb(desc->validity, GFP_NOIO);
953 dev_err(&desc->intf->dev,
954 "Error resume submitting int urb - %d\n", rv);
960 static int wdm_resume(struct usb_interface *intf)
962 struct wdm_device *desc = wdm_find_device(intf);
965 dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor);
967 clear_bit(WDM_SUSPENDING, &desc->flags);
968 rv = recover_from_urb_loss(desc);
974 static int wdm_pre_reset(struct usb_interface *intf)
976 struct wdm_device *desc = wdm_find_device(intf);
979 * we notify everybody using poll of
980 * an exceptional situation
981 * must be done before recovery lest a spontaneous
982 * message from the device is lost
984 spin_lock_irq(&desc->iuspin);
985 set_bit(WDM_RESETTING, &desc->flags); /* inform read/write */
986 set_bit(WDM_READ, &desc->flags); /* unblock read */
987 clear_bit(WDM_IN_USE, &desc->flags); /* unblock write */
989 spin_unlock_irq(&desc->iuspin);
990 wake_up_all(&desc->wait);
991 mutex_lock(&desc->rlock);
992 mutex_lock(&desc->wlock);
994 cancel_work_sync(&desc->rxwork);
998 static int wdm_post_reset(struct usb_interface *intf)
1000 struct wdm_device *desc = wdm_find_device(intf);
1003 clear_bit(WDM_RESETTING, &desc->flags);
1004 rv = recover_from_urb_loss(desc);
1005 mutex_unlock(&desc->wlock);
1006 mutex_unlock(&desc->rlock);
1010 static struct usb_driver wdm_driver = {
1013 .disconnect = wdm_disconnect,
1015 .suspend = wdm_suspend,
1016 .resume = wdm_resume,
1017 .reset_resume = wdm_resume,
1019 .pre_reset = wdm_pre_reset,
1020 .post_reset = wdm_post_reset,
1021 .id_table = wdm_ids,
1022 .supports_autosuspend = 1,
1023 .disable_hub_initiated_lpm = 1,
1026 module_usb_driver(wdm_driver);
1028 MODULE_AUTHOR(DRIVER_AUTHOR);
1029 MODULE_DESCRIPTION(DRIVER_DESC);
1030 MODULE_LICENSE("GPL");