From patchwork Thu Jun 27 16:13:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 2794241 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9E6D6BF4A1 for ; Thu, 27 Jun 2013 16:13:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53B19203FC for ; Thu, 27 Jun 2013 16:13:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 207F6203F3 for ; Thu, 27 Jun 2013 16:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648Ab3F0QNX (ORCPT ); Thu, 27 Jun 2013 12:13:23 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:53077 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018Ab3F0QNW (ORCPT ); Thu, 27 Jun 2013 12:13:22 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so1113485pbb.19 for ; Thu, 27 Jun 2013 09:13:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=OnK7URNrrlLm/fjgWPo2vM07JiEv6BtIxXqNaEr955k=; b=XTH53UeA+dNI26K+ff0LpqIUasg6A95s9vk/hvcdgFR79FHqRwtslx6xD1D4jnGHC7 o3R8F8zrXWaav2F/ltSuJw2Ls3Tkdd+zB6p8Iii3n+SIP1qu+jlRCElMSG6zqQVOQHou wJBYro+Jt55hdtMNdhL3GI02/86QwdGCxFPXPInM0HQ4EZHuOAWyl5P8M4gA2gcgHEBY 8mBQh3kgd4vaM5ZOOzT1Qf/QnSIiNmdg0iosiPP1O6ECMYFxObalEmzSMKhrdebtH1rw RFjIiMglY3k+T0cKHFRqJmxKR3rSVlvZBKHdje+XdT/u7WHwxXso1JzVOyQkVTMNMl4K +2PQ== X-Received: by 10.68.75.110 with SMTP id b14mr6832222pbw.89.1372349602391; Thu, 27 Jun 2013 09:13:22 -0700 (PDT) Received: from black.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPSA id v7sm3756194pbq.32.2013.06.27.09.13.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Jun 2013 09:13:21 -0700 (PDT) From: mathieu.poirier@linaro.org To: grant.likely@linaro.org Cc: devicetree-discuss@lists.ozlabs.org, dmitry.torokhov@gmail.com, john.stultz@linaro.org, kernel-team@android.com, linux-input@vger.kernel.org Subject: [PATCH 2/2] Input: Adding DT support for keyreset tuneables Date: Thu, 27 Jun 2013 10:13:25 -0600 Message-Id: <1372349605-4500-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1372349605-4500-1-git-send-email-mathieu.poirier@linaro.org> References: <1372349605-4500-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQlLhnagY4clDlluxewwqN6za8g4PfCXxzNngy09JIU6BBsu0NMZrBnA/7lPvYUTTyGrduCi Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Mathieu J. Poirier" This patch adds the possibility to get the keyreset and timeout values from the device tree. Signed-off-by: Mathieu Poirier --- drivers/tty/sysrq.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index b51c154..91d081c 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -671,6 +672,50 @@ static void sysrq_detect_reset_sequence(struct sysrq_state *state, } } +static void sysrq_of_get_keyreset_config(void) +{ + unsigned short key; + struct device_node *np; + const struct property *prop; + const __be32 *val; + int count, i; + + np = of_find_node_by_path("/sysrq"); + if (!np) { + pr_info("No sysrq node found"); + goto out; + } + + prop = of_find_property(np, "linux,input-keyset", NULL); + if (!prop || !prop->value) { + pr_err("Invalid input-keyset"); + goto out; + } + + count = prop->length / sizeof(u32); + val = prop->value; + + if (count > SYSRQ_KEY_RESET_MAX) + count = SYSRQ_KEY_RESET_MAX; + + /* reset in case a __weak definition was present */ + sysrq_reset_seq_len = 0; + + for (i = 0; i < count; i++) { + key = (unsigned short)be32_to_cpup(val++); + if (key == KEY_RESERVED || key > KEY_MAX) + break; + + sysrq_reset_seq[sysrq_reset_seq_len++] = key; + } + + /* get reset timeout if any */ + of_property_read_u32(np, "timeout-ms", &sysrq_reset_downtime_ms); + + out: + ; +} + static void sysrq_reinject_alt_sysrq(struct work_struct *work) { struct sysrq_state *sysrq = @@ -688,6 +733,7 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work) input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1); input_inject_event(handle, EV_SYN, SYN_REPORT, 1); + input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0); input_inject_event(handle, EV_KEY, alt_code, 0); input_inject_event(handle, EV_SYN, SYN_REPORT, 1); @@ -903,6 +949,7 @@ static inline void sysrq_register_handler(void) int error; int i; + /* first check if a __weak interface was instantiated */ for (i = 0; i < ARRAY_SIZE(sysrq_reset_seq); i++) { key = platform_sysrq_reset_seq[i]; if (key == KEY_RESERVED || key > KEY_MAX) @@ -911,6 +958,13 @@ static inline void sysrq_register_handler(void) sysrq_reset_seq[sysrq_reset_seq_len++] = key; } + /* + * DT configuration takes precedence over anything + * that would have been defined via the __weak + * interface + */ + sysrq_of_get_keyreset_config(); + error = input_register_handler(&sysrq_handler); if (error) pr_err("Failed to register input handler, error %d", error);