From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
linux-pm@lists.linux-foundation.org
Subject: [PATCH 4/5] ACPI / Sleep: Consolidate suspend and hibernation routines
Date: Fri, 2 Jul 2010 00:14:09 +0200 [thread overview]
Message-ID: <201007020014.09639.rjw__45965.830985415$1278022669$gmane$org@sisk.pl> (raw)
In-Reply-To: <201007020010.13755.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
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>
---
drivers/acpi/sleep.c | 42 ++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)
Index: linux-2.6/drivers/acpi/sleep.c
===================================================================
--- linux-2.6.orig/drivers/acpi/sleep.c
+++ linux-2.6/drivers/acpi/sleep.c
@@ -105,6 +105,16 @@ static int acpi_pm_freeze(void)
}
/**
+ * acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS.
+ */
+static int acpi_pm_pre_suspend(void)
+{
+ acpi_pm_freeze();
+ suspend_nvs_save();
+ return 0;
+}
+
+/**
* __acpi_pm_prepare - Prepare the platform to enter the target state.
*
* If necessary, set the firmware waking vector and do arch-specific
@@ -113,11 +123,9 @@ static int acpi_pm_freeze(void)
static int __acpi_pm_prepare(void)
{
int error = acpi_sleep_prepare(acpi_target_sleep_state);
-
- suspend_nvs_save();
-
if (error)
acpi_target_sleep_state = ACPI_STATE_S0;
+
return error;
}
@@ -128,9 +136,8 @@ static int __acpi_pm_prepare(void)
static int acpi_pm_prepare(void)
{
int error = __acpi_pm_prepare();
-
if (!error)
- acpi_pm_freeze();
+ acpi_pm_pre_suspend();
return error;
}
@@ -317,9 +324,9 @@ static struct platform_suspend_ops acpi_
static int acpi_suspend_begin_old(suspend_state_t pm_state)
{
int error = acpi_suspend_begin(pm_state);
-
if (!error)
error = __acpi_pm_prepare();
+
return error;
}
@@ -330,7 +337,7 @@ static int acpi_suspend_begin_old(suspen
static struct platform_suspend_ops acpi_suspend_ops_old = {
.valid = acpi_suspend_state_valid,
.begin = acpi_suspend_begin_old,
- .prepare_late = acpi_pm_freeze,
+ .prepare_late = acpi_pm_pre_suspend,
.enter = acpi_suspend_enter,
.wake = acpi_suspend_finish,
.end = acpi_pm_end,
@@ -418,16 +425,6 @@ static int acpi_hibernation_begin(void)
return error;
}
-static int acpi_hibernation_pre_snapshot(void)
-{
- int error = acpi_pm_prepare();
-
- if (!error)
- suspend_nvs_save();
-
- return error;
-}
-
static int acpi_hibernation_enter(void)
{
acpi_status status = AE_OK;
@@ -475,7 +472,7 @@ static void acpi_pm_thaw(void)
static struct platform_hibernation_ops acpi_hibernation_ops = {
.begin = acpi_hibernation_begin,
.end = acpi_pm_end,
- .pre_snapshot = acpi_hibernation_pre_snapshot,
+ .pre_snapshot = acpi_pm_prepare,
.finish = acpi_pm_finish,
.prepare = acpi_pm_prepare,
.enter = acpi_hibernation_enter,
@@ -511,13 +508,6 @@ static int acpi_hibernation_begin_old(vo
return error;
}
-static int acpi_hibernation_pre_snapshot_old(void)
-{
- acpi_pm_freeze();
- suspend_nvs_save();
- return 0;
-}
-
/*
* The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
* been requested.
@@ -525,7 +515,7 @@ static int acpi_hibernation_pre_snapshot
static struct platform_hibernation_ops acpi_hibernation_ops_old = {
.begin = acpi_hibernation_begin_old,
.end = acpi_pm_end,
- .pre_snapshot = acpi_hibernation_pre_snapshot_old,
+ .pre_snapshot = acpi_pm_pre_suspend,
.prepare = acpi_pm_freeze,
.finish = acpi_pm_finish,
.enter = acpi_hibernation_enter,
next prev parent reply other threads:[~2010-07-01 22:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 22:10 [PATCH 0/5] ACPI / PM: Fixes and simplifications Rafael J. Wysocki
2010-07-01 22:11 ` [PATCH 1/5] ACPI / Sleep: Do not allocate memory for saving NVS in advance Rafael J. Wysocki
2010-07-06 18:12 ` [linux-pm] " Rafael J. Wysocki
2010-07-06 18:12 ` Rafael J. Wysocki
2010-07-07 2:16 ` Len Brown
2010-07-07 2:16 ` Len Brown
2010-07-01 22:11 ` Rafael J. Wysocki
2010-07-01 22:12 ` [PATCH 2/5] ACPI / Sleep: Rework enabling wakeup devices Rafael J. Wysocki
2010-07-01 22:12 ` Rafael J. Wysocki
2010-07-07 2:16 ` Len Brown
2010-07-07 2:16 ` Len Brown
2010-07-01 22:13 ` [PATCH 3/5] ACPI / Wakeup: Simplify enabling of " Rafael J. Wysocki
2010-07-06 23:17 ` Rafael J. Wysocki
2010-07-06 23:17 ` [linux-pm] " Rafael J. Wysocki
2010-07-07 2:13 ` Len Brown
2010-07-07 2:13 ` [linux-pm] " Len Brown
2010-07-01 22:13 ` Rafael J. Wysocki
2010-07-01 22:14 ` [PATCH 4/5] ACPI / Sleep: Consolidate suspend and hibernation routines Rafael J. Wysocki
2010-07-07 2:14 ` Len Brown
2010-07-07 2:14 ` Len Brown
2010-07-01 22:14 ` Rafael J. Wysocki [this message]
2010-07-01 22:14 ` [PATCH 5/5] ACPI / Sleep: Drop acpi_suspend_finish() Rafael J. Wysocki
2010-07-07 2:14 ` Len Brown
2010-07-01 22:14 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='201007020014.09639.rjw__45965.830985415$1278022669$gmane$org@sisk.pl' \
--to=rjw@sisk.pl \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.