[PATCH] rtcwake: support not suspending

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>

diff -urp util-linux-ng.OLD/sys-utils/rtcwake.8 util-linux-ng/sys-utils/rtcwake.8
--- util-linux-ng.OLD/sys-utils/rtcwake.8	2009-01-25 16:16:40.000000000 +0100
+++ util-linux-ng/sys-utils/rtcwake.8	2009-01-25 17:33:01.000000000 +0100
@@ -74,8 +74,8 @@ is the time in seconds since 1970-01-01,
 .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 -urp util-linux-ng.OLD/sys-utils/rtcwake.c util-linux-ng/sys-utils/rtcwake.c
--- util-linux-ng.OLD/sys-utils/rtcwake.c	2009-01-25 16:16:40.000000000 +0100
+++ util-linux-ng/sys-utils/rtcwake.c	2009-01-25 17:22:51.000000000 +0100
@@ -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 {

-- 
ciao,
Marco
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux