From e4b0fc36ffb565f19db8934bc13c9b6a2bce572f Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sun, 25 Jan 2009 17:44:16 +0100 Subject: [PATCH] rtcwake: support not suspending 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 --- sys-utils/rtcwake.8 | 4 ++-- sys-utils/rtcwake.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys-utils/rtcwake.8 b/sys-utils/rtcwake.8 index c06fb211..a47374dc 100644 --- a/sys-utils/rtcwake.8 +++ b/sys-utils/rtcwake.8 @@ -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. diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 3baf88c6..4b843736 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -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 { -- 2.39.5