From 1e75227ef0571031cd18536ab768ee35667ec5b9 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 3 Dec 2010 22:58:05 +0100 Subject: 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 --- drivers/base/power/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ead3e79d6fc..4747a1e8b44 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "../base.h" #include "power.h" @@ -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 { @@ -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; -- cgit v1.2.3-70-g09d2