aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-07-01 18:14:09 -0400
committerLen Brown <len.brown@intel.com>2010-07-06 22:14:19 -0400
commitc5f7a1bb65bca03253c189e946b3ca79669f08af (patch)
treeb8a85641a64c0c6b28376ac33eb21aa63de592b2
parent78f5f023167813130d2cf657d1b9eadc32f0e992 (diff)
ACPI / Sleep: Consolidate suspend and hibernation routines
Some hibernation and suspend routines can be merged, which reduces the complexity of code a bit. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/sleep.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 93441c95c53b..61c5bd03f733 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -105,6 +105,16 @@ static int acpi_pm_freeze(void)
105} 105}
106 106
107/** 107/**
108 * acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS.
109 */
110static int acpi_pm_pre_suspend(void)
111{
112 acpi_pm_freeze();
113 suspend_nvs_save();
114 return 0;
115}
116
117/**
108 * __acpi_pm_prepare - Prepare the platform to enter the target state. 118 * __acpi_pm_prepare - Prepare the platform to enter the target state.
109 * 119 *
110 * If necessary, set the firmware waking vector and do arch-specific 120 * If necessary, set the firmware waking vector and do arch-specific
@@ -113,11 +123,9 @@ static int acpi_pm_freeze(void)
113static int __acpi_pm_prepare(void) 123static int __acpi_pm_prepare(void)
114{ 124{
115 int error = acpi_sleep_prepare(acpi_target_sleep_state); 125 int error = acpi_sleep_prepare(acpi_target_sleep_state);
116
117 suspend_nvs_save();
118
119 if (error) 126 if (error)
120 acpi_target_sleep_state = ACPI_STATE_S0; 127 acpi_target_sleep_state = ACPI_STATE_S0;
128
121 return error; 129 return error;
122} 130}
123 131
@@ -128,9 +136,8 @@ static int __acpi_pm_prepare(void)
128static int acpi_pm_prepare(void) 136static int acpi_pm_prepare(void)
129{ 137{
130 int error = __acpi_pm_prepare(); 138 int error = __acpi_pm_prepare();
131
132 if (!error) 139 if (!error)
133 acpi_pm_freeze(); 140 acpi_pm_pre_suspend();
134 141
135 return error; 142 return error;
136} 143}
@@ -322,9 +329,9 @@ static struct platform_suspend_ops acpi_suspend_ops = {
322static int acpi_suspend_begin_old(suspend_state_t pm_state) 329static int acpi_suspend_begin_old(suspend_state_t pm_state)
323{ 330{
324 int error = acpi_suspend_begin(pm_state); 331 int error = acpi_suspend_begin(pm_state);
325
326 if (!error) 332 if (!error)
327 error = __acpi_pm_prepare(); 333 error = __acpi_pm_prepare();
334
328 return error; 335 return error;
329} 336}
330 337
@@ -335,7 +342,7 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
335static struct platform_suspend_ops acpi_suspend_ops_old = { 342static struct platform_suspend_ops acpi_suspend_ops_old = {
336 .valid = acpi_suspend_state_valid, 343 .valid = acpi_suspend_state_valid,
337 .begin = acpi_suspend_begin_old, 344 .begin = acpi_suspend_begin_old,
338 .prepare_late = acpi_pm_freeze, 345 .prepare_late = acpi_pm_pre_suspend,
339 .enter = acpi_suspend_enter, 346 .enter = acpi_suspend_enter,
340 .wake = acpi_suspend_finish, 347 .wake = acpi_suspend_finish,
341 .end = acpi_pm_end, 348 .end = acpi_pm_end,
@@ -423,16 +430,6 @@ static int acpi_hibernation_begin(void)
423 return error; 430 return error;
424} 431}
425 432
426static int acpi_hibernation_pre_snapshot(void)
427{
428 int error = acpi_pm_prepare();
429
430 if (!error)
431 suspend_nvs_save();
432
433 return error;
434}
435
436static int acpi_hibernation_enter(void) 433static int acpi_hibernation_enter(void)
437{ 434{
438 acpi_status status = AE_OK; 435 acpi_status status = AE_OK;
@@ -480,7 +477,7 @@ static void acpi_pm_thaw(void)
480static struct platform_hibernation_ops acpi_hibernation_ops = { 477static struct platform_hibernation_ops acpi_hibernation_ops = {
481 .begin = acpi_hibernation_begin, 478 .begin = acpi_hibernation_begin,
482 .end = acpi_pm_end, 479 .end = acpi_pm_end,
483 .pre_snapshot = acpi_hibernation_pre_snapshot, 480 .pre_snapshot = acpi_pm_prepare,
484 .finish = acpi_pm_finish, 481 .finish = acpi_pm_finish,
485 .prepare = acpi_pm_prepare, 482 .prepare = acpi_pm_prepare,
486 .enter = acpi_hibernation_enter, 483 .enter = acpi_hibernation_enter,
@@ -516,13 +513,6 @@ static int acpi_hibernation_begin_old(void)
516 return error; 513 return error;
517} 514}
518 515
519static int acpi_hibernation_pre_snapshot_old(void)
520{
521 acpi_pm_freeze();
522 suspend_nvs_save();
523 return 0;
524}
525
526/* 516/*
527 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has 517 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
528 * been requested. 518 * been requested.
@@ -530,7 +520,7 @@ static int acpi_hibernation_pre_snapshot_old(void)
530static struct platform_hibernation_ops acpi_hibernation_ops_old = { 520static struct platform_hibernation_ops acpi_hibernation_ops_old = {
531 .begin = acpi_hibernation_begin_old, 521 .begin = acpi_hibernation_begin_old,
532 .end = acpi_pm_end, 522 .end = acpi_pm_end,
533 .pre_snapshot = acpi_hibernation_pre_snapshot_old, 523 .pre_snapshot = acpi_pm_pre_suspend,
534 .prepare = acpi_pm_freeze, 524 .prepare = acpi_pm_freeze,
535 .finish = acpi_pm_finish, 525 .finish = acpi_pm_finish,
536 .enter = acpi_hibernation_enter, 526 .enter = acpi_hibernation_enter,