USB: cdc-wdm: reset handling according to new requirements
authorOliver Neukum <oliver@neukum.org>
Fri, 29 Apr 2011 12:12:21 +0000 (14:12 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 30 Apr 2011 00:04:40 +0000 (17:04 -0700)
This patch
- ensures no IO takes place during resets
- reports resets to user space

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/cdc-wdm.c

index a97c018dd41980ebc6a9087d235f7ee1fdc965b4..2b9ff518b509c3ca45fa7e064aa5be56fbae36ae 100644 (file)
@@ -542,6 +542,8 @@ static int wdm_open(struct inode *inode, struct file *file)
 
        mutex_lock(&desc->lock);
        if (!desc->count++) {
+               desc->werr = 0;
+               desc->rerr = 0;
                rv = usb_submit_urb(desc->validity, GFP_KERNEL);
                if (rv < 0) {
                        desc->count--;
@@ -853,6 +855,18 @@ static int wdm_pre_reset(struct usb_interface *intf)
        struct wdm_device *desc = usb_get_intfdata(intf);
 
        mutex_lock(&desc->lock);
+       kill_urbs(desc);
+
+       /*
+        * we notify everybody using poll of
+        * an exceptional situation
+        * must be done before recovery lest a spontaneous
+        * message from the device is lost
+        */
+       spin_lock_irq(&desc->iuspin);
+       desc->rerr = -EINTR;
+       spin_unlock_irq(&desc->iuspin);
+       wake_up_all(&desc->wait);
        return 0;
 }