Skip to content

Commit

Permalink
PM / Runtime: Use deferred_resume flag in pm_request_resume
Browse files Browse the repository at this point in the history
This patch (as1307) adds a small optimization to
__pm_request_resume().  If the device is currently being suspended,
there's no need to queue a work routine to resume it.  Setting the
deferred_resume flag will suffice.  (There's also a minor improvement
to the function's code layout: An unnecessary "else" is removed.)

Also, the patch clarifies the usage of the deferred_resume flag.  It
is meaningful only while a suspend is in progress, so it should be
cleared just before a suspend starts, not just after one ends.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Alan Stern authored and Rafael J. Wysocki committed Dec 6, 2009
1 parent 7b199ca commit 63c9480
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq)
}

dev->power.runtime_status = RPM_SUSPENDING;
dev->power.deferred_resume = false;

if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_suspend) {
spin_unlock_irq(&dev->power.lock);
Expand All @@ -200,7 +201,6 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq)
if (retval) {
dev->power.runtime_status = RPM_ACTIVE;
pm_runtime_cancel_pending(dev);
dev->power.deferred_resume = false;

if (retval == -EAGAIN || retval == -EBUSY) {
notify = true;
Expand All @@ -217,7 +217,6 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq)
wake_up_all(&dev->power.wait_queue);

if (dev->power.deferred_resume) {
dev->power.deferred_resume = false;
__pm_runtime_resume(dev, false);
retval = -EAGAIN;
goto out;
Expand Down Expand Up @@ -659,13 +658,17 @@ static int __pm_request_resume(struct device *dev)

pm_runtime_deactivate_timer(dev);

if (dev->power.runtime_status == RPM_SUSPENDING) {
dev->power.deferred_resume = true;
return retval;
}
if (dev->power.request_pending) {
/* If non-resume request is pending, we can overtake it. */
dev->power.request = retval ? RPM_REQ_NONE : RPM_REQ_RESUME;
return retval;
} else if (retval) {
return retval;
}
if (retval)
return retval;

dev->power.request = RPM_REQ_RESUME;
dev->power.request_pending = true;
Expand Down

0 comments on commit 63c9480

Please sign in to comment.