PM / Hibernate: Refactor and simplify freezer_test_done
authorSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Sat, 4 Feb 2012 22:39:56 +0000 (23:39 +0100)
committerRafael J. Wysocki <rjw@sisk.pl>
Thu, 9 Feb 2012 22:56:01 +0000 (23:56 +0100)
The code related to 'freezer_test_done' is needlessly convoluted.
Refactor the code and simplify the implementation.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
kernel/power/hibernate.c
kernel/power/user.c

index c6dee73..72baaf0 100644 (file)
@@ -629,12 +629,8 @@ int hibernate(void)
                goto Finish;
 
        error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
-       if (error)
-               goto Thaw;
-       if (freezer_test_done) {
-               freezer_test_done = false;
+       if (error || freezer_test_done)
                goto Thaw;
-       }
 
        if (in_suspend) {
                unsigned int flags = 0;
@@ -659,6 +655,10 @@ int hibernate(void)
 
  Thaw:
        thaw_processes();
+
+       /* Don't bother checking whether freezer_test_done is true */
+       freezer_test_done = false;
+
  Finish:
        free_basic_memory_bitmaps();
        usermodehelper_enable();
index 7bee91f..33c4329 100644 (file)
@@ -251,10 +251,8 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
                error = hibernation_snapshot(data->platform_support);
                if (!error) {
                        error = put_user(in_suspend, (int __user *)arg);
-                       if (!error && !freezer_test_done)
-                               data->ready = 1;
-                       if (freezer_test_done)
-                               freezer_test_done = false;
+                       data->ready = !freezer_test_done && !error;
+                       freezer_test_done = false;
                }
                break;