]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
USB: fix warning caused by autosuspend counter going negative
authorAlan Stern <stern@rowland.harvard.edu>
Mon, 16 Jul 2007 19:28:19 +0000 (15:28 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 20 Jul 2007 00:46:04 +0000 (17:46 -0700)
This patch (as937) fixes a minor bug in the autosuspend usage-counting
code.  Each hub's usage counter keeps track of the number of
unsuspended children.  However the current driver increments the
counter after registering a new child, by which time the child may
already have been suspended and caused the counter to go negative.
The obvious solution is to increment the counter before registering
the child.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hub.c

index fd74c50b18049b71f85256fa47a62d6199bc2098..e341a1da517fe8589c7153b0bf7811f84c435e51 100644 (file)
@@ -1335,6 +1335,10 @@ int usb_new_device(struct usb_device *udev)
        udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
                        (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
 
+       /* Increment the parent's count of unsuspended children */
+       if (udev->parent)
+               usb_autoresume_device(udev->parent);
+
        /* Register the device.  The device driver is responsible
         * for adding the device files to sysfs and for configuring
         * the device.
@@ -1342,13 +1346,11 @@ int usb_new_device(struct usb_device *udev)
        err = device_add(&udev->dev);
        if (err) {
                dev_err(&udev->dev, "can't device_add, error %d\n", err);
+               if (udev->parent)
+                       usb_autosuspend_device(udev->parent);
                goto fail;
        }
 
-       /* Increment the parent's count of unsuspended children */
-       if (udev->parent)
-               usb_autoresume_device(udev->parent);
-
 exit:
        return err;