Skip to content

Commit

Permalink
USB: fix signed jiffies issue in autosuspend logic
Browse files Browse the repository at this point in the history
This patch (as897) changes the autosuspend timer code to use the
standard types and macros in dealing with jiffies values.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Apr 27, 2007
1 parent ecb658d commit 8c9862e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ static int autosuspend_check(struct usb_device *udev)
{
int i;
struct usb_interface *intf;
long suspend_time;
unsigned long suspend_time;

/* For autosuspend, fail fast if anything is in use or autosuspend
* is disabled. Also fail if any interfaces require remote wakeup
Expand Down Expand Up @@ -964,11 +964,18 @@ static int autosuspend_check(struct usb_device *udev)
/* If everything is okay but the device hasn't been idle for long
* enough, queue a delayed autosuspend request.
*/
suspend_time -= jiffies;
if (suspend_time > 0) {
if (!timer_pending(&udev->autosuspend.timer))
if (time_after(suspend_time, jiffies)) {
if (!timer_pending(&udev->autosuspend.timer)) {

/* The value of jiffies may change between the
* time_after() comparison above and the subtraction
* below. That's okay; the system behaves sanely
* when a timer is registered for the present moment
* or for the past.
*/
queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
suspend_time);
suspend_time - jiffies);
}
return -EAGAIN;
}
return 0;
Expand Down

0 comments on commit 8c9862e

Please sign in to comment.