From patchwork Fri Apr 5 13:38:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 2398601 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 630B9DF2E5 for ; Fri, 5 Apr 2013 13:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161564Ab3DENii (ORCPT ); Fri, 5 Apr 2013 09:38:38 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:50776 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161548Ab3DENih (ORCPT ); Fri, 5 Apr 2013 09:38:37 -0400 Received: by mail-pa0-f52.google.com with SMTP id fb10so2055259pad.39 for ; Fri, 05 Apr 2013 06:38:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=UrBTB454RlR6iIH94Q/xt4hjT4znnR7lwZVkFso+A+A=; b=C9hTW536ebHxqZ3sToTYW7/W1/iOzBCE4gAbzP67o9FuRMTAh4rgb0f83hSdwXCjIs LXfpqQ8ns46qqoGnF3lug1rYviSGOFNBFwnWS/rMEA1eHRhGvMe0mK4uVy0ir2qndzyA R8oKcRSpUF/bfnZtl2LZSwThpg9Mj4ZnkvdARwXvVXsHzWhJ7vXAQM9Z3b59QDcQ+xmC 3nyf6CwhwBtNylpQDbGAAkThwuk/zaFggCZnkQnznlNcN0bgDUmx2ArgC4zSYT6wZ4ok mkfNLcnIZi8rWSf52555+sl3ud+lgVWeWhQq6zEZe2nkAS5hj/2ySXJRIR5tox+uXHf8 A+Lw== X-Received: by 10.68.231.164 with SMTP id th4mr14162999pbc.198.1365169117533; Fri, 05 Apr 2013 06:38:37 -0700 (PDT) Received: from black.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id ky10sm16036907pab.23.2013.04.05.06.38.36 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 06:38:36 -0700 (PDT) From: mathieu.poirier@linaro.org To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, arve@android.com, kernel-team@android.com, john.stultz@linaro.org, mathieu.poirier@linaro.org Subject: [PATCH] Input: Adding graceful shutdown to sysrq key reset Date: Fri, 5 Apr 2013 07:38:32 -0600 Message-Id: <1365169112-7999-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQl1ysKBsErJyB3cca8KcaG73PO/GA05IG47sisvBAD/XOIDN7KL1dHiOBphYq7PUTnHg0tC Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Mathieu J. Poirier" 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 --- 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 #include #include +#include #include #include @@ -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));