diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-03-13 16:39:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-04-27 16:28:35 -0400 |
commit | eaafbc3a8adab16babe2c20e54ad3ba40d1fbbc9 (patch) | |
tree | fea84341faf742efe8beeaff03ec94b687b7b26f | |
parent | 6b157c9bf3bace6eeb4a973da63923ef24995cce (diff) |
USB: Allow autosuspend delay to equal 0
This patch (as867) adds an entry for the new power/autosuspend
attribute in Documentation/ABI/testing, and it changes the behavior of
the delay value. Now a delay of 0 means to autosuspend as soon as
possible, and negative values will prevent autosuspend.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | Documentation/ABI/testing/sysfs-bus-usb | 15 | ||||
-rw-r--r-- | Documentation/kernel-parameters.txt | 2 | ||||
-rw-r--r-- | drivers/usb/core/driver.c | 2 | ||||
-rw-r--r-- | drivers/usb/core/sysfs.c | 16 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 2 | ||||
-rw-r--r-- | include/linux/usb.h | 2 |
6 files changed, 29 insertions, 10 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb new file mode 100644 index 000000000000..00a84326325f --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-usb | |||
@@ -0,0 +1,15 @@ | |||
1 | What: /sys/bus/usb/devices/.../power/autosuspend | ||
2 | Date: March 2007 | ||
3 | KernelVersion: 2.6.21 | ||
4 | Contact: Alan Stern <stern@rowland.harvard.edu> | ||
5 | Description: | ||
6 | Each USB device directory will contain a file named | ||
7 | power/autosuspend. This file holds the time (in seconds) | ||
8 | the device must be idle before it will be autosuspended. | ||
9 | 0 means the device will be autosuspended as soon as | ||
10 | possible. Negative values will prevent the device from | ||
11 | being autosuspended at all, and writing a negative value | ||
12 | will resume the device if it is already suspended. | ||
13 | |||
14 | The autosuspend delay for newly-created devices is set to | ||
15 | the value of the usbcore.autosuspend module parameter. | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 12533a958c51..2017942e0966 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1792,7 +1792,7 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1792 | for newly-detected USB devices (default 2). This | 1792 | for newly-detected USB devices (default 2). This |
1793 | is the time required before an idle device will be | 1793 | is the time required before an idle device will be |
1794 | autosuspended. Devices for which the delay is set | 1794 | autosuspended. Devices for which the delay is set |
1795 | to 0 won't be autosuspended at all. | 1795 | to a negative value won't be autosuspended at all. |
1796 | 1796 | ||
1797 | usbhid.mousepoll= | 1797 | usbhid.mousepoll= |
1798 | [USBHID] The interval which mice are to be polled at. | 1798 | [USBHID] The interval which mice are to be polled at. |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index abea48de8766..884179f1e163 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -970,7 +970,7 @@ static int autosuspend_check(struct usb_device *udev) | |||
970 | udev->do_remote_wakeup = device_may_wakeup(&udev->dev); | 970 | udev->do_remote_wakeup = device_may_wakeup(&udev->dev); |
971 | if (udev->pm_usage_cnt > 0) | 971 | if (udev->pm_usage_cnt > 0) |
972 | return -EBUSY; | 972 | return -EBUSY; |
973 | if (!udev->autosuspend_delay) | 973 | if (udev->autosuspend_delay < 0) |
974 | return -EPERM; | 974 | return -EPERM; |
975 | 975 | ||
976 | if (udev->actconfig) { | 976 | if (udev->actconfig) { |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 311d5df80386..731001f7d2c1 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -165,7 +165,7 @@ show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) | |||
165 | { | 165 | { |
166 | struct usb_device *udev = to_usb_device(dev); | 166 | struct usb_device *udev = to_usb_device(dev); |
167 | 167 | ||
168 | return sprintf(buf, "%u\n", udev->autosuspend_delay / HZ); | 168 | return sprintf(buf, "%d\n", udev->autosuspend_delay / HZ); |
169 | } | 169 | } |
170 | 170 | ||
171 | static ssize_t | 171 | static ssize_t |
@@ -173,17 +173,21 @@ set_autosuspend(struct device *dev, struct device_attribute *attr, | |||
173 | const char *buf, size_t count) | 173 | const char *buf, size_t count) |
174 | { | 174 | { |
175 | struct usb_device *udev = to_usb_device(dev); | 175 | struct usb_device *udev = to_usb_device(dev); |
176 | unsigned value, old; | 176 | int value; |
177 | 177 | ||
178 | if (sscanf(buf, "%u", &value) != 1 || value >= INT_MAX/HZ) | 178 | if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ || |
179 | value <= - INT_MAX/HZ) | ||
179 | return -EINVAL; | 180 | return -EINVAL; |
180 | value *= HZ; | 181 | value *= HZ; |
181 | 182 | ||
182 | old = udev->autosuspend_delay; | ||
183 | udev->autosuspend_delay = value; | 183 | udev->autosuspend_delay = value; |
184 | if (value > 0 && old == 0) | 184 | if (value >= 0) |
185 | usb_try_autosuspend_device(udev); | 185 | usb_try_autosuspend_device(udev); |
186 | 186 | else { | |
187 | usb_lock_device(udev); | ||
188 | usb_external_resume_device(udev); | ||
189 | usb_unlock_device(udev); | ||
190 | } | ||
187 | return count; | 191 | return count; |
188 | } | 192 | } |
189 | 193 | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 138252e0a1cf..6f35dce8a95d 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -55,7 +55,7 @@ struct workqueue_struct *ksuspend_usb_wq; | |||
55 | #ifdef CONFIG_USB_SUSPEND | 55 | #ifdef CONFIG_USB_SUSPEND |
56 | static int usb_autosuspend_delay = 2; /* Default delay value, | 56 | static int usb_autosuspend_delay = 2; /* Default delay value, |
57 | * in seconds */ | 57 | * in seconds */ |
58 | module_param_named(autosuspend, usb_autosuspend_delay, uint, 0644); | 58 | module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); |
59 | MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); | 59 | MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); |
60 | 60 | ||
61 | #else | 61 | #else |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 87dc75a6cee1..cc24d089faa0 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -394,7 +394,7 @@ struct usb_device { | |||
394 | struct delayed_work autosuspend; /* for delayed autosuspends */ | 394 | struct delayed_work autosuspend; /* for delayed autosuspends */ |
395 | struct mutex pm_mutex; /* protects PM operations */ | 395 | struct mutex pm_mutex; /* protects PM operations */ |
396 | 396 | ||
397 | unsigned autosuspend_delay; /* in jiffies */ | 397 | int autosuspend_delay; /* in jiffies */ |
398 | 398 | ||
399 | unsigned auto_pm:1; /* autosuspend/resume in progress */ | 399 | unsigned auto_pm:1; /* autosuspend/resume in progress */ |
400 | unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ | 400 | unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ |