Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp456042pxa; Tue, 4 Aug 2020 09:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybHqeZD0R3PEFPxGxxBCja4EcIBWrTiC/NmgRWzM5X0pU1z9OVcvpHYVND9iGmgk2MkOrb X-Received: by 2002:a17:906:8149:: with SMTP id z9mr1022064ejw.356.1596558396786; Tue, 04 Aug 2020 09:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596558396; cv=none; d=google.com; s=arc-20160816; b=rdilI8LhaLNXQwqQTvqI5p/3YrGsH3DJCvXLE6D0KISPPynGHqA+tl4gO7n06S0YvB qgN6/rThtZLIigNPC/uKzed2Xrad+a71TgDcTLzuvkl85fJv1gUFMBUNiWJym2LfdOTc zjwCBIDZUUWLxkUxzSQIFNB8XmIBS1n3+tEgbI1jUBMfKL7qgFWXWM2gXFJj/O9hIiJv v0DPU5VmQ9ywgBZurQf3jjtj+7xf2106J/5AZSA2GF1iQWi80tGLRNdyZHKi08fW47l7 lf6zy4RbNsCnY6yRFzkBjB/Mnz5nnws8/K6382c7dcklfG5IJbYL1D1+1x3ZJc3HHuoH Sh2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=2U441Ab3Iv8YfAyBYX8ahhXriPfYOQALdYRZ/NtT8Dk=; b=vTsbI8UEeurLlXXKHzURHnENQVQVrK0zYZOPVMf/JuB3akE8ajAUQMGmMEIbMEEhfH Pfw5q2keNiB+3c5nb3Ydl+gAmqL+bSI1ZR9kII6YC9TTJEWp9Sknd94ccSFcqgJix7fZ 4M5+wYnzHiE4iI3eys5ck6twTLWQYLkdU8hWxHeoI7cVoJKhStdaOgypNdmmpKAjJLJs B7OWM0zloqnk7DZxAzD4pHcc+gJGCuhRJAfUX/DEVnF3xi2fZecc5E6dyG9o5JkkuJFY rD7jDS3+pBEPQnC2W3G3twNMFkgZbxN/xDWyfsTfhsKDmk7AK9iCGuOIszvrMDt4HvWF mMjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m2si12072390ejj.244.2020.08.04.09.26.14; Tue, 04 Aug 2020 09:26:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729959AbgHDQZW (ORCPT + 99 others); Tue, 4 Aug 2020 12:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729889AbgHDQYN (ORCPT ); Tue, 4 Aug 2020 12:24:13 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA27C06174A; Tue, 4 Aug 2020 09:24:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id EFC502950FC From: Andrzej Pietrasiewicz To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Dmitry Torokhov , Andrzej Pietrasiewicz , linux-input@vger.kernel.org, kernel@collabora.com Subject: [PATCH 1/2] tty/sysrq: Extend the sysrq_key_table to cover capital letters Date: Tue, 4 Aug 2020 18:24:01 +0200 Message-Id: <20200804162402.2087-2-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200804162402.2087-1-andrzej.p@collabora.com> References: <20200804162402.2087-1-andrzej.p@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All slots in sysrq_key_table[] are either used, reserved or at least commented with their intended use. This patch adds capital letter versions available, which means adding 26 more entries. For already existing SysRq operations the user presses Alt-SysRq-, and for the newly added ones Alt-Shift-SysRq-. Signed-off-by: Andrzej Pietrasiewicz --- Documentation/admin-guide/sysrq.rst | 2 ++ drivers/tty/sysrq.c | 49 +++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/sysrq.rst b/Documentation/admin-guide/sysrq.rst index e6424d8c5846..67dfa4c29093 100644 --- a/Documentation/admin-guide/sysrq.rst +++ b/Documentation/admin-guide/sysrq.rst @@ -79,6 +79,8 @@ On all echo t > /proc/sysrq-trigger +The :kbd:`` is case sensitive. + What are the 'command' keys? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 7c95afa905a0..52e344bfe8c0 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -442,7 +442,7 @@ static const struct sysrq_key_op sysrq_unrt_op = { /* Key Operations table and lock */ static DEFINE_SPINLOCK(sysrq_key_table_lock); -static const struct sysrq_key_op *sysrq_key_table[36] = { +static const struct sysrq_key_op *sysrq_key_table[62] = { &sysrq_loglevel_op, /* 0 */ &sysrq_loglevel_op, /* 1 */ &sysrq_loglevel_op, /* 2 */ @@ -499,6 +499,32 @@ static const struct sysrq_key_op *sysrq_key_table[36] = { /* y: May be registered on sparc64 for global register dump */ NULL, /* y */ &sysrq_ftrace_dump_op, /* z */ + NULL, /* A */ + NULL, /* B */ + NULL, /* C */ + NULL, /* D */ + NULL, /* E */ + NULL, /* F */ + NULL, /* G */ + NULL, /* H */ + NULL, /* I */ + NULL, /* J */ + NULL, /* K */ + NULL, /* L */ + NULL, /* M */ + NULL, /* N */ + NULL, /* O */ + NULL, /* P */ + NULL, /* Q */ + NULL, /* R */ + NULL, /* S */ + NULL, /* T */ + NULL, /* U */ + NULL, /* V */ + NULL, /* W */ + NULL, /* X */ + NULL, /* Y */ + NULL, /* Z */ }; /* key2index calculation, -1 on invalid index */ @@ -510,6 +536,8 @@ static int sysrq_key_table_key2index(int key) retval = key - '0'; else if ((key >= 'a') && (key <= 'z')) retval = key + 10 - 'a'; + else if ((key >= 'A') && (key <= 'Z')) + retval = key + 36 - 'A'; else retval = -1; return retval; @@ -623,6 +651,8 @@ struct sysrq_state { unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; unsigned int alt; unsigned int alt_use; + unsigned int shift; + unsigned int shift_use; bool active; bool need_reinject; bool reinjecting; @@ -807,10 +837,20 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq, } break; + case KEY_LEFTSHIFT: + case KEY_RIGHTSHIFT: + if (!value) + sysrq->shift = KEY_RESERVED; + else if (value != 2) + sysrq->shift = code; + break; + case KEY_SYSRQ: if (value == 1 && sysrq->alt != KEY_RESERVED) { sysrq->active = true; sysrq->alt_use = sysrq->alt; + /* either RESERVED (for released) or actual code */ + sysrq->shift_use = sysrq->shift; /* * If nothing else will be pressed we'll need * to re-inject Alt-SysRq keysroke. @@ -833,8 +873,13 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq, default: if (sysrq->active && value && value != 2) { + unsigned char c = sysrq_xlate[code]; + sysrq->need_reinject = false; - __handle_sysrq(sysrq_xlate[code], true); + if (sysrq->shift_use != KEY_RESERVED) + if (c >= 'a' && c <= 'z') + c &= ~(1 << 5); /* to uppercase */ + __handle_sysrq(c, true); } break; } -- 2.17.1