aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-03-13 16:39:15 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 13:28:35 -0700
commiteaafbc3a8adab16babe2c20e54ad3ba40d1fbbc9 (patch)
treefea84341faf742efe8beeaff03ec94b687b7b26f /drivers
parent6b157c9bf3bace6eeb4a973da63923ef24995cce (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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/driver.c2
-rw-r--r--drivers/usb/core/sysfs.c16
-rw-r--r--drivers/usb/core/usb.c2
3 files changed, 12 insertions, 8 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index abea48de876..884179f1e16 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)
udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
if (udev->pm_usage_cnt > 0)
return -EBUSY;
- if (!udev->autosuspend_delay)
+ if (udev->autosuspend_delay < 0)
return -EPERM;
if (udev->actconfig) {
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 311d5df8038..731001f7d2c 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)
{
struct usb_device *udev = to_usb_device(dev);
- return sprintf(buf, "%u\n", udev->autosuspend_delay / HZ);
+ return sprintf(buf, "%d\n", udev->autosuspend_delay / HZ);
}
static ssize_t
@@ -173,17 +173,21 @@ set_autosuspend(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct usb_device *udev = to_usb_device(dev);
- unsigned value, old;
+ int value;
- if (sscanf(buf, "%u", &value) != 1 || value >= INT_MAX/HZ)
+ if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ ||
+ value <= - INT_MAX/HZ)
return -EINVAL;
value *= HZ;
- old = udev->autosuspend_delay;
udev->autosuspend_delay = value;
- if (value > 0 && old == 0)
+ if (value >= 0)
usb_try_autosuspend_device(udev);
-
+ else {
+ usb_lock_device(udev);
+ usb_external_resume_device(udev);
+ usb_unlock_device(udev);
+ }
return count;
}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 138252e0a1c..6f35dce8a95 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -55,7 +55,7 @@ struct workqueue_struct *ksuspend_usb_wq;
#ifdef CONFIG_USB_SUSPEND
static int usb_autosuspend_delay = 2; /* Default delay value,
* in seconds */
-module_param_named(autosuspend, usb_autosuspend_delay, uint, 0644);
+module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
#else