Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=eaafbc3a8adab16babe2c20e54ad3ba40d1fbbc9
Commit:     eaafbc3a8adab16babe2c20e54ad3ba40d1fbbc9
Parent:     6b157c9bf3bace6eeb4a973da63923ef24995cce
Author:     Alan Stern <[EMAIL PROTECTED]>
AuthorDate: Tue Mar 13 16:39:15 2007 -0400
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Apr 27 13:28:35 2007 -0700

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 Documentation/ABI/testing/sysfs-bus-usb |   15 +++++++++++++++
 Documentation/kernel-parameters.txt     |    2 +-
 drivers/usb/core/driver.c               |    2 +-
 drivers/usb/core/sysfs.c                |   16 ++++++++++------
 drivers/usb/core/usb.c                  |    2 +-
 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 0000000..00a8432
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -0,0 +1,15 @@
+What:          /sys/bus/usb/devices/.../power/autosuspend
+Date:          March 2007
+KernelVersion: 2.6.21
+Contact:       Alan Stern <[EMAIL PROTECTED]>
+Description:
+               Each USB device directory will contain a file named
+               power/autosuspend.  This file holds the time (in seconds)
+               the device must be idle before it will be autosuspended.
+               0 means the device will be autosuspended as soon as
+               possible.  Negative values will prevent the device from
+               being autosuspended at all, and writing a negative value
+               will resume the device if it is already suspended.
+
+               The autosuspend delay for newly-created devices is set to
+               the value of the usbcore.autosuspend module parameter.
diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 12533a9..2017942 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
                        for newly-detected USB devices (default 2).  This
                        is the time required before an idle device will be
                        autosuspended.  Devices for which the delay is set
-                       to 0 won't be autosuspended at all.
+                       to a negative value won't be autosuspended at all.
 
        usbhid.mousepoll=
                        [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 abea48d..884179f 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 311d5df..731001f 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 138252e..6f35dce 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
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 87dc75a..cc24d08 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -394,7 +394,7 @@ struct usb_device {
        struct delayed_work autosuspend; /* for delayed autosuspends */
        struct mutex pm_mutex;          /* protects PM operations */
 
-       unsigned autosuspend_delay;     /* in jiffies */
+       int autosuspend_delay;          /* in jiffies */
 
        unsigned auto_pm:1;             /* autosuspend/resume in progress */
        unsigned do_remote_wakeup:1;    /* remote wakeup should be enabled */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to