]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/power/disk.c
Hibernation: Invoke suspend notifications after console switch
[linux-2.6-omap-h63xx.git] / kernel / power / disk.c
index 64e42ab8b57c3008e5d1f1574557eef3667939d7..d09da08951748ce357a06462a6be60da3045a727 100644 (file)
@@ -54,8 +54,8 @@ static struct platform_hibernation_ops *hibernation_ops;
 
 void hibernation_set_ops(struct platform_hibernation_ops *ops)
 {
-       if (ops && !(ops->start && ops->pre_snapshot && ops->finish
-           && ops->prepare && ops->enter && ops->pre_restore
+       if (ops && !(ops->begin && ops->end &&  ops->pre_snapshot
+           && ops->prepare && ops->finish && ops->enter && ops->pre_restore
            && ops->restore_cleanup)) {
                WARN_ON(1);
                return;
@@ -100,14 +100,25 @@ static int hibernation_test(int level) { return 0; }
 #endif /* !CONFIG_PM_DEBUG */
 
 /**
- *     platform_start - tell the platform driver that we're starting
+ *     platform_begin - tell the platform driver that we're starting
  *     hibernation
  */
 
-static int platform_start(int platform_mode)
+static int platform_begin(int platform_mode)
 {
        return (platform_mode && hibernation_ops) ?
-               hibernation_ops->start() : 0;
+               hibernation_ops->begin() : 0;
+}
+
+/**
+ *     platform_end - tell the platform driver that we've entered the
+ *     working state
+ */
+
+static void platform_end(int platform_mode)
+{
+       if (platform_mode && hibernation_ops)
+               hibernation_ops->end();
 }
 
 /**
@@ -237,9 +248,9 @@ int hibernation_snapshot(int platform_mode)
        if (error)
                return error;
 
-       error = platform_start(platform_mode);
+       error = platform_begin(platform_mode);
        if (error)
-               return error;
+               goto Close;
 
        suspend_console();
        error = device_suspend(PMSG_FREEZE);
@@ -272,6 +283,8 @@ int hibernation_snapshot(int platform_mode)
        device_resume();
  Resume_console:
        resume_console();
+ Close:
+       platform_end(platform_mode);
        return error;
 }
 
@@ -373,9 +386,9 @@ int hibernation_platform_enter(void)
         * hibernation_ops->finish() before saving the image, so we should let
         * the firmware know that we're going to enter the sleep state after all
         */
-       error = hibernation_ops->start();
+       error = hibernation_ops->begin();
        if (error)
-               return error;
+               goto Close;
 
        suspend_console();
        error = device_suspend(PMSG_SUSPEND);
@@ -409,6 +422,8 @@ int hibernation_platform_enter(void)
        device_resume();
  Resume_console:
        resume_console();
+ Close:
+       hibernation_ops->end();
        return error;
 }
 
@@ -443,20 +458,13 @@ static void power_down(void)
        while(1);
 }
 
-static void unprepare_processes(void)
-{
-       thaw_processes();
-       pm_restore_console();
-}
-
 static int prepare_processes(void)
 {
        int error = 0;
 
-       pm_prepare_console();
        if (freeze_processes()) {
                error = -EBUSY;
-               unprepare_processes();
+               thaw_processes();
        }
        return error;
 }
@@ -476,6 +484,7 @@ int hibernate(void)
                goto Unlock;
        }
 
+       pm_prepare_console();
        error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
        if (error)
                goto Exit;
@@ -515,11 +524,12 @@ int hibernate(void)
                swsusp_free();
        }
  Thaw:
-       unprepare_processes();
+       thaw_processes();
  Finish:
        free_basic_memory_bitmaps();
  Exit:
        pm_notifier_call_chain(PM_POST_HIBERNATION);
+       pm_restore_console();
        atomic_inc(&snapshot_device_available);
  Unlock:
        mutex_unlock(&pm_mutex);
@@ -588,6 +598,7 @@ static int software_resume(void)
                goto Unlock;
        }
 
+       pm_prepare_console();
        error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
        if (error)
                goto Finish;
@@ -611,11 +622,12 @@ static int software_resume(void)
 
        printk(KERN_ERR "PM: Restore failed, recovering.\n");
        swsusp_free();
-       unprepare_processes();
+       thaw_processes();
  Done:
        free_basic_memory_bitmaps();
  Finish:
        pm_notifier_call_chain(PM_POST_RESTORE);
+       pm_restore_console();
        atomic_inc(&snapshot_device_available);
        /* For success case, the suspend path will release the lock */
  Unlock: