usbcore: non-hub-specific uses of autosuspend
This patch (as741) makes the non-hub parts of usbcore actually use the
autosuspend facilities added by an earlier patch.
Devices opened through usbfs are autoresumed and then
autosuspended upon close.
Likewise for usb-skeleton.
Devices are autoresumed for usb_set_configuration.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 43c0872..fd345ad 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -558,10 +558,12 @@
dev = usbdev_lookup_minor(iminor(inode));
if (!dev)
dev = inode->i_private;
- if (!dev) {
- kfree(ps);
+ if (!dev)
goto out;
- }
+ ret = usb_autoresume_device(dev, 1);
+ if (ret)
+ goto out;
+
usb_get_dev(dev);
ret = 0;
ps->dev = dev;
@@ -581,6 +583,8 @@
list_add_tail(&ps->list, &dev->filelist);
file->private_data = ps;
out:
+ if (ret)
+ kfree(ps);
mutex_unlock(&usbfs_mutex);
return ret;
}
@@ -604,6 +608,7 @@
releaseintf(ps, ifnum);
}
destroy_all_async(ps);
+ usb_autosuspend_device(dev, 1);
usb_unlock_device(dev);
usb_put_dev(dev);
kfree(ps);