mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] fix magic sysrq on strange keyboards
@ 2006-05-18 10:23 Pavel Machek
  2006-05-18 19:10 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2006-05-18 10:23 UTC (permalink / raw)
  To: dtor_core, linux-input, vojtech, Andrew Morton, kernel list

Magic sysrq fails to work on many keyboards, particulary most of
notebook keyboards. This should help...

The idea is quite simple: Discard the SysRq break code if Alt is still
being held down. This way the broken keyboard can send the break code
(or the user with a normal keyboard can release the SysRq key) and the
kernel waits until the next key is pressed or the Alt key is released.

From: Fredrik Roubert <roubert@df.lth.se>
Signed-off-by: Pavel Machek <pavel@suse.cz>

---
commit 81a95636a6fa97678b744785ddb33f987d934d99
tree 41bde7eb3767e087bbcda90430b5a1777aa3c3c8
parent 103baf40aa229f40933f1eab736158875bf01484
author <pavel@amd.ucw.cz> Thu, 18 May 2006 12:21:43 +0200
committer <pavel@amd.ucw.cz> Thu, 18 May 2006 12:21:43 +0200

 drivers/char/keyboard.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 5d84839..4602cf3 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -149,7 +149,8 @@ unsigned char kbd_sysrq_xlate[KEY_MAX + 
         "\206\207\210\211\212\000\000789-456+1"         /* 0x40 - 0x4f */
         "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
         "\r\000/";                                      /* 0x60 - 0x6f */
-static int was_sysrq;
+static int sysrq_down;
+static int sysrq_alt_use;
 #endif
 static int sysrq_alt;
 
@@ -1142,7 +1143,7 @@ static void kbd_keycode(unsigned int key
 	kbd = kbd_table + fg_console;
 
 	if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
-		sysrq_alt = down;
+		sysrq_alt = down ? keycode : 0;
 #ifdef CONFIG_SPARC
 	if (keycode == KEY_STOP)
 		sparc_l1_a_state = down;
@@ -1161,13 +1162,17 @@ static void kbd_keycode(unsigned int key
 				printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
 
 #ifdef CONFIG_MAGIC_SYSRQ	       /* Handle the SysRq Hack */
-	if ((keycode == KEY_SYSRQ) && down) {
-		printk(KERN_CRIT "Sysrq: press a key to do something\n");
-		was_sysrq = 1;
+	if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
+		if (!sysrq_down) {
+			sysrq_down = down;
+			sysrq_alt_use = sysrq_alt;
+		}
+		return;
 	}
-	if (was_sysrq && down && !rep) {
+	if (sysrq_down && !down && keycode == sysrq_alt_use)
+		sysrq_down = 0;
+	if (sysrq_down && down && !rep) {
 		handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
-		was_sysrq = 0;
 		return;
 	}
 #endif

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] fix magic sysrq on strange keyboards
  2006-05-18 10:23 [patch] fix magic sysrq on strange keyboards Pavel Machek
@ 2006-05-18 19:10 ` Andrew Morton
  2006-05-18 21:01   ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-05-18 19:10 UTC (permalink / raw)
  To: Pavel Machek; +Cc: dtor_core, linux-input, vojtech, linux-kernel

Pavel Machek <pavel@suse.cz> wrote:
>
> Magic sysrq fails to work on many keyboards, particulary most of
>  notebook keyboards. This should help...
> 
>  The idea is quite simple: Discard the SysRq break code if Alt is still
>  being held down. This way the broken keyboard can send the break code
>  (or the user with a normal keyboard can release the SysRq key) and the
>  kernel waits until the next key is pressed or the Alt key is released.
> 
>  From: Fredrik Roubert <roubert@df.lth.se>
>  Signed-off-by: Pavel Machek <pavel@suse.cz>
> 

What kernel are you patching here?


>  index 5d84839..4602cf3 100644
>  --- a/drivers/char/keyboard.c
>  +++ b/drivers/char/keyboard.c
>  @@ -149,7 +149,8 @@ unsigned char kbd_sysrq_xlate[KEY_MAX + 
>           "\206\207\210\211\212\000\000789-456+1"         /* 0x40 - 0x4f */
>           "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
>           "\r\000/";                                      /* 0x60 - 0x6f */
>  -static int was_sysrq;
>  +static int sysrq_down;
>  +static int sysrq_alt_use;

bix:/usr/src/linux-2.6.17-rc4> grep was_sysrq drivers/char/sysrq.c
bix:/usr/src/linux-2.6.17-rc4> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] fix magic sysrq on strange keyboards
  2006-05-18 19:10 ` Andrew Morton
@ 2006-05-18 21:01   ` Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2006-05-18 21:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: dtor_core, linux-input, vojtech, linux-kernel, roubert

Hi!

Sorry, probably sent patch to my own kernel... This one should be
better.
	
								Pavel

--- 

Magic sysrq fails to work on many keyboards, particulary most of
notebook keyboards. This should help...

The idea is quite simple: Discard the SysRq break code if Alt is still
being held down. This way the broken keyboard can send the break code
(or the user with a normal keyboard can release the SysRq key) and the
kernel waits until the next key is pressed or the Alt key is released.
 
From: Fredrik Roubert <roubert@df.lth.se>
Signed-off-by: Pavel Machek <pavel@suse.cz>

diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 5755b7e..4602cf3 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -150,6 +150,7 @@ unsigned char kbd_sysrq_xlate[KEY_MAX + 
         "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
         "\r\000/";                                      /* 0x60 - 0x6f */
 static int sysrq_down;
+static int sysrq_alt_use;
 #endif
 static int sysrq_alt;
 
@@ -1142,7 +1143,7 @@ static void kbd_keycode(unsigned int key
 	kbd = kbd_table + fg_console;
 
 	if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
-		sysrq_alt = down;
+		sysrq_alt = down ? keycode : 0;
 #ifdef CONFIG_SPARC
 	if (keycode == KEY_STOP)
 		sparc_l1_a_state = down;
@@ -1162,9 +1163,14 @@ static void kbd_keycode(unsigned int key
 
 #ifdef CONFIG_MAGIC_SYSRQ	       /* Handle the SysRq Hack */
 	if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
-		sysrq_down = down;
+		if (!sysrq_down) {
+			sysrq_down = down;
+			sysrq_alt_use = sysrq_alt;
+		}
 		return;
 	}
+	if (sysrq_down && !down && keycode == sysrq_alt_use)
+		sysrq_down = 0;
 	if (sysrq_down && down && !rep) {
 		handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
 		return;


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-18 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-18 10:23 [patch] fix magic sysrq on strange keyboards Pavel Machek
2006-05-18 19:10 ` Andrew Morton
2006-05-18 21:01   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®