diff options
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r-- | kernel/power/main.c | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index b4d219016b6..f172f41858b 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -287,25 +287,55 @@ void __attribute__ ((weak)) arch_suspend_enable_irqs(void) | |||
287 | */ | 287 | */ |
288 | static int suspend_enter(suspend_state_t state) | 288 | static int suspend_enter(suspend_state_t state) |
289 | { | 289 | { |
290 | int error = 0; | 290 | int error; |
291 | 291 | ||
292 | device_pm_lock(); | 292 | device_pm_lock(); |
293 | arch_suspend_disable_irqs(); | ||
294 | BUG_ON(!irqs_disabled()); | ||
295 | 293 | ||
296 | if ((error = device_power_down(PMSG_SUSPEND))) { | 294 | error = device_power_down(PMSG_SUSPEND); |
295 | if (error) { | ||
297 | printk(KERN_ERR "PM: Some devices failed to power down\n"); | 296 | printk(KERN_ERR "PM: Some devices failed to power down\n"); |
298 | goto Done; | 297 | goto Done; |
299 | } | 298 | } |
300 | 299 | ||
301 | if (!suspend_test(TEST_CORE)) | 300 | if (suspend_ops->prepare) { |
302 | error = suspend_ops->enter(state); | 301 | error = suspend_ops->prepare(); |
302 | if (error) | ||
303 | goto Power_up_devices; | ||
304 | } | ||
305 | |||
306 | if (suspend_test(TEST_PLATFORM)) | ||
307 | goto Platfrom_finish; | ||
308 | |||
309 | error = disable_nonboot_cpus(); | ||
310 | if (error || suspend_test(TEST_CPUS)) | ||
311 | goto Enable_cpus; | ||
312 | |||
313 | arch_suspend_disable_irqs(); | ||
314 | BUG_ON(!irqs_disabled()); | ||
315 | |||
316 | error = sysdev_suspend(PMSG_SUSPEND); | ||
317 | if (!error) { | ||
318 | if (!suspend_test(TEST_CORE)) | ||
319 | error = suspend_ops->enter(state); | ||
320 | sysdev_resume(); | ||
321 | } | ||
303 | 322 | ||
304 | device_power_up(PMSG_RESUME); | ||
305 | Done: | ||
306 | arch_suspend_enable_irqs(); | 323 | arch_suspend_enable_irqs(); |
307 | BUG_ON(irqs_disabled()); | 324 | BUG_ON(irqs_disabled()); |
325 | |||
326 | Enable_cpus: | ||
327 | enable_nonboot_cpus(); | ||
328 | |||
329 | Platfrom_finish: | ||
330 | if (suspend_ops->finish) | ||
331 | suspend_ops->finish(); | ||
332 | |||
333 | Power_up_devices: | ||
334 | device_power_up(PMSG_RESUME); | ||
335 | |||
336 | Done: | ||
308 | device_pm_unlock(); | 337 | device_pm_unlock(); |
338 | |||
309 | return error; | 339 | return error; |
310 | } | 340 | } |
311 | 341 | ||
@@ -337,23 +367,8 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
337 | if (suspend_test(TEST_DEVICES)) | 367 | if (suspend_test(TEST_DEVICES)) |
338 | goto Recover_platform; | 368 | goto Recover_platform; |
339 | 369 | ||
340 | if (suspend_ops->prepare) { | 370 | suspend_enter(state); |
341 | error = suspend_ops->prepare(); | ||
342 | if (error) | ||
343 | goto Resume_devices; | ||
344 | } | ||
345 | |||
346 | if (suspend_test(TEST_PLATFORM)) | ||
347 | goto Finish; | ||
348 | |||
349 | error = disable_nonboot_cpus(); | ||
350 | if (!error && !suspend_test(TEST_CPUS)) | ||
351 | suspend_enter(state); | ||
352 | 371 | ||
353 | enable_nonboot_cpus(); | ||
354 | Finish: | ||
355 | if (suspend_ops->finish) | ||
356 | suspend_ops->finish(); | ||
357 | Resume_devices: | 372 | Resume_devices: |
358 | suspend_test_start(); | 373 | suspend_test_start(); |
359 | device_resume(PMSG_RESUME); | 374 | device_resume(PMSG_RESUME); |