* [PATCH] change SysRq keycode for systems without SysRq key
@ 2007-07-13 21:20 federico ferri
2007-07-17 6:57 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: federico ferri @ 2007-07-13 21:20 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
this patch adds an entry in Kconfig after 'config MAGIC_SYSRQ' which
asks for a different keycode (replacing also KEY_SYSRQ with
CONFIG_MAGIC_SYSRQ_KEYCODE in char/keyboard.c)
it was tested on some USB keyboards (Microsoft and Apple USB keyboards,
and it works)
I sumbitted this patch two years ago, but it was ignored.
I think this patch is very important, even to a non-developer (SysRq-k
is very helpful when testing unstable software/drivers)
--
federico ferri
[-- Attachment #2: ff-magic_sysrq_keycode.patch --]
[-- Type: text/x-patch, Size: 1535 bytes --]
diff -uprN linux.orig/drivers/char/keyboard.c linux/drivers/char/keyboard.c
--- linux.orig/drivers/char/keyboard.c 2005-07-09 21:47:50.000000000 +0200
+++ linux/drivers/char/keyboard.c 2005-07-10 14:42:34.000000000 +0200
@@ -1081,7 +1087,7 @@ 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 && (sysrq_down || (down == 1 && sysrq_alt))) {
+ if (keycode == CONFIG_MAGIC_SYSRQ_KEYCODE && (sysrq_down || (down == 1 && sysrq_alt))) {
sysrq_down = down;
return;
}
diff -uprN linux.orig/lib/Kconfig.debug linux/lib/Kconfig.debug
--- linux.orig/lib/Kconfig.debug 2005-07-09 21:47:22.000000000 +0200
+++ linux/lib/Kconfig.debug 2005-07-09 21:50:44.000000000 +0200
@@ -28,6 +28,16 @@ config MAGIC_SYSRQ
send a BREAK and then within 5 seconds a command keypress. The
keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
unless you really know what this hack does.
+
+config MAGIC_SYSRQ_KEYCODE
+ int
+ prompt "Change SysRq key-code" if MAGIC_SYSRQ
+ default 99
+ depends on MAGIC_SYSRQ
+ help
+ If your keyboard doesn't have a SysRq key (also labeled PrintScr),
+ you can specify another keycode which should act as SysRq.
+ Default is 99 (KEY_SYSRQ).
+ You can find this number using programs like evtest, or (maybe)
+ showkey.
config LOG_BUF_SHIFT
int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] change SysRq keycode for systems without SysRq key 2007-07-13 21:20 [PATCH] change SysRq keycode for systems without SysRq key federico ferri @ 2007-07-17 6:57 ` Andrew Morton 2007-07-17 22:28 ` federico ferri 0 siblings, 1 reply; 3+ messages in thread From: Andrew Morton @ 2007-07-17 6:57 UTC (permalink / raw) To: federico ferri; +Cc: linux-kernel On Fri, 13 Jul 2007 23:20:33 +0200 federico ferri <xaero@inwind.it> wrote: > #ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */ > - if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) { > + if (keycode == CONFIG_MAGIC_SYSRQ_KEYCODE && (sysrq_down || (down == 1 && sysrq_alt))) { > sysrq_down = down; > return; > } > diff -uprN linux.orig/lib/Kconfig.debug linux/lib/Kconfig.debug > --- linux.orig/lib/Kconfig.debug 2005-07-09 21:47:22.000000000 +0200 > +++ linux/lib/Kconfig.debug 2005-07-09 21:50:44.000000000 +0200 > @@ -28,6 +28,16 @@ config MAGIC_SYSRQ > send a BREAK and then within 5 seconds a command keypress. The > keys are documented in <file:Documentation/sysrq.txt>. Don't say Y > unless you really know what this hack does. > + > +config MAGIC_SYSRQ_KEYCODE > + int > + prompt "Change SysRq key-code" if MAGIC_SYSRQ > + default 99 > + depends on MAGIC_SYSRQ > + help > + If your keyboard doesn't have a SysRq key (also labeled PrintScr), > + you can specify another keycode which should act as SysRq. > + Default is 99 (KEY_SYSRQ). > + You can find this number using programs like evtest, or (maybe) > + showkey. > Seems harmless enough ;) Could you please send in a suitable update to Documentation/sysrq.txt? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] change SysRq keycode for systems without SysRq key 2007-07-17 6:57 ` Andrew Morton @ 2007-07-17 22:28 ` federico ferri 0 siblings, 0 replies; 3+ messages in thread From: federico ferri @ 2007-07-17 22:28 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-kernel Andrew Morton ha scritto: > Seems harmless enough ;) > > Could you please send in a suitable update to Documentation/sysrq.txt? sorry, I should have written a few lines here... issue solved (sorry for not CCing here, I'm shy ((: ) resulting in no need for a patch, just the need of a recent kernel and a userspace program. I report here the full discussion I had with Linus Torvalds, Dmitry Torokhov (CCed to linux-input list): >>>>> this patch adds an entry in Kconfig after 'config MAGIC_SYSRQ' which >>>>> asks for a different keycode (replacing also KEY_SYSRQ with >>>>> CONFIG_MAGIC_SYSRQ_KEYCODE in char/keyboard.c) >>>>> >>>>> Federico >>>> >>>> Quite frankly, I think that if we want to make something like this >>>> configurable, it should be dynamic, not compiled-in. So that the same >>>> kernel image can be used with different keyboards. >>>> >>>> Linus >>> (I can imagine it could be done via a /proc/sysrq-keycode virtual file, >>> but that's just one possibility) >>> >>> So, this should turn into a feature request... >>> would you accept feature requests? ( : >>> >>> Federico >> >> Well, this is totally untested, and I won't guarantee that this works at >> all, but this is how to generally do these kinds of things.. >> >> Linus >> >> --- >> drivers/char/keyboard.c | 6 +++++- >> 1 files changed, 5 insertions(+), 1 deletions(-) >> >> diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c >> index 90965b4..e21f52b 100644 >> --- a/drivers/char/keyboard.c >> +++ b/drivers/char/keyboard.c >> @@ -157,6 +157,10 @@ static int sysrq_alt_use; >> #endif >> static int sysrq_alt; >> >> +static int sysrq_key = KEY_SYSRQ; >> +module_param_named(sysrq_key, sysrq_key, uint, 0644); >> +MODULE_PARM_DESC(sysrq_key, "The keycode to be used for sysrq"); >> + >> /* >> * Translation of scancodes to keycodes. We set them on only the first >> * keyboard in the list that accepts the scancode and keycode. >> @@ -1139,7 +1143,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) >> 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 && (sysrq_down || (down == 1 && sysrq_alt))) { >> + if (keycode == sysrq_key && (sysrq_down || (down == 1 && sysrq_alt))) { >> if (!sysrq_down) { >> sysrq_down = down; >> sysrq_alt_use = sysrq_alt; >> > > YAY! it works great. > tried with: > # echo 183 > /sys/module/keyboard/parameters/sysrq_key > but also keyboard.sys_rq=183 on the command line should work; I'll > discover that on next reboot. Yes, please do verify. > thank you, Linus! You're welcome. > (now that this has done in the proper way, is this patch going to be > merged in the tree?) I'm certainly ok with it, but I guess it's more up to Dmitry. If he ack's it, I can just commit it. Dmitry? Any reason not to do this? Linus ------------------------------------------------------------------------------- On 7/17/07, federico ferri <xaero@inwind.it> wrote: > Dmitry Torokhov ha scritto: > >> Dmitry? Any reason not to do this? > >> > > > > Recent kernels have the ability to remap keymap for USB keyboards via > > EVIOCSKEYCODE ioctl (we allowed 0adjusting keymaps on PS/2 keyboards > > for a long time). So instead of having the new parameter redefining > > SysRq keycode Frederico can remap one of the keys on his keyboard to > > generate KEY_SYSRQ. This way SysRq should still work if he plugs in > > another USB keyboard that has SysRq key or a PS/2 keyboard. > > would setkeycodes still just work for PS2 keyboards? > I upgraded to newer kbd-1.13 package (kernel 2.6.21), and while trying > to change sysrq keycode still I get the old error: > > KDSETKEYCODE: No such device > failed to set scancode 38b7 to keycode 84 > > which I reported on gentoo a long time ago: > http://bugs.gentoo.org/show_bug.cgi?id=97388 > > (it doesn't use EVIOCSKEYCODE) > maybe I'm not picking up the right program? > EVIOCSKEYCODE support for HID (USB) went in in 2.6.22-rc1. There is keyfuzz utility you can use to play with keymaps for a particular device: http://0pointer.de/lennart/projects/keyfuzz/ -- Dmitry ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-17 23:28 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-07-13 21:20 [PATCH] change SysRq keycode for systems without SysRq key federico ferri 2007-07-17 6:57 ` Andrew Morton 2007-07-17 22:28 ` federico ferri
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox