]> err.no Git - util-linux/commitdiff
rtcwake: support not suspending
authorMarco d'Itri <md@Linux.IT>
Sun, 25 Jan 2009 16:44:16 +0000 (17:44 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 26 Jan 2009 20:22:24 +0000 (21:22 +0100)
People usually want to use pm-utils to suspend the system instead of
the raw kernel interface, so I added an option to just exit after
configuring the wakeup time.
Actually I think that all the suspend code should be removed from
rtcwake, since it does not really belong there.

Signed-off-by: Marco d'Itri <md@linux.it>
sys-utils/rtcwake.8
sys-utils/rtcwake.c

index c06fb2117c5f44b1f27a0aae5732406a4b01ca51..a47374dc35a8d51589375a177fe95bb53231dc75 100644 (file)
@@ -74,8 +74,8 @@ is the time in seconds since 1970-01-01, 00:00 UTC. Use the
 .TP
 \fB-m\fP \fImode\fP | \fB--mode\fP \fImode\fP
 Use standby state \fImode\fP. Valid values are \fIstandby\fP,
-\fImem\fP, \fIdisk\fP and \fIon\fP (no suspend). The default is
-\fIstandby\fP.
+\fImem\fP, \fIdisk\fP, \fIno\fP (no suspend) and \fIon\fP (for debugging).
+The default is \fIstandby\fP.
 .SH NOTES
 Some PC systems can't currently exit sleep states such as \fImem\fP
 using only the kernel code accessed by this driver.
index 3baf88c61f27c3e03f7691a10ad3fe6d20eae70f..4b843736d33df2f18da064b6437d63746a963e80 100644 (file)
@@ -333,6 +333,7 @@ int main(int argc, char **argv)
                                        || strcmp(optarg, "mem") == 0
                                        || strcmp(optarg, "disk") == 0
                                        || strcmp(optarg, "on") == 0
+                                       || strcmp(optarg, "no") == 0
                           ) {
                                suspend = strdup(optarg);
                                break;
@@ -419,7 +420,8 @@ int main(int argc, char **argv)
                devname = new_devname;
        }
 
-       if (strcmp(suspend, "on") != 0 && !is_wakeup_enabled(devname)) {
+       if (strcmp(suspend, "on") != 0 && strcmp(suspend, "no") != 0
+                       && !is_wakeup_enabled(devname)) {
                fprintf(stderr, _("%s: %s not enabled for wakeup events\n"),
                                progname, devname);
                exit(EXIT_FAILURE);
@@ -451,16 +453,18 @@ int main(int argc, char **argv)
        if (setup_alarm(fd, &alarm) < 0)
                exit(EXIT_FAILURE);
 
-       sync();
        printf(_("%s: wakeup from \"%s\" using %s at %s\n"),
                        progname, suspend, devname,
                        ctime(&alarm));
        fflush(stdout);
        usleep(10 * 1000);
 
-       if (strcmp(suspend, "on") != 0)
+       if (strcmp(suspend, "no") == 0)
+               exit(EXIT_SUCCESS);
+       else if (strcmp(suspend, "on") != 0) {
+               sync();
                suspend_system(suspend);
-       else {
+       else {
                unsigned long data;
 
                do {