Skip to content

Commit

Permalink
PM: Prevent dpm_prepare() from returning errors unnecessarily
Browse files Browse the repository at this point in the history
Currently dpm_prepare() returns error code if it finds that a device
being suspended has a pending runtime resume request.  However, it
should not do that if the checking for wakeup events is not enabled.
On the other hand, if the checking for wakeup events is enabled, it
can return error when a wakeup event is detected, regardless of its
source.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Rafael J. Wysocki committed Dec 24, 2010
1 parent 7ac4dca commit 1e75227
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/async.h>
#include <linux/suspend.h>

#include "../base.h"
#include "power.h"
Expand Down Expand Up @@ -1052,8 +1053,10 @@ static int dpm_prepare(pm_message_t state)
mutex_unlock(&dpm_list_mtx);

pm_runtime_get_noresume(dev);
if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) {
/* Wake-up requested during system sleep transition. */
if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
pm_wakeup_event(dev, 0);

if (!pm_check_wakeup_events()) {
pm_runtime_put_sync(dev);
error = -EBUSY;
} else {
Expand All @@ -1068,8 +1071,8 @@ static int dpm_prepare(pm_message_t state)
error = 0;
continue;
}
printk(KERN_ERR "PM: Failed to prepare device %s "
"for power transition: error %d\n",
printk(KERN_INFO "PM: Device %s not prepared "
"for power transition: code %d\n",
kobject_name(&dev->kobj), error);
put_device(dev);
break;
Expand Down

0 comments on commit 1e75227

Please sign in to comment.