Skip to contentSkip to conversation

busybox: rtcwake: Allow poweroff with rtcwake

PATCH New Carlos Hernandez 1 participant 1 message Jul 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 busybox: rtcwake: Allow poweroff with rtcwake

Useful to test rtcwake from poweroff.

---
 ...cwake-Allow-poweroff-with-rtcwake-command.patch | 56 ++++++++++++++++++++++
 .../recipes-core/busybox/busybox_%.bbappend        |  2 +
 2 files changed, 58 insertions(+)
 create mode 100644 meta-arago-distro/recipes-core/busybox/busybox/0001-rtcwake-Allow-poweroff-with-rtcwake-command.patch
meta-arago-distro/recipes-core/busybox/busybox/0001-rtcwake-Allow-poweroff-with-rtcwake-command.patch new file +56 -0
new file mode 100644
index 000000000000..da47888ef8fd
@@ -0,0 +1,56 @@
+From 81e46127ec781dec6789457e918582a5a4eae50a Mon Sep 17 00:00:00 2001
+From: Dave Gerlach <[email protected]>
+Date: Tue, 9 Jun 2015 10:54:19 -0500
+Subject: [PATCH] rtcwake: Allow poweroff with rtcwake command
+
+rtcwake will support poweroff as an option for -m with this
+patch by calling poweroff from the command line and also not disabling
+the rtc alarm1 interrupt at exit.
+
+Signed-off-by: Dave Gerlach <[email protected]>
+---
+ util-linux/rtcwake.c | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c
+index 8aee0cfcbd56..a0edee5d8647 100644
+--- a/util-linux/rtcwake.c
++++ b/util-linux/rtcwake.c
+@@ -133,6 +133,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+	unsigned seconds = seconds; /* for compiler */
+	int utc = -1;
+	int fd;
++        int poweroff = 0;
+
+ #if ENABLE_LONG_OPTS
+	static const char rtcwake_longopts[] ALIGN1 =
+@@ -211,9 +212,14 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+	fflush_all();
+	usleep(10 * 1000);
+
+-	if (strcmp(suspend, "on") != 0)
+-		xopen_xwrite_close(SYS_POWER_PATH, suspend);
+-	else {
++	if (strcmp(suspend, "on")) {
++		if (!strcmp(suspend, "poweroff")) {
++			system("poweroff");
++			poweroff = 1;
++		} else {
++			xopen_xwrite_close(SYS_POWER_PATH, suspend);
++		}
++	} else {
+		/* "fake" suspend ... we'll do the delay ourselves */
+		unsigned long data;
+
+@@ -226,7 +232,8 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+		} while (!(data & RTC_AF));
+	}
+
+-	xioctl(fd, RTC_AIE_OFF, 0);
++	if (!poweroff)
++		xioctl(fd, RTC_AIE_OFF, 0);
+
+	if (ENABLE_FEATURE_CLEAN_UP)
+		close(fd);
+--
+1.9.1
meta-arago-distro/recipes-core/busybox/busybox_%.bbappend +2 -0
index 709ebdaaf8c1..d3c258c9bfd6 100644
@@ -1,4 +1,6 @@
 # look for files in this layer first
 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
 
+SRC_URI_append = " file://0001-rtcwake-Allow-poweroff-with-rtcwake-command.patch "
+
 PR_append = ".arago20"
Signature · 1 line
1.9.1