aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2008-01-07 18:04:17 -0500
committerLen Brown <len.brown@intel.com>2008-02-01 18:30:56 -0500
commitc697eecebc6cfc0b393afea3c4ff1a5041526ad1 (patch)
tree36b0cb4e667792212c2b5d05ac212662555d1682 /drivers/acpi/sleep
parent7671b8ae5381a504d4c4ef8dd9c47128c2c3fd7e (diff)
Suspend: Introduce begin() and end() callbacks
On ACPI systems the target state set by acpi_pm_set_target() is reset by acpi_pm_finish(), but that need not be called if the suspend fails.  All platforms that use the .set_target() global suspend callback are affected by analogous issues. For this reason, we need an additional global suspend callback that will reset the target state regardless of whether or not the suspend is successful.  Also, it is reasonable to rename the .set_target() callback, since it will be used for a different purpose on ACPI systems (due to ACPI 1.0x code ordering requirements). Introduce the global suspend callback .end() to be executed at the end of the suspend sequence and rename the .set_target() global suspend callback to .begin(). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sleep')
-rw-r--r--drivers/acpi/sleep/main.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 96d23b3cfc4e..e2e4e617952b 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -63,11 +63,11 @@ static u32 acpi_suspend_states[] = {
63static int init_8259A_after_S1; 63static int init_8259A_after_S1;
64 64
65/** 65/**
66 * acpi_pm_set_target - Set the target system sleep state to the state 66 * acpi_pm_begin - Set the target system sleep state to the state
67 * associated with given @pm_state, if supported. 67 * associated with given @pm_state, if supported.
68 */ 68 */
69 69
70static int acpi_pm_set_target(suspend_state_t pm_state) 70static int acpi_pm_begin(suspend_state_t pm_state)
71{ 71{
72 u32 acpi_state = acpi_suspend_states[pm_state]; 72 u32 acpi_state = acpi_suspend_states[pm_state];
73 int error = 0; 73 int error = 0;
@@ -164,7 +164,7 @@ static int acpi_pm_enter(suspend_state_t pm_state)
164} 164}
165 165
166/** 166/**
167 * acpi_pm_finish - Finish up suspend sequence. 167 * acpi_pm_finish - Instruct the platform to leave a sleep state.
168 * 168 *
169 * This is called after we wake back up (or if entering the sleep state 169 * This is called after we wake back up (or if entering the sleep state
170 * failed). 170 * failed).
@@ -190,6 +190,19 @@ static void acpi_pm_finish(void)
190#endif 190#endif
191} 191}
192 192
193/**
194 * acpi_pm_end - Finish up suspend sequence.
195 */
196
197static void acpi_pm_end(void)
198{
199 /*
200 * This is necessary in case acpi_pm_finish() is not called during a
201 * failing transition to a sleep state.
202 */
203 acpi_target_sleep_state = ACPI_STATE_S0;
204}
205
193static int acpi_pm_state_valid(suspend_state_t pm_state) 206static int acpi_pm_state_valid(suspend_state_t pm_state)
194{ 207{
195 u32 acpi_state; 208 u32 acpi_state;
@@ -208,10 +221,11 @@ static int acpi_pm_state_valid(suspend_state_t pm_state)
208 221
209static struct platform_suspend_ops acpi_pm_ops = { 222static struct platform_suspend_ops acpi_pm_ops = {
210 .valid = acpi_pm_state_valid, 223 .valid = acpi_pm_state_valid,
211 .set_target = acpi_pm_set_target, 224 .begin = acpi_pm_begin,
212 .prepare = acpi_pm_prepare, 225 .prepare = acpi_pm_prepare,
213 .enter = acpi_pm_enter, 226 .enter = acpi_pm_enter,
214 .finish = acpi_pm_finish, 227 .finish = acpi_pm_finish,
228 .end = acpi_pm_end,
215}; 229};
216 230
217/* 231/*