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;
114 spin_lock(&wdm_device_list_lock);
115 list_for_each_entry(desc, &wdm_device_list, device_list)
116 if (desc->intf == intf)
120 spin_unlock(&wdm_device_list_lock);
125 static struct wdm_device *wdm_find_device_by_minor(int minor)
127 struct wdm_device *desc;
129 spin_lock(&wdm_device_list_lock);
130 list_for_each_entry(desc, &wdm_device_list, device_list)
131 if (desc->intf->minor == minor)
135 spin_unlock(&wdm_device_list_lock);
140 /* --- callbacks --- */
141 static void wdm_out_callback(struct urb *urb)
143 struct wdm_device *desc;
145 spin_lock(&desc->iuspin);
146 desc->werr = urb->status;
147 spin_unlock(&desc->iuspin);
150 clear_bit(WDM_IN_USE, &desc->flags);
151 wake_up(&desc->wait);
154 static void wdm_in_callback(struct urb *urb)
156 struct wdm_device *desc = urb->context;
157 int status = urb->status;
159 spin_lock(&desc->iuspin);
160 clear_bit(WDM_RESPONDING, &desc->flags);
165 dev_dbg(&desc->intf->dev,
166 "nonzero urb status received: -ENOENT");
169 dev_dbg(&desc->intf->dev,
170 "nonzero urb status received: -ECONNRESET");
173 dev_dbg(&desc->intf->dev,
174 "nonzero urb status received: -ESHUTDOWN");
177 dev_err(&desc->intf->dev,
178 "nonzero urb status received: -EPIPE\n");
181 dev_err(&desc->intf->dev,
182 "Unexpected error %d\n", status);
188 desc->reslength = urb->actual_length;
189 memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
190 desc->length += desc->reslength;
192 wake_up(&desc->wait);
194 set_bit(WDM_READ, &desc->flags);
195 spin_unlock(&desc->iuspin);
198 static void wdm_int_callback(struct urb *urb)
201 int status = urb->status;
202 struct wdm_device *desc;
203 struct usb_cdc_notification *dr;
206 dr = (struct usb_cdc_notification *)desc->sbuf;
215 set_bit(WDM_INT_STALL, &desc->flags);
216 dev_err(&desc->intf->dev, "Stall on int endpoint\n");
217 goto sw; /* halt is cleared in work */
219 dev_err(&desc->intf->dev,
220 "nonzero urb status received: %d\n", status);
225 if (urb->actual_length < sizeof(struct usb_cdc_notification)) {
226 dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n",
231 switch (dr->bNotificationType) {
232 case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
233 dev_dbg(&desc->intf->dev,
234 "NOTIFY_RESPONSE_AVAILABLE received: index %d len %d",
235 dr->wIndex, dr->wLength);
238 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
240 dev_dbg(&desc->intf->dev,
241 "NOTIFY_NETWORK_CONNECTION %s network",
242 dr->wValue ? "connected to" : "disconnected from");
245 clear_bit(WDM_POLL_RUNNING, &desc->flags);
246 dev_err(&desc->intf->dev,
247 "unknown notification %d received: index %d len %d\n",
248 dr->bNotificationType, dr->wIndex, dr->wLength);
252 spin_lock(&desc->iuspin);
253 clear_bit(WDM_READ, &desc->flags);
254 set_bit(WDM_RESPONDING, &desc->flags);
255 if (!test_bit(WDM_DISCONNECTING, &desc->flags)
256 && !test_bit(WDM_SUSPENDING, &desc->flags)) {
257 rv = usb_submit_urb(desc->response, GFP_ATOMIC);
258 dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
261 spin_unlock(&desc->iuspin);
263 clear_bit(WDM_RESPONDING, &desc->flags);
268 rv = schedule_work(&desc->rxwork);
270 dev_err(&desc->intf->dev,
271 "Cannot schedule work\n");
275 rv = usb_submit_urb(urb, GFP_ATOMIC);
277 dev_err(&desc->intf->dev,
278 "%s - usb_submit_urb failed with result %d\n",
283 static void kill_urbs(struct wdm_device *desc)
285 /* the order here is essential */
286 usb_kill_urb(desc->command);
287 usb_kill_urb(desc->validity);
288 usb_kill_urb(desc->response);
291 static void free_urbs(struct wdm_device *desc)
293 usb_free_urb(desc->validity);
294 usb_free_urb(desc->response);
295 usb_free_urb(desc->command);
298 static void cleanup(struct wdm_device *desc)
309 static ssize_t wdm_write
310 (struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
313 int rv = -EMSGSIZE, r, we;
314 struct wdm_device *desc = file->private_data;
315 struct usb_ctrlrequest *req;
317 if (count > desc->wMaxCommand)
318 count = desc->wMaxCommand;
320 spin_lock_irq(&desc->iuspin);
323 spin_unlock_irq(&desc->iuspin);
327 buf = kmalloc(count, GFP_KERNEL);
333 r = copy_from_user(buf, buffer, count);
340 /* concurrent writes and disconnect */
341 r = mutex_lock_interruptible(&desc->wlock);
348 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
354 r = usb_autopm_get_interface(desc->intf);
357 rv = usb_translate_errors(r);
361 if (!(file->f_flags & O_NONBLOCK))
362 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
365 if (test_bit(WDM_IN_USE, &desc->flags))
368 if (test_bit(WDM_RESETTING, &desc->flags))
378 usb_fill_control_urb(
380 interface_to_usbdev(desc->intf),
381 /* using common endpoint 0 */
382 usb_sndctrlpipe(interface_to_usbdev(desc->intf), 0),
383 (unsigned char *)req,
390 req->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS |
391 USB_RECIP_INTERFACE);
392 req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;
394 req->wIndex = desc->inum;
395 req->wLength = cpu_to_le16(count);
396 set_bit(WDM_IN_USE, &desc->flags);
399 rv = usb_submit_urb(desc->command, GFP_KERNEL);
403 clear_bit(WDM_IN_USE, &desc->flags);
404 dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
405 rv = usb_translate_errors(rv);
407 dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
411 usb_autopm_put_interface(desc->intf);
413 mutex_unlock(&desc->wlock);
415 return rv < 0 ? rv : count;
418 static ssize_t wdm_read
419 (struct file *file, char __user *buffer, size_t count, loff_t *ppos)
423 struct wdm_device *desc = file->private_data;
426 rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
430 cntr = ACCESS_ONCE(desc->length);
434 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
439 if (file->f_flags & O_NONBLOCK) {
440 if (!test_bit(WDM_READ, &desc->flags)) {
441 rv = cntr ? cntr : -EAGAIN;
446 rv = wait_event_interruptible(desc->wait,
447 test_bit(WDM_READ, &desc->flags));
450 /* may have happened while we slept */
451 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
455 if (test_bit(WDM_RESETTING, &desc->flags)) {
459 usb_mark_last_busy(interface_to_usbdev(desc->intf));
465 spin_lock_irq(&desc->iuspin);
467 if (desc->rerr) { /* read completed, error happened */
469 spin_unlock_irq(&desc->iuspin);
474 * recheck whether we've lost the race
475 * against the completion handler
477 if (!test_bit(WDM_READ, &desc->flags)) { /* lost race */
478 spin_unlock_irq(&desc->iuspin);
481 if (!desc->reslength) { /* zero length read */
482 dev_dbg(&desc->intf->dev, "%s: zero length - clearing WDM_READ\n", __func__);
483 clear_bit(WDM_READ, &desc->flags);
484 spin_unlock_irq(&desc->iuspin);
488 spin_unlock_irq(&desc->iuspin);
493 rv = copy_to_user(buffer, desc->ubuf, cntr);
499 spin_lock_irq(&desc->iuspin);
501 for (i = 0; i < desc->length - cntr; i++)
502 desc->ubuf[i] = desc->ubuf[i + cntr];
504 desc->length -= cntr;
505 /* in case we had outstanding data */
507 clear_bit(WDM_READ, &desc->flags);
509 spin_unlock_irq(&desc->iuspin);
514 mutex_unlock(&desc->rlock);
518 static int wdm_flush(struct file *file, fl_owner_t id)
520 struct wdm_device *desc = file->private_data;
522 wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
524 /* cannot dereference desc->intf if WDM_DISCONNECTING */
525 if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
526 dev_err(&desc->intf->dev, "Error in flush path: %d\n",
529 return usb_translate_errors(desc->werr);
532 static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
534 struct wdm_device *desc = file->private_data;
536 unsigned int mask = 0;
538 spin_lock_irqsave(&desc->iuspin, flags);
539 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
540 mask = POLLHUP | POLLERR;
541 spin_unlock_irqrestore(&desc->iuspin, flags);
544 if (test_bit(WDM_READ, &desc->flags))
545 mask = POLLIN | POLLRDNORM;
546 if (desc->rerr || desc->werr)
548 if (!test_bit(WDM_IN_USE, &desc->flags))
549 mask |= POLLOUT | POLLWRNORM;
550 spin_unlock_irqrestore(&desc->iuspin, flags);
552 poll_wait(file, &desc->wait, wait);
558 static int wdm_open(struct inode *inode, struct file *file)
560 int minor = iminor(inode);
562 struct usb_interface *intf;
563 struct wdm_device *desc;
565 mutex_lock(&wdm_mutex);
566 desc = wdm_find_device_by_minor(minor);
571 if (test_bit(WDM_DISCONNECTING, &desc->flags))
573 file->private_data = desc;
575 rv = usb_autopm_get_interface(desc->intf);
577 dev_err(&desc->intf->dev, "Error autopm - %d\n", rv);
581 /* using write lock to protect desc->count */
582 mutex_lock(&desc->wlock);
583 if (!desc->count++) {
586 rv = usb_submit_urb(desc->validity, GFP_KERNEL);
589 dev_err(&desc->intf->dev,
590 "Error submitting int urb - %d\n", rv);
591 rv = usb_translate_errors(rv);
596 mutex_unlock(&desc->wlock);
597 if (desc->count == 1)
598 desc->manage_power(intf, 1);
599 usb_autopm_put_interface(desc->intf);
601 mutex_unlock(&wdm_mutex);
605 static int wdm_release(struct inode *inode, struct file *file)
607 struct wdm_device *desc = file->private_data;
609 mutex_lock(&wdm_mutex);
611 /* using write lock to protect desc->count */
612 mutex_lock(&desc->wlock);
614 mutex_unlock(&desc->wlock);
617 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
618 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
620 desc->manage_power(desc->intf, 0);
622 /* must avoid dev_printk here as desc->intf is invalid */
623 pr_debug(KBUILD_MODNAME " %s: device gone - cleaning up\n", __func__);
627 mutex_unlock(&wdm_mutex);
631 static const struct file_operations wdm_fops = {
632 .owner = THIS_MODULE,
637 .release = wdm_release,
639 .llseek = noop_llseek,
642 static struct usb_class_driver wdm_class = {
645 .minor_base = WDM_MINOR_BASE,
648 /* --- error handling --- */
649 static void wdm_rxwork(struct work_struct *work)
651 struct wdm_device *desc = container_of(work, struct wdm_device, rxwork);
655 spin_lock_irqsave(&desc->iuspin, flags);
656 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
657 spin_unlock_irqrestore(&desc->iuspin, flags);
659 spin_unlock_irqrestore(&desc->iuspin, flags);
660 rv = usb_submit_urb(desc->response, GFP_KERNEL);
661 if (rv < 0 && rv != -EPERM) {
662 spin_lock_irqsave(&desc->iuspin, flags);
663 if (!test_bit(WDM_DISCONNECTING, &desc->flags))
664 schedule_work(&desc->rxwork);
665 spin_unlock_irqrestore(&desc->iuspin, flags);
670 /* --- hotplug --- */
672 static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor *ep,
673 u16 bufsize, int (*manage_power)(struct usb_interface *, int))
676 struct wdm_device *desc;
678 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
681 INIT_LIST_HEAD(&desc->device_list);
682 mutex_init(&desc->rlock);
683 mutex_init(&desc->wlock);
684 spin_lock_init(&desc->iuspin);
685 init_waitqueue_head(&desc->wait);
686 desc->wMaxCommand = bufsize;
687 /* this will be expanded and needed in hardware endianness */
688 desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber);
690 INIT_WORK(&desc->rxwork, wdm_rxwork);
693 if (!usb_endpoint_is_int_in(ep))
696 desc->wMaxPacketSize = usb_endpoint_maxp(ep);
698 desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
701 desc->irq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
705 desc->validity = usb_alloc_urb(0, GFP_KERNEL);
709 desc->response = usb_alloc_urb(0, GFP_KERNEL);
713 desc->command = usb_alloc_urb(0, GFP_KERNEL);
717 desc->ubuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
721 desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL);
725 desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
731 interface_to_usbdev(intf),
732 usb_rcvintpipe(interface_to_usbdev(intf), ep->bEndpointAddress),
734 desc->wMaxPacketSize,
740 desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
741 desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE;
742 desc->irq->wValue = 0;
743 desc->irq->wIndex = desc->inum;
744 desc->irq->wLength = cpu_to_le16(desc->wMaxCommand);
746 usb_fill_control_urb(
748 interface_to_usbdev(intf),
749 /* using common endpoint 0 */
750 usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0),
751 (unsigned char *)desc->irq,
758 desc->manage_power = manage_power;
760 spin_lock(&wdm_device_list_lock);
761 list_add(&desc->device_list, &wdm_device_list);
762 spin_unlock(&wdm_device_list_lock);
764 rv = usb_register_dev(intf, &wdm_class);
768 dev_info(&intf->dev, "%s: USB WDM device\n", dev_name(intf->usb_dev));
772 spin_lock(&wdm_device_list_lock);
773 list_del(&desc->device_list);
774 spin_unlock(&wdm_device_list_lock);
779 static int wdm_manage_power(struct usb_interface *intf, int on)
781 /* need autopm_get/put here to ensure the usbcore sees the new value */
782 int rv = usb_autopm_get_interface(intf);
786 intf->needs_remote_wakeup = on;
787 usb_autopm_put_interface(intf);
792 static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
795 struct usb_host_interface *iface;
796 struct usb_endpoint_descriptor *ep;
797 struct usb_cdc_dmm_desc *dmhd;
798 u8 *buffer = intf->altsetting->extra;
799 int buflen = intf->altsetting->extralen;
800 u16 maxcom = WDM_DEFAULT_BUFSIZE;
805 if (buffer[1] != USB_DT_CS_INTERFACE) {
806 dev_err(&intf->dev, "skipping garbage\n");
811 case USB_CDC_HEADER_TYPE:
813 case USB_CDC_DMM_TYPE:
814 dmhd = (struct usb_cdc_dmm_desc *)buffer;
815 maxcom = le16_to_cpu(dmhd->wMaxCommand);
817 "Finding maximum buffer length: %d", maxcom);
821 "Ignoring extra header, type %d, length %d\n",
822 buffer[2], buffer[0]);
830 iface = intf->cur_altsetting;
831 if (iface->desc.bNumEndpoints != 1)
833 ep = &iface->endpoint[0].desc;
835 rv = wdm_create(intf, ep, maxcom, &wdm_manage_power);
842 * usb_cdc_wdm_register - register a WDM subdriver
843 * @intf: usb interface the subdriver will associate with
844 * @ep: interrupt endpoint to monitor for notifications
845 * @bufsize: maximum message size to support for read/write
847 * Create WDM usb class character device and associate it with intf
848 * without binding, allowing another driver to manage the interface.
850 * The subdriver will manage the given interrupt endpoint exclusively
851 * and will issue control requests referring to the given intf. It
852 * will otherwise avoid interferring, and in particular not do
853 * usb_set_intfdata/usb_get_intfdata on intf.
855 * The return value is a pointer to the subdriver's struct usb_driver.
856 * The registering driver is responsible for calling this subdriver's
857 * disconnect, suspend, resume, pre_reset and post_reset methods from
860 struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf,
861 struct usb_endpoint_descriptor *ep,
863 int (*manage_power)(struct usb_interface *, int))
867 rv = wdm_create(intf, ep, bufsize, manage_power);
875 EXPORT_SYMBOL(usb_cdc_wdm_register);
877 static void wdm_disconnect(struct usb_interface *intf)
879 struct wdm_device *desc;
882 usb_deregister_dev(intf, &wdm_class);
883 desc = wdm_find_device(intf);
884 mutex_lock(&wdm_mutex);
886 /* the spinlock makes sure no new urbs are generated in the callbacks */
887 spin_lock_irqsave(&desc->iuspin, flags);
888 set_bit(WDM_DISCONNECTING, &desc->flags);
889 set_bit(WDM_READ, &desc->flags);
890 /* to terminate pending flushes */
891 clear_bit(WDM_IN_USE, &desc->flags);
892 spin_unlock_irqrestore(&desc->iuspin, flags);
893 wake_up_all(&desc->wait);
894 mutex_lock(&desc->rlock);
895 mutex_lock(&desc->wlock);
897 cancel_work_sync(&desc->rxwork);
898 mutex_unlock(&desc->wlock);
899 mutex_unlock(&desc->rlock);
901 /* the desc->intf pointer used as list key is now invalid */
902 spin_lock(&wdm_device_list_lock);
903 list_del(&desc->device_list);
904 spin_unlock(&wdm_device_list_lock);
909 dev_dbg(&intf->dev, "%s: %d open files - postponing cleanup\n", __func__, desc->count);
910 mutex_unlock(&wdm_mutex);
914 static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
916 struct wdm_device *desc = wdm_find_device(intf);
919 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
921 /* if this is an autosuspend the caller does the locking */
922 if (!PMSG_IS_AUTO(message)) {
923 mutex_lock(&desc->rlock);
924 mutex_lock(&desc->wlock);
926 spin_lock_irq(&desc->iuspin);
928 if (PMSG_IS_AUTO(message) &&
929 (test_bit(WDM_IN_USE, &desc->flags)
930 || test_bit(WDM_RESPONDING, &desc->flags))) {
931 spin_unlock_irq(&desc->iuspin);
935 set_bit(WDM_SUSPENDING, &desc->flags);
936 spin_unlock_irq(&desc->iuspin);
937 /* callback submits work - order is essential */
939 cancel_work_sync(&desc->rxwork);
941 if (!PMSG_IS_AUTO(message)) {
942 mutex_unlock(&desc->wlock);
943 mutex_unlock(&desc->rlock);
950 static int recover_from_urb_loss(struct wdm_device *desc)
955 rv = usb_submit_urb(desc->validity, GFP_NOIO);
957 dev_err(&desc->intf->dev,
958 "Error resume submitting int urb - %d\n", rv);
964 static int wdm_resume(struct usb_interface *intf)
966 struct wdm_device *desc = wdm_find_device(intf);
969 dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor);
971 clear_bit(WDM_SUSPENDING, &desc->flags);
972 rv = recover_from_urb_loss(desc);
978 static int wdm_pre_reset(struct usb_interface *intf)
980 struct wdm_device *desc = wdm_find_device(intf);
983 * we notify everybody using poll of
984 * an exceptional situation
985 * must be done before recovery lest a spontaneous
986 * message from the device is lost
988 spin_lock_irq(&desc->iuspin);
989 set_bit(WDM_RESETTING, &desc->flags); /* inform read/write */
990 set_bit(WDM_READ, &desc->flags); /* unblock read */
991 clear_bit(WDM_IN_USE, &desc->flags); /* unblock write */
993 spin_unlock_irq(&desc->iuspin);
994 wake_up_all(&desc->wait);
995 mutex_lock(&desc->rlock);
996 mutex_lock(&desc->wlock);
998 cancel_work_sync(&desc->rxwork);
1002 static int wdm_post_reset(struct usb_interface *intf)
1004 struct wdm_device *desc = wdm_find_device(intf);
1007 clear_bit(WDM_RESETTING, &desc->flags);
1008 rv = recover_from_urb_loss(desc);
1009 mutex_unlock(&desc->wlock);
1010 mutex_unlock(&desc->rlock);
1014 static struct usb_driver wdm_driver = {
1017 .disconnect = wdm_disconnect,
1019 .suspend = wdm_suspend,
1020 .resume = wdm_resume,
1021 .reset_resume = wdm_resume,
1023 .pre_reset = wdm_pre_reset,
1024 .post_reset = wdm_post_reset,
1025 .id_table = wdm_ids,
1026 .supports_autosuspend = 1,
1027 .disable_hub_initiated_lpm = 1,
1030 module_usb_driver(wdm_driver);
1032 MODULE_AUTHOR(DRIVER_AUTHOR);
1033 MODULE_DESCRIPTION(DRIVER_DESC);
1034 MODULE_LICENSE("GPL");