summaryrefslogtreecommitdiff
path: root/drivers/usb/core/sysfs.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2010-01-08 12:56:19 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-02 14:54:08 -0800
commit62e299e61a6ffe8131fa85a984c3058b68586f5d (patch)
treed10709c5b5e6d280e1329c7ed4f30f990246893e /drivers/usb/core/sysfs.c
parent0f3dda9f7ff2db8dbf4d6fbab4d4438251446002 (diff)
USB: change locking for device-level autosuspend
This patch (as1323) changes the locking requirements for usb_autosuspend_device(), usb_autoresume_device(), and usb_try_autosuspend_device(). This isn't a very important change; mainly it's meant to make the locking more uniform. The most tricky part of the patch involves changes to usbdev_open(). To avoid an ABBA locking problem, it was necessary to reduce the region protected by usbfs_mutex. Since that mutex now protects only against simultaneous open and remove, this posed no difficulty -- its scope was larger than necessary. And it turns out that usbfs_mutex is no longer needed in usbdev_release() at all. The list of usbfs "ps" structures is now protected by the device lock instead of by usbfs_mutex. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/sysfs.c')
-rw-r--r--drivers/usb/core/sysfs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 1b3c00b3ca3f..d8f3bfe1559f 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -352,6 +352,7 @@ set_autosuspend(struct device *dev, struct device_attribute *attr,
return -EINVAL;
value *= HZ;
+ usb_lock_device(udev);
udev->autosuspend_delay = value;
if (value >= 0)
usb_try_autosuspend_device(udev);
@@ -359,6 +360,7 @@ set_autosuspend(struct device *dev, struct device_attribute *attr,
if (usb_autoresume_device(udev) == 0)
usb_autosuspend_device(udev);
}
+ usb_unlock_device(udev);
return count;
}