Hi,

I've just notice that we "forgot" to implement the "platform" mode in resume.
The appended patch fixes this problem.

Greetings,
Rafael

---
 resume.c  |   18 +++++++++++++++++-
 suspend.c |   19 ++++++++++++-------
 swsusp.h  |    1 +
 3 files changed, 30 insertions(+), 8 deletions(-)

Index: suspend/suspend.c
===================================================================
--- suspend.orig/suspend.c      2007-02-25 20:57:12.000000000 +0100
+++ suspend/suspend.c   2007-02-25 21:20:18.000000000 +0100
@@ -587,10 +587,14 @@ int write_image(int snapshot_fd, int res
                max_block_size = page_size;
                if (compute_checksum)
                        header->image_flags |= IMAGE_CHECKSUM;
+
                if (compress) {
                        header->image_flags |= IMAGE_COMPRESSED;
                        max_block_size += sizeof(short);
                }
+               if (use_platform_suspend)
+                       header->image_flags |= PLATFORM_SUSPEND;
+
 #ifdef CONFIG_ENCRYPT
                if (encrypt) {
                        if (use_RSA) {
@@ -719,9 +723,9 @@ static int reset_signature(int fd)
 
 static void suspend_shutdown(int snapshot_fd)
 {
-       if (!strcmp(shutdown_method, "reboot"))
+       if (!strcmp(shutdown_method, "reboot")) {
                reboot();
-       else if (use_platform_suspend) {
+       } else if (use_platform_suspend) {
                int ret = platform_enter(snapshot_fd);
                if (ret < 0)
                        fprintf(stderr, "suspend: pm_ops->enter returned"
@@ -763,9 +767,11 @@ int suspend_system(int snapshot_fd, int 
 
        if (use_platform_suspend) {
                int ret = platform_prepare(snapshot_fd);
-               if (ret < 0)
+               if (ret < 0) {
                        fprintf(stderr, "suspend: pm_ops->prepare returned "
                                "error %d\n", ret);
+                       use_platform_suspend = 0;
+               }
        }
 
        printf("suspend: Snapshotting system\n");
@@ -781,8 +787,6 @@ int suspend_system(int snapshot_fd, int 
                                printf("\e[13]");
                                printf("suspend: returned to userspace\n");
                                free_snapshot(snapshot_fd);
-                               if (use_platform_suspend)
-                                       platform_finish(snapshot_fd);
                                break;
                        }
                        error = write_image(snapshot_fd, resume_fd);
@@ -821,8 +825,9 @@ int suspend_system(int snapshot_fd, int 
                }
        } while (--attempts);
 
-       /* we only get here when we failed to suspend.
-          Remember, suspend_shutdown() never returns! */
+       /* We get here during the resume or when we failed to suspend.
+        * Remember, suspend_shutdown() never returns!
+        */
        if (use_platform_suspend)
                platform_finish(snapshot_fd);
 
Index: suspend/swsusp.h
===================================================================
--- suspend.orig/swsusp.h       2007-02-25 20:57:11.000000000 +0100
+++ suspend/swsusp.h    2007-02-25 21:11:01.000000000 +0100
@@ -82,6 +82,7 @@ struct swsusp_info {
 #define IMAGE_COMPRESSED       0x0002
 #define IMAGE_ENCRYPTED                0x0004
 #define IMAGE_USE_RSA          0x0008
+#define PLATFORM_SUSPEND       0x0010
 
 #define SWSUSP_SIG     "ULSUSPEND"
 
Index: suspend/resume.c
===================================================================
--- suspend.orig/resume.c       2007-02-25 20:57:11.000000000 +0100
+++ suspend/resume.c    2007-02-25 21:29:15.000000000 +0100
@@ -55,6 +55,7 @@ static char decrypt;
 #define decrypt 0
 #endif
 static char splash_param;
+static int use_platform_suspend;
 
 static struct splash splash;
 
@@ -575,7 +576,10 @@ static int read_image(int dev, int fd, s
        error = read_area(fd, header, swsusp_header->image, page_size);
 
        if (!error) {
-               if(header->image_flags & IMAGE_CHECKSUM) {
+               if (header->image_flags & PLATFORM_SUSPEND)
+                       use_platform_suspend = 1;
+
+               if (header->image_flags & IMAGE_CHECKSUM) {
                        memcpy(orig_checksum, header->checksum, 16);
                        printf("resume: MD5 checksum %s\n",
                                print_checksum(buffer, orig_checksum));
@@ -866,7 +870,19 @@ int main(int argc, char *argv[])
                fprintf(stderr, "resume: Could not freeze processes\n");
                goto Close_splash;
        }
+       if (use_platform_suspend) {
+               int ret = platform_prepare(dev);
+               if (ret < 0) {
+                       fprintf(stderr, "resume: pm_ops->prepare returned "
+                               "error %d\n", ret);
+                       use_platform_suspend = 0;
+               }
+       }
        atomic_restore(dev);
+       /* We only get here if the atomic restore fails.  Clean up. */
+       if (use_platform_suspend)
+               platform_finish(dev);
+
        unfreeze(dev);
 
 Close_splash:

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to