mirror of
https://github.com/torvalds/linux.git
synced 2024-12-02 09:01:34 +00:00
USB: update last_busy field correctly
This patch (as966) fixes a bug in the autosuspend code. The last_busy field should be updated whenever any event occurs, not just events that cause an autosuspend or an autoresume. This partially fixes Bugzilla #8892. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
85237f202d
commit
013d27f265
@ -1224,6 +1224,8 @@ static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
|
||||
udev->auto_pm = 1;
|
||||
udev->pm_usage_cnt += inc_usage_cnt;
|
||||
WARN_ON(udev->pm_usage_cnt < 0);
|
||||
if (inc_usage_cnt)
|
||||
udev->last_busy = jiffies;
|
||||
if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
|
||||
if (udev->state == USB_STATE_SUSPENDED)
|
||||
status = usb_resume_both(udev);
|
||||
@ -1232,8 +1234,6 @@ static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
|
||||
else if (inc_usage_cnt)
|
||||
udev->last_busy = jiffies;
|
||||
} else if (inc_usage_cnt <= 0 && udev->pm_usage_cnt <= 0) {
|
||||
if (inc_usage_cnt)
|
||||
udev->last_busy = jiffies;
|
||||
status = usb_suspend_both(udev, PMSG_SUSPEND);
|
||||
}
|
||||
usb_pm_unlock(udev);
|
||||
@ -1342,16 +1342,15 @@ static int usb_autopm_do_interface(struct usb_interface *intf,
|
||||
else {
|
||||
udev->auto_pm = 1;
|
||||
intf->pm_usage_cnt += inc_usage_cnt;
|
||||
udev->last_busy = jiffies;
|
||||
if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) {
|
||||
if (udev->state == USB_STATE_SUSPENDED)
|
||||
status = usb_resume_both(udev);
|
||||
if (status != 0)
|
||||
intf->pm_usage_cnt -= inc_usage_cnt;
|
||||
else if (inc_usage_cnt)
|
||||
else
|
||||
udev->last_busy = jiffies;
|
||||
} else if (inc_usage_cnt <= 0 && intf->pm_usage_cnt <= 0) {
|
||||
if (inc_usage_cnt)
|
||||
udev->last_busy = jiffies;
|
||||
status = usb_suspend_both(udev, PMSG_SUSPEND);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user