Re: [PATCH] PM: allow for usage_count > 0 in pm_runtime_get()

Rafael J. Wysocki
2009-12-01T23:01:28Z

On Tuesday 01 December 2009, Alan Stern wrote:
> Rafael:

Hi,

> One other thing I just noticed. The power.timer_expires field is
> supposed to be nonzero when the timer is scheduled. But the code at
> the end of pm_schedule_suspend() doesn't check for the possibility that
> the expiration time might just happen to be 0. If it is, the
> timer_expires value should be bumped up to 1 before the mod_timer()
> call.

Do you mean something like the patch below?

Rafael

---
drivers/base/power/runtime.c | 2 ++
1 file changed, 2 insertions(+)

Index: linux-2.6/drivers/base/power/runtime.c
===================================================================
--- linux-2.6.orig/drivers/base/power/runtime.c
+++ linux-2.6/drivers/base/power/runtime.c
@@ -625,6 +625,8 @@ int pm_schedule_suspend(struct device *d
goto out;

dev->power.timer_expires = jiffies + msecs_to_jiffies(delay);
+ if (!dev->power.timer_expires)
+ dev->power.timer_expires = 1;
mod_timer(&dev->power.suspend_timer, dev->power.timer_expires);