Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 013d27f2 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 85237f20
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -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);
		}
	}