]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - kernel/power/hibernate.c
Merge branch 'x86-txt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / kernel / power / hibernate.c
index 81d2e746489311473bb86a5428bdc16381c95fc1..04b3a83d686f63e430723e2a3e26a1fc3d3e0601 100644 (file)
@@ -298,8 +298,8 @@ int hibernation_snapshot(int platform_mode)
        if (error)
                return error;
 
-       /* Free memory before shutting down devices. */
-       error = swsusp_shrink_memory();
+       /* Preallocate image memory before shutting down devices. */
+       error = hibernate_preallocate_memory();
        if (error)
                goto Close;
 
@@ -315,6 +315,10 @@ int hibernation_snapshot(int platform_mode)
        /* Control returns here after successful restore */
 
  Resume_devices:
+       /* We may need to release the preallocated image pages here. */
+       if (error || !in_suspend)
+               swsusp_free();
+
        dpm_resume_end(in_suspend ?
                (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
        resume_console();
@@ -460,11 +464,11 @@ int hibernation_platform_enter(void)
 
        error = hibernation_ops->prepare();
        if (error)
-               goto Platofrm_finish;
+               goto Platform_finish;
 
        error = disable_nonboot_cpus();
        if (error)
-               goto Platofrm_finish;
+               goto Platform_finish;
 
        local_irq_disable();
        sysdev_suspend(PMSG_HIBERNATE);
@@ -476,7 +480,7 @@ int hibernation_platform_enter(void)
         * We don't need to reenable the nonboot CPUs or resume consoles, since
         * the system is going to be halted anyway.
         */
- Platofrm_finish:
+ Platform_finish:
        hibernation_ops->finish();
 
        dpm_suspend_noirq(PMSG_RESTORE);
@@ -578,7 +582,10 @@ int hibernate(void)
                goto Thaw;
 
        error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
-       if (in_suspend && !error) {
+       if (error)
+               goto Thaw;
+
+       if (in_suspend) {
                unsigned int flags = 0;
 
                if (hibernation_mode == HIBERNATION_PLATFORM)
@@ -590,8 +597,8 @@ int hibernate(void)
                        power_down();
        } else {
                pr_debug("PM: Image restored successfully.\n");
-               swsusp_free();
        }
+
  Thaw:
        thaw_processes();
  Finish: