Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1552141 > unrolled thread

[PATCH] sysrq: attach sysrq handler correctly for 32-bit kernel

Started byAkinobu Mita <akinobu.mita@gmail.com>
First post2017-01-05 18:20 +0100
Last post2017-01-05 23:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] sysrq: attach sysrq handler correctly for 32-bit kernel Akinobu Mita <akinobu.mita@gmail.com> - 2017-01-05 18:20 +0100
    Re: [PATCH] sysrq: attach sysrq handler correctly for 32-bit kernel Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-01-05 23:20 +0100

#1552141 — [PATCH] sysrq: attach sysrq handler correctly for 32-bit kernel

FromAkinobu Mita <akinobu.mita@gmail.com>
Date2017-01-05 18:20 +0100
Subject[PATCH] sysrq: attach sysrq handler correctly for 32-bit kernel
Message-ID<sWjRM-5ZY-47@gated-at.bofh.it>
The sysrq input handler should be attached to the input device which has
a left alt key.

On 32-bit kernels, some input devices which has a left alt key cannot
attach sysrq handler.  Because the keybit bitmap in struct input_device_id
for sysrq is not correctly initialized.  KEY_LEFTALT is 56 which is
greater than BITS_PER_LONG on 32-bit kernels.

I found this problem when using a matrix keypad device which defines
a KEY_LEFTALT (56) but doesn't have a KEY_O (24 == 56%32).

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 drivers/tty/sysrq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 52bbd27..701c085 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -946,8 +946,8 @@ static const struct input_device_id sysrq_ids[] = {
 	{
 		.flags = INPUT_DEVICE_ID_MATCH_EVBIT |
 				INPUT_DEVICE_ID_MATCH_KEYBIT,
-		.evbit = { BIT_MASK(EV_KEY) },
-		.keybit = { BIT_MASK(KEY_LEFTALT) },
+		.evbit = { [BIT_WORD(EV_KEY)] = BIT_MASK(EV_KEY) },
+		.keybit = { [BIT_WORD(KEY_LEFTALT)] = BIT_MASK(KEY_LEFTALT) },
 	},
 	{ },
 };
-- 
2.7.4

[toc] | [next] | [standalone]


#1552370

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-01-05 23:20 +0100
Message-ID<sWoy6-G2-23@gated-at.bofh.it>
In reply to#1552141
On Fri, Jan 06, 2017 at 02:14:16AM +0900, Akinobu Mita wrote:
> The sysrq input handler should be attached to the input device which has
> a left alt key.
> 
> On 32-bit kernels, some input devices which has a left alt key cannot
> attach sysrq handler.  Because the keybit bitmap in struct input_device_id
> for sysrq is not correctly initialized.  KEY_LEFTALT is 56 which is
> greater than BITS_PER_LONG on 32-bit kernels.
> 
> I found this problem when using a matrix keypad device which defines
> a KEY_LEFTALT (56) but doesn't have a KEY_O (24 == 56%32).
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

I guess Greg will take it through TTY tree. Might go to stable as well,
although apparently not pressing since it was only noticed now.

> ---
>  drivers/tty/sysrq.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index 52bbd27..701c085 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -946,8 +946,8 @@ static const struct input_device_id sysrq_ids[] = {
>  	{
>  		.flags = INPUT_DEVICE_ID_MATCH_EVBIT |
>  				INPUT_DEVICE_ID_MATCH_KEYBIT,
> -		.evbit = { BIT_MASK(EV_KEY) },
> -		.keybit = { BIT_MASK(KEY_LEFTALT) },
> +		.evbit = { [BIT_WORD(EV_KEY)] = BIT_MASK(EV_KEY) },
> +		.keybit = { [BIT_WORD(KEY_LEFTALT)] = BIT_MASK(KEY_LEFTALT) },
>  	},
>  	{ },
>  };
> -- 
> 2.7.4
> 

Thanks.

-- 
Dmitry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web