linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: Adding graceful shutdown to sysrq key reset
@ 2013-04-05 13:38 mathieu.poirier
  2013-04-15 20:45 ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: mathieu.poirier @ 2013-04-05 13:38 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: linux-input, arve, kernel-team, john.stultz, mathieu.poirier

From: "Mathieu J. Poirier" <mathieu.poirier@linaro.org>

Attempt to reboot the system gracefully when a key combo
is detected.  The system is force to go down if the first
attempt failed and the key combo is pressed a second time.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/tty/sysrq.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 766878a..bd852fc 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -43,6 +43,7 @@
 #include <linux/uaccess.h>
 #include <linux/moduleparam.h>
 #include <linux/jiffies.h>
+#include <linux/syscalls.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq_regs.h>
@@ -584,6 +585,7 @@ struct sysrq_state {
 
 	/* reset sequence handling */
 	bool reset_canceled;
+	bool reset_requested;
 	unsigned long reset_keybit[BITS_TO_LONGS(KEY_CNT)];
 	int reset_seq_len;
 	int reset_seq_cnt;
@@ -624,11 +626,17 @@ static void sysrq_parse_reset_sequence(struct sysrq_state *state)
 
 static void sysrq_do_reset(unsigned long dummy)
 {
-	__handle_sysrq(sysrq_xlate[KEY_B], false);
+	sys_sync();
+	kernel_restart(NULL);
 }
 
 static void sysrq_handle_reset_request(struct sysrq_state *state)
 {
+	if (state->reset_requested)
+		__handle_sysrq(sysrq_xlate[KEY_B], false);
+
+	state->reset_requested = true;
+
 	if (sysrq_reset_downtime_ms)
 		mod_timer(&state->keyreset_timer,
 			jiffies + msecs_to_jiffies(sysrq_reset_downtime_ms));
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-24  0:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-05 13:38 [PATCH] Input: Adding graceful shutdown to sysrq key reset mathieu.poirier
2013-04-15 20:45 ` Dmitry Torokhov
2013-04-16 14:45   ` Mathieu Poirier
2013-04-23 23:50     ` Mathieu Poirier
2013-04-24  0:42       ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).