summaryrefslogtreecommitdiff
path: root/kernel/power/suspend.c
diff options
context:
space:
mode:
authorLianwei Wang <lianwei.wang@gmail.com>2016-06-19 23:52:27 -0700
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-28 00:38:55 +0200
commitea00f4f4f00cc2bc3b63ad512a4e6df3b20832b9 (patch)
tree148dbab1f94bc7dd515c6ddda12f85bae310dd4f /kernel/power/suspend.c
parentca5f2b4c4fb7bb7397317ee2ead83485aa295a3e (diff)
PM / sleep: make PM notifiers called symmetrically
This makes pm notifier PREPARE/POST symmetrical: if PREPARE fails, we will only undo what ever happened on PREPARE. It fixes the unbalanced CPU hotplug enable in CPU PM notifier. Signed-off-by: Lianwei Wang <lianwei.wang@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power/suspend.c')
-rw-r--r--kernel/power/suspend.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 5b70d64b871e..0acab9d7f96f 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -266,16 +266,18 @@ static int suspend_test(int level)
*/
static int suspend_prepare(suspend_state_t state)
{
- int error;
+ int error, nr_calls = 0;
if (!sleep_state_supported(state))
return -EPERM;
pm_prepare_console();
- error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
- if (error)
+ error = __pm_notifier_call_chain(PM_SUSPEND_PREPARE, -1, &nr_calls);
+ if (error) {
+ nr_calls--;
goto Finish;
+ }
trace_suspend_resume(TPS("freeze_processes"), 0, true);
error = suspend_freeze_processes();
@@ -286,7 +288,7 @@ static int suspend_prepare(suspend_state_t state)
suspend_stats.failed_freeze++;
dpm_save_failed_step(SUSPEND_FREEZE);
Finish:
- pm_notifier_call_chain(PM_POST_SUSPEND);
+ __pm_notifier_call_chain(PM_POST_SUSPEND, nr_calls, NULL);
pm_restore_console();
return error;
}