Skip to content

Commit

Permalink
PM: allow for usage_count > 0 in pm_runtime_get()
Browse files Browse the repository at this point in the history
This patch (as1308c) fixes __pm_runtime_get().  Currently the routine
will resume a device if the prior usage count was 0.  But this isn't
right; thanks to pm_runtime_get_noresume() the usage count can be
positive even while the device is suspended.

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 15, 2009
1 parent 8bea867 commit 1d531c1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,15 +701,15 @@ EXPORT_SYMBOL_GPL(pm_request_resume);
* @dev: Device to handle.
* @sync: If set and the device is suspended, resume it synchronously.
*
* Increment the usage count of the device and if it was zero previously,
* resume it or submit a resume request for it, depending on the value of @sync.
* Increment the usage count of the device and resume it or submit a resume
* request for it, depending on the value of @sync.
*/
int __pm_runtime_get(struct device *dev, bool sync)
{
int retval = 1;
int retval;

if (atomic_add_return(1, &dev->power.usage_count) == 1)
retval = sync ? pm_runtime_resume(dev) : pm_request_resume(dev);
atomic_inc(&dev->power.usage_count);
retval = sync ? pm_runtime_resume(dev) : pm_request_resume(dev);

return retval;
}
Expand Down

0 comments on commit 1d531c1

Please sign in to comment.