aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/hibernate.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/power/hibernate.c')
-rw-r--r--kernel/power/hibernate.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index b4511b6d3ef9..a6b0503574ee 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -55,6 +55,8 @@ enum {
55 55
56static int hibernation_mode = HIBERNATION_SHUTDOWN; 56static int hibernation_mode = HIBERNATION_SHUTDOWN;
57 57
58static bool freezer_test_done;
59
58static const struct platform_hibernation_ops *hibernation_ops; 60static const struct platform_hibernation_ops *hibernation_ops;
59 61
60/** 62/**
@@ -345,11 +347,24 @@ int hibernation_snapshot(int platform_mode)
345 347
346 error = freeze_kernel_threads(); 348 error = freeze_kernel_threads();
347 if (error) 349 if (error)
348 goto Close; 350 goto Cleanup;
351
352 if (hibernation_test(TEST_FREEZER) ||
353 hibernation_testmode(HIBERNATION_TESTPROC)) {
354
355 /*
356 * Indicate to the caller that we are returning due to a
357 * successful freezer test.
358 */
359 freezer_test_done = true;
360 goto Cleanup;
361 }
349 362
350 error = dpm_prepare(PMSG_FREEZE); 363 error = dpm_prepare(PMSG_FREEZE);
351 if (error) 364 if (error) {
352 goto Complete_devices; 365 dpm_complete(msg);
366 goto Cleanup;
367 }
353 368
354 suspend_console(); 369 suspend_console();
355 pm_restrict_gfp_mask(); 370 pm_restrict_gfp_mask();
@@ -378,8 +393,6 @@ int hibernation_snapshot(int platform_mode)
378 pm_restore_gfp_mask(); 393 pm_restore_gfp_mask();
379 394
380 resume_console(); 395 resume_console();
381
382 Complete_devices:
383 dpm_complete(msg); 396 dpm_complete(msg);
384 397
385 Close: 398 Close:
@@ -389,6 +402,10 @@ int hibernation_snapshot(int platform_mode)
389 Recover_platform: 402 Recover_platform:
390 platform_recover(platform_mode); 403 platform_recover(platform_mode);
391 goto Resume_devices; 404 goto Resume_devices;
405
406 Cleanup:
407 swsusp_free();
408 goto Close;
392} 409}
393 410
394/** 411/**
@@ -641,15 +658,13 @@ int hibernate(void)
641 if (error) 658 if (error)
642 goto Finish; 659 goto Finish;
643 660
644 if (hibernation_test(TEST_FREEZER))
645 goto Thaw;
646
647 if (hibernation_testmode(HIBERNATION_TESTPROC))
648 goto Thaw;
649
650 error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM); 661 error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
651 if (error) 662 if (error)
652 goto Thaw; 663 goto Thaw;
664 if (freezer_test_done) {
665 freezer_test_done = false;
666 goto Thaw;
667 }
653 668
654 if (in_suspend) { 669 if (in_suspend) {
655 unsigned int flags = 0; 670 unsigned int flags = 0;