PM: Prevent dpm_prepare() from returning errors unnecessarily

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>
This commit is contained in:
Rafael J. Wysocki 2010-12-03 22:58:05 +01:00
parent 7ac4dcabdb
commit 1e75227ef0

View File

@ -26,6 +26,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/async.h> #include <linux/async.h>
#include <linux/suspend.h>
#include "../base.h" #include "../base.h"
#include "power.h" #include "power.h"
@ -1052,8 +1053,10 @@ static int dpm_prepare(pm_message_t state)
mutex_unlock(&dpm_list_mtx); mutex_unlock(&dpm_list_mtx);
pm_runtime_get_noresume(dev); pm_runtime_get_noresume(dev);
if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) { if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
/* Wake-up requested during system sleep transition. */ pm_wakeup_event(dev, 0);
if (!pm_check_wakeup_events()) {
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
error = -EBUSY; error = -EBUSY;
} else { } else {
@ -1068,8 +1071,8 @@ static int dpm_prepare(pm_message_t state)
error = 0; error = 0;
continue; continue;
} }
printk(KERN_ERR "PM: Failed to prepare device %s " printk(KERN_INFO "PM: Device %s not prepared "
"for power transition: error %d\n", "for power transition: code %d\n",
kobject_name(&dev->kobj), error); kobject_name(&dev->kobj), error);
put_device(dev); put_device(dev);
break; break;