aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/usb-skeleton.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-08-30 15:47:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:57 -0400
commit01d883d44a1ca8dc77486635d428cba63e7fdadf (patch)
tree447a4293b2ec4dfa1b3d03a46a3a33498809f0e8 /drivers/usb/usb-skeleton.c
parent645daaab0b6adc35c1838df2a82f9d729fdb1767 (diff)
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>
Diffstat (limited to 'drivers/usb/usb-skeleton.c')
-rw-r--r--drivers/usb/usb-skeleton.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 9b542a6ba978..1b51d3187a95 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -90,6 +90,11 @@ static int skel_open(struct inode *inode, struct file *file)
90 goto exit; 90 goto exit;
91 } 91 }
92 92
93 /* prevent the device from being autosuspended */
94 retval = usb_autopm_get_interface(interface);
95 if (retval)
96 goto exit;
97
93 /* increment our usage count for the device */ 98 /* increment our usage count for the device */
94 kref_get(&dev->kref); 99 kref_get(&dev->kref);
95 100
@@ -108,6 +113,12 @@ static int skel_release(struct inode *inode, struct file *file)
108 if (dev == NULL) 113 if (dev == NULL)
109 return -ENODEV; 114 return -ENODEV;
110 115
116 /* allow the device to be autosuspended */
117 mutex_lock(&dev->io_mutex);
118 if (dev->interface)
119 usb_autopm_put_interface(dev->interface);
120 mutex_unlock(&dev->io_mutex);
121
111 /* decrement the count on our device */ 122 /* decrement the count on our device */
112 kref_put(&dev->kref, skel_delete); 123 kref_put(&dev->kref, skel_delete);
113 return 0; 124 return 0;