]> git.neil.brown.name Git - susman.git/commitdiff
wakealarmd fixes
authorNeilBrown <neilb@suse.de>
Sun, 22 Apr 2012 04:21:41 +0000 (14:21 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 22 Apr 2012 04:21:41 +0000 (14:21 +1000)
1/ make sure to reset the wakealarm before
   write to write a new value.

2/ We need to block suspend if it is *not* already disabled,
   not if it is.

Signed-off-by: NeilBrown <neilb@suse.de>
wakealarmd.c

index 6b11fad10989d05011f035eb5ef3ff83bd367b6f..07b3831b16a2f59223d95a14d9c12431dc1dba6d 100644 (file)
@@ -182,6 +182,7 @@ static int do_suspend(void *data)
                int fd = open("/sys/class/rtc/rtc0/wakealarm", O_WRONLY);
                if (fd >= 0) {
                        char buf[20];
+                       write(fd, "0\n", 2);
                        sprintf(buf, "%lld\n",
                                (long long)state->conns->stamp - 2);
                        write(fd, buf, strlen(buf));
@@ -190,7 +191,7 @@ static int do_suspend(void *data)
                return 1;
        }
        /* too close to next wakeup */
-       if (state->disabled) {
+       if (!state->disabled) {
                suspend_block(state->disablefd);
                state->disabled = 1;
        }