linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.com>
To: Andrzej Pietrasiewicz <andrzej.p@collabora.com>,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	kernel@collabora.com
Subject: Re: [PATCH] tty/sysrq: Add alternative SysRq key
Date: Mon, 22 Jun 2020 08:24:52 +0200	[thread overview]
Message-ID: <7c61ac4d-959f-0069-d1db-7e1ba646ac64@suse.com> (raw)
In-Reply-To: <20200619162819.715-1-andrzej.p@collabora.com>

On 19. 06. 20, 18:28, Andrzej Pietrasiewicz wrote:
> There exist machines which don't have SysRq key at all, e.g. chromebooks.
> 
> This patch allows configuring an alternative key to act as SysRq. Devices
> which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
> but other devices use the alternative SysRq key instead, by default F10.
> Which key is actually used can be modified with sysrq's module parameter.
> 
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> ---
>  drivers/tty/sysrq.c | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index 0dc3878794fd..e1d271c84746 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -604,6 +604,7 @@ EXPORT_SYMBOL(handle_sysrq);
>  
>  #ifdef CONFIG_INPUT
>  static int sysrq_reset_downtime_ms;
> +static unsigned short alternative_sysrq_key = KEY_F10;

I would go for sysrq_alternative_key to preserve the namespace naming.

> @@ -825,11 +828,15 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
>  		 * triggering print screen function.
>  		 */
>  		if (sysrq->active)
> -			clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
> +			clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
>  
>  		break;
>  
>  	default:
> +		/* handle non-default sysrq key */
> +		if (code == sysrq->sysrq_key)
> +			goto key_sysrq;
> +
>  		if (sysrq->active && value && value != 2) {
>  			sysrq->need_reinject = false;
>  			__handle_sysrq(sysrq_xlate[code], true);
> @@ -924,6 +931,14 @@ static int sysrq_connect(struct input_handler *handler,
>  	sysrq->handle.private = sysrq;
>  	timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
>  
> +	if (test_bit(KEY_SYSRQ, dev->keybit)) {
> +		sysrq->sysrq_key = KEY_SYSRQ;
> +		pr_info("%s: using default sysrq key [%x]\n", dev->name, KEY_SYSRQ);
> +	} else {
> +		sysrq->sysrq_key = alternative_sysrq_key;
> +		pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);

Capital U, lowercase u above. Do we want to print the info in the
default case, actually?

> +	}
> +
>  	error = input_register_handle(&sysrq->handle);
>  	if (error) {
>  		pr_err("Failed to register input sysrq handler, error %d\n",
> @@ -1032,6 +1047,13 @@ module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq,
>  
>  module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644);
>  
> +module_param(alternative_sysrq_key, ushort, 0644);
> +MODULE_PARM_DESC(alternative_sysrq_key,
> +	"Alternative SysRq key for input devices that don't have SysRq key. F10 by default.\n"

If you line-break here, I suggest adding a \t or two to the beginning of
the following lines:

> +	"Example\n"
> +	"Using F9 as SysRq:\n"
> +	"sysrq.alternative_sysrq_key=0x43\n");

The last \n is superfluous, there would be an empty line.

Looking at emulate_raw in drivers/tty/vt/keyboard.c, you seem you need
to update that one as well. Otherwise raw keyboard mode won't send sysrq
sequence, when you press it, right?

thanks,
-- 
js
suse labs

  parent reply	other threads:[~2020-06-22 14:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 13:59 [PATCH 0/6] Magic SysRq extensions Andrzej Pietrasiewicz
2020-05-11 13:59 ` [PATCH 1/6] tty/sysrq: Remove linux,sysrq-reset-seq Andrzej Pietrasiewicz
2020-05-11 17:58   ` Dmitry Torokhov
2020-05-12  9:21     ` Andrzej Pietrasiewicz
2020-05-11 13:59 ` [PATCH 2/6] dt-bindings: input: Remove linux,sysrq-reset-seq binding Andrzej Pietrasiewicz
2020-05-11 13:59 ` [PATCH 3/6] tty/sysrq: Allow configurable SysRq key Andrzej Pietrasiewicz
2020-05-11 16:18   ` Greg Kroah-Hartman
2020-05-11 18:01   ` Dmitry Torokhov
2020-05-12  9:46     ` Andrzej Pietrasiewicz
2020-06-19 16:28     ` [PATCH] tty/sysrq: Add alternative " Andrzej Pietrasiewicz
2020-06-21 21:21       ` Pavel Machek
2020-06-26 11:07         ` Andrzej Pietrasiewicz
2020-06-22  6:24       ` Jiri Slaby [this message]
2020-06-26 11:51         ` Andrzej Pietrasiewicz
2020-07-09  5:05       ` Dmitry Torokhov
2020-07-09  8:15         ` Andrzej Pietrasiewicz
2020-05-11 13:59 ` [PATCH 4/6] tty/sysrq: Extend the sysrq_key_table to cover capital letters Andrzej Pietrasiewicz
2020-05-11 13:59 ` [PATCH 5/6] tty/sysrq: Add configurable handler to signal a process Andrzej Pietrasiewicz
2020-05-11 16:20   ` Greg Kroah-Hartman
2020-05-14  9:06   ` kbuild test robot
2020-05-11 13:59 ` [PATCH 6/6] tty/sysrq: Add configurable handler to execute a compound action Andrzej Pietrasiewicz
2020-05-11 16:21   ` Greg Kroah-Hartman
2020-05-11 18:29     ` Dmitry Torokhov
2020-05-12  9:15       ` Andrzej Pietrasiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c61ac4d-959f-0069-d1db-7e1ba646ac64@suse.com \
    --to=jslaby@suse.com \
    --cc=andrzej.p@collabora.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@collabora.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).