Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: more autosuspend timer stuff

This patch (as879) ties up some loose ends from an earlier patch.
These are things I didn't think to include at the time but which
clearly belonged there.

If an autosuspend fails because driver activity races with
the autosuspend call, restart the autosuspend timer.

When a device is resumed by an external request, it counts
as device activity and should update the last_busy time so
that the next autoresume won't occur immediately.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
ef7f6c70 4fe5354f

+14 -4
+14 -4
drivers/usb/core/driver.c
··· 983 983 984 984 #else 985 985 986 - #define autosuspend_check(udev) 0 986 + static inline int autosuspend_check(struct usb_device *udev) 987 + { 988 + return 0; 989 + } 987 990 988 991 #endif /* CONFIG_USB_SUSPEND */ 989 992 ··· 1044 1041 if (status < 0) 1045 1042 goto done; 1046 1043 } 1047 - cancel_delayed_work(&udev->autosuspend); 1048 1044 1049 1045 /* Suspend all the interfaces and then udev itself */ 1050 1046 if (udev->actconfig) { ··· 1064 1062 usb_resume_interface(intf); 1065 1063 } 1066 1064 1065 + /* Try another autosuspend when the interfaces aren't busy */ 1066 + if (udev->auto_pm) 1067 + autosuspend_check(udev); 1068 + 1067 1069 /* If the suspend succeeded, propagate it up the tree */ 1068 - } else if (parent) 1069 - usb_autosuspend_device(parent); 1070 + } else { 1071 + cancel_delayed_work(&udev->autosuspend); 1072 + if (parent) 1073 + usb_autosuspend_device(parent); 1074 + } 1070 1075 1071 1076 done: 1072 1077 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); ··· 1484 1475 usb_pm_lock(udev); 1485 1476 udev->auto_pm = 0; 1486 1477 status = usb_resume_both(udev); 1478 + udev->last_busy = jiffies; 1487 1479 usb_pm_unlock(udev); 1488 1480 1489 1481 /* Now that the device is awake, we can start trying to autosuspend