aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/driver.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 631f30582481..b9f7f90aef82 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -932,7 +932,7 @@ static int autosuspend_check(struct usb_device *udev)
932{ 932{
933 int i; 933 int i;
934 struct usb_interface *intf; 934 struct usb_interface *intf;
935 long suspend_time; 935 unsigned long suspend_time;
936 936
937 /* For autosuspend, fail fast if anything is in use or autosuspend 937 /* For autosuspend, fail fast if anything is in use or autosuspend
938 * is disabled. Also fail if any interfaces require remote wakeup 938 * is disabled. Also fail if any interfaces require remote wakeup
@@ -964,11 +964,18 @@ static int autosuspend_check(struct usb_device *udev)
964 /* If everything is okay but the device hasn't been idle for long 964 /* If everything is okay but the device hasn't been idle for long
965 * enough, queue a delayed autosuspend request. 965 * enough, queue a delayed autosuspend request.
966 */ 966 */
967 suspend_time -= jiffies; 967 if (time_after(suspend_time, jiffies)) {
968 if (suspend_time > 0) { 968 if (!timer_pending(&udev->autosuspend.timer)) {
969 if (!timer_pending(&udev->autosuspend.timer)) 969
970 /* The value of jiffies may change between the
971 * time_after() comparison above and the subtraction
972 * below. That's okay; the system behaves sanely
973 * when a timer is registered for the present moment
974 * or for the past.
975 */
970 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, 976 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
971 suspend_time); 977 suspend_time - jiffies);
978 }
972 return -EAGAIN; 979 return -EAGAIN;
973 } 980 }
974 return 0; 981 return 0;