* Fwd: Patch for initial CapsLock
@ 2003-01-06 18:37 Pete Zaitcev
2003-01-06 21:52 ` Vojtech Pavlik
0 siblings, 1 reply; 6+ messages in thread
From: Pete Zaitcev @ 2003-01-06 18:37 UTC (permalink / raw)
To: alan; +Cc: greg, linux-kernel, vojtech, zaitcev
Dear Alan,
Here's a USB problem which can only be resolved in generic code.
Vojtech is the owner of the code, but did not reply. Do you think
you can keep this patch in -ac?
Thanks in advance,
-- Pete
----- Forwarded message from Pete Zaitcev <zaitcev@redhat.com> -----
Date: Tue, 24 Dec 2002 13:41:03 -0500
From: Pete Zaitcev <zaitcev@redhat.com>
To: vojtech@suse.cz
Cc: zaitcev@redhat.com, linux-kernel@vger.kernel.org
Subject: Patch for initial CapsLock
User-Agent: Mutt/1.2.5.1i
Hi, Vojtech:
In 2.4.21-pre2, if Caps Lock is on and a USB keyboard is connected,
the LED will not be lit. It mostly affects KVM users like those
of IBM BladeCenter, because they "connect" keyboards all day long.
Would you be so kind to review the attached patch?
-- Pete
diff -ur -X dontdiff linux-2.4.21-pre2/drivers/char/keyboard.c linux-2.4.21-pre2-usb/drivers/char/keyboard.c
--- linux-2.4.21-pre2/drivers/char/keyboard.c 2002-08-02 17:39:43.000000000 -0700
+++ linux-2.4.21-pre2-usb/drivers/char/keyboard.c 2002-12-24 10:40:48.000000000 -0800
@@ -64,6 +64,7 @@
void (*kbd_ledfunc)(unsigned int led);
EXPORT_SYMBOL(handle_scancode);
EXPORT_SYMBOL(kbd_ledfunc);
+EXPORT_SYMBOL(kbd_refresh_leds);
extern void ctrl_alt_del(void);
@@ -899,9 +900,9 @@
* Aside from timing (which isn't really that important for
* keyboard interrupts as they happen often), using the software
* interrupt routines for this thing allows us to easily mask
- * this when we don't want any of the above to happen. Not yet
- * used, but this allows for easy and efficient race-condition
- * prevention later on.
+ * this when we don't want any of the above to happen.
+ * This allows for easy and efficient race-condition prevention
+ * for kbd_ledfunc => input_event(dev, EV_LED, ...) => ...
*/
static void kbd_bh(unsigned long dummy)
{
@@ -917,6 +918,18 @@
EXPORT_SYMBOL(keyboard_tasklet);
DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
+/*
+ * This allows a newly plugged keyboard to pick the LED state.
+ * We do it in this seemindly backwards fashion to ensure proper locking.
+ * Built-in keyboard does refresh on its own.
+ */
+void kbd_refresh_leds(void)
+{
+ tasklet_disable(&keyboard_tasklet);
+ if (ledstate != 0xff && kbd_ledfunc != NULL) kbd_ledfunc(ledstate);
+ tasklet_enable(&keyboard_tasklet);
+}
+
typedef void (pm_kbd_func) (void);
pm_callback pm_kbd_request_override = NULL;
diff -ur -X dontdiff linux-2.4.21-pre2/drivers/input/keybdev.c linux-2.4.21-pre2-usb/drivers/input/keybdev.c
--- linux-2.4.21-pre2/drivers/input/keybdev.c 2001-10-11 09:14:32.000000000 -0700
+++ linux-2.4.21-pre2-usb/drivers/input/keybdev.c 2002-12-23 23:43:53.000000000 -0800
@@ -201,6 +201,7 @@
input_open_device(handle);
// printk(KERN_INFO "keybdev.c: Adding keyboard: input%d\n", dev->number);
+ kbd_refresh_leds();
return handle;
}
@@ -222,6 +223,7 @@
{
input_register_handler(&keybdev_handler);
kbd_ledfunc = keybdev_ledfunc;
+ kbd_refresh_leds();
if (jp_kbd_109) {
x86_keycodes[0xb5] = 0x73; /* backslash, underscore */
diff -ur -X dontdiff linux-2.4.21-pre2/include/linux/kbd_kern.h linux-2.4.21-pre2-usb/include/linux/kbd_kern.h
--- linux-2.4.21-pre2/include/linux/kbd_kern.h 2002-12-19 20:22:19.000000000 -0800
+++ linux-2.4.21-pre2-usb/include/linux/kbd_kern.h 2002-12-23 23:43:31.000000000 -0800
@@ -72,6 +72,7 @@
extern int do_poke_blanked_console;
extern void (*kbd_ledfunc)(unsigned int led);
+extern void kbd_refresh_leds(void);
extern void set_console(int nr);
extern void schedule_console_callback(void);
----- End forwarded message -----
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Fwd: Patch for initial CapsLock
2003-01-06 18:37 Fwd: Patch for initial CapsLock Pete Zaitcev
@ 2003-01-06 21:52 ` Vojtech Pavlik
2003-01-06 22:17 ` Pete Zaitcev
0 siblings, 1 reply; 6+ messages in thread
From: Vojtech Pavlik @ 2003-01-06 21:52 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: alan, greg, linux-kernel, vojtech
On Mon, Jan 06, 2003 at 01:37:16PM -0500, Pete Zaitcev wrote:
> Dear Alan,
>
> Here's a USB problem which can only be resolved in generic code.
> Vojtech is the owner of the code, but did not reply. Do you think
> you can keep this patch in -ac?
Sorry for the delay - yes, it's OK.
>
> Thanks in advance,
> -- Pete
>
> ----- Forwarded message from Pete Zaitcev <zaitcev@redhat.com> -----
>
> Date: Tue, 24 Dec 2002 13:41:03 -0500
> From: Pete Zaitcev <zaitcev@redhat.com>
> To: vojtech@suse.cz
> Cc: zaitcev@redhat.com, linux-kernel@vger.kernel.org
> Subject: Patch for initial CapsLock
> User-Agent: Mutt/1.2.5.1i
>
> Hi, Vojtech:
>
> In 2.4.21-pre2, if Caps Lock is on and a USB keyboard is connected,
> the LED will not be lit. It mostly affects KVM users like those
> of IBM BladeCenter, because they "connect" keyboards all day long.
> Would you be so kind to review the attached patch?
>
> -- Pete
>
> diff -ur -X dontdiff linux-2.4.21-pre2/drivers/char/keyboard.c linux-2.4.21-pre2-usb/drivers/char/keyboard.c
> --- linux-2.4.21-pre2/drivers/char/keyboard.c 2002-08-02 17:39:43.000000000 -0700
> +++ linux-2.4.21-pre2-usb/drivers/char/keyboard.c 2002-12-24 10:40:48.000000000 -0800
> @@ -64,6 +64,7 @@
> void (*kbd_ledfunc)(unsigned int led);
> EXPORT_SYMBOL(handle_scancode);
> EXPORT_SYMBOL(kbd_ledfunc);
> +EXPORT_SYMBOL(kbd_refresh_leds);
>
> extern void ctrl_alt_del(void);
>
> @@ -899,9 +900,9 @@
> * Aside from timing (which isn't really that important for
> * keyboard interrupts as they happen often), using the software
> * interrupt routines for this thing allows us to easily mask
> - * this when we don't want any of the above to happen. Not yet
> - * used, but this allows for easy and efficient race-condition
> - * prevention later on.
> + * this when we don't want any of the above to happen.
> + * This allows for easy and efficient race-condition prevention
> + * for kbd_ledfunc => input_event(dev, EV_LED, ...) => ...
> */
> static void kbd_bh(unsigned long dummy)
> {
> @@ -917,6 +918,18 @@
> EXPORT_SYMBOL(keyboard_tasklet);
> DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
>
> +/*
> + * This allows a newly plugged keyboard to pick the LED state.
> + * We do it in this seemindly backwards fashion to ensure proper locking.
> + * Built-in keyboard does refresh on its own.
> + */
> +void kbd_refresh_leds(void)
> +{
> + tasklet_disable(&keyboard_tasklet);
> + if (ledstate != 0xff && kbd_ledfunc != NULL) kbd_ledfunc(ledstate);
> + tasklet_enable(&keyboard_tasklet);
> +}
> +
> typedef void (pm_kbd_func) (void);
>
> pm_callback pm_kbd_request_override = NULL;
> diff -ur -X dontdiff linux-2.4.21-pre2/drivers/input/keybdev.c linux-2.4.21-pre2-usb/drivers/input/keybdev.c
> --- linux-2.4.21-pre2/drivers/input/keybdev.c 2001-10-11 09:14:32.000000000 -0700
> +++ linux-2.4.21-pre2-usb/drivers/input/keybdev.c 2002-12-23 23:43:53.000000000 -0800
> @@ -201,6 +201,7 @@
> input_open_device(handle);
>
> // printk(KERN_INFO "keybdev.c: Adding keyboard: input%d\n", dev->number);
> + kbd_refresh_leds();
>
> return handle;
> }
> @@ -222,6 +223,7 @@
> {
> input_register_handler(&keybdev_handler);
> kbd_ledfunc = keybdev_ledfunc;
> + kbd_refresh_leds();
>
> if (jp_kbd_109) {
> x86_keycodes[0xb5] = 0x73; /* backslash, underscore */
> diff -ur -X dontdiff linux-2.4.21-pre2/include/linux/kbd_kern.h linux-2.4.21-pre2-usb/include/linux/kbd_kern.h
> --- linux-2.4.21-pre2/include/linux/kbd_kern.h 2002-12-19 20:22:19.000000000 -0800
> +++ linux-2.4.21-pre2-usb/include/linux/kbd_kern.h 2002-12-23 23:43:31.000000000 -0800
> @@ -72,6 +72,7 @@
> extern int do_poke_blanked_console;
>
> extern void (*kbd_ledfunc)(unsigned int led);
> +extern void kbd_refresh_leds(void);
>
> extern void set_console(int nr);
> extern void schedule_console_callback(void);
>
> ----- End forwarded message -----
--
Vojtech Pavlik
SuSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Fwd: Patch for initial CapsLock
2003-01-06 21:52 ` Vojtech Pavlik
@ 2003-01-06 22:17 ` Pete Zaitcev
2003-01-07 8:54 ` Vojtech Pavlik
0 siblings, 1 reply; 6+ messages in thread
From: Pete Zaitcev @ 2003-01-06 22:17 UTC (permalink / raw)
To: Vojtech Pavlik; +Cc: linux-kernel
> Date: Mon, 6 Jan 2003 22:52:18 +0100
> From: Vojtech Pavlik <vojtech@suse.cz>
> Sorry for the delay - yes, it's OK.
Do you want me to do the same for 2.5? It should be a little
simpler there, and no new exports.
-- Pete
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Fwd: Patch for initial CapsLock
2003-01-06 22:17 ` Pete Zaitcev
@ 2003-01-07 8:54 ` Vojtech Pavlik
2003-01-07 22:07 ` Pete Zaitcev
0 siblings, 1 reply; 6+ messages in thread
From: Vojtech Pavlik @ 2003-01-07 8:54 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: Vojtech Pavlik, linux-kernel
On Mon, Jan 06, 2003 at 05:17:44PM -0500, Pete Zaitcev wrote:
> > Date: Mon, 6 Jan 2003 22:52:18 +0100
> > From: Vojtech Pavlik <vojtech@suse.cz>
>
> > Sorry for the delay - yes, it's OK.
>
> Do you want me to do the same for 2.5? It should be a little
> simpler there, and no new exports.
Yes, please.
--
Vojtech Pavlik
SuSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Fwd: Patch for initial CapsLock
2003-01-07 8:54 ` Vojtech Pavlik
@ 2003-01-07 22:07 ` Pete Zaitcev
2003-01-08 8:45 ` Vojtech Pavlik
0 siblings, 1 reply; 6+ messages in thread
From: Pete Zaitcev @ 2003-01-07 22:07 UTC (permalink / raw)
To: Vojtech Pavlik; +Cc: linux-kernel, zaitcev
> > Do you want me to do the same for 2.5? It should be a little
> > simpler there, and no new exports.
>
> Yes, please.
Done, works for me.
I toyed with the idea to trigger keyboard tasklet instead of
locking it out and calling methods, but I did not see how
to force updates for unchanged ledstate. Changing ledstate to 0xff
just looked so very wrong...
-- Pete
--- linux-2.5.54/drivers/char/keyboard.c 2002-12-15 18:07:54.000000000 -0800
+++ linux-2.5.54-p3/drivers/char/keyboard.c 2003-01-07 13:55:25.000000000 -0800
@@ -894,9 +894,9 @@
* Aside from timing (which isn't really that important for
* keyboard interrupts as they happen often), using the software
* interrupt routines for this thing allows us to easily mask
- * this when we don't want any of the above to happen. Not yet
- * used, but this allows for easy and efficient race-condition
- * prevention later on.
+ * this when we don't want any of the above to happen.
+ * This allows for easy and efficient race-condition prevention
+ * for kbd_refresh_leds => input_event(dev, EV_LED, ...) => ...
*/
static void kbd_bh(unsigned long dummy)
@@ -918,6 +918,22 @@
DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
+/*
+ * This allows a newly plugged keyboard to pick the LED state.
+ */
+void kbd_refresh_leds(struct input_handle *handle)
+{
+ unsigned char leds = ledstate;
+
+ tasklet_disable(&keyboard_tasklet);
+ if (leds != 0xff) {
+ input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
+ input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02));
+ input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04));
+ }
+ tasklet_enable(&keyboard_tasklet);
+}
+
#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)
static unsigned short x86_keycodes[256] =
@@ -1159,6 +1175,7 @@
handle->name = kbd_name;
input_open_device(handle);
+ kbd_refresh_leds(handle);
return handle;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Fwd: Patch for initial CapsLock
2003-01-07 22:07 ` Pete Zaitcev
@ 2003-01-08 8:45 ` Vojtech Pavlik
0 siblings, 0 replies; 6+ messages in thread
From: Vojtech Pavlik @ 2003-01-08 8:45 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: Vojtech Pavlik, linux-kernel
On Tue, Jan 07, 2003 at 05:07:46PM -0500, Pete Zaitcev wrote:
> > > Do you want me to do the same for 2.5? It should be a little
> > > simpler there, and no new exports.
> >
> > Yes, please.
>
> Done, works for me.
>
> I toyed with the idea to trigger keyboard tasklet instead of
> locking it out and calling methods, but I did not see how
> to force updates for unchanged ledstate. Changing ledstate to 0xff
> just looked so very wrong...
Thanks, this looks very good.
>
> -- Pete
>
> --- linux-2.5.54/drivers/char/keyboard.c 2002-12-15 18:07:54.000000000 -0800
> +++ linux-2.5.54-p3/drivers/char/keyboard.c 2003-01-07 13:55:25.000000000 -0800
> @@ -894,9 +894,9 @@
> * Aside from timing (which isn't really that important for
> * keyboard interrupts as they happen often), using the software
> * interrupt routines for this thing allows us to easily mask
> - * this when we don't want any of the above to happen. Not yet
> - * used, but this allows for easy and efficient race-condition
> - * prevention later on.
> + * this when we don't want any of the above to happen.
> + * This allows for easy and efficient race-condition prevention
> + * for kbd_refresh_leds => input_event(dev, EV_LED, ...) => ...
> */
>
> static void kbd_bh(unsigned long dummy)
> @@ -918,6 +918,22 @@
>
> DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
>
> +/*
> + * This allows a newly plugged keyboard to pick the LED state.
> + */
> +void kbd_refresh_leds(struct input_handle *handle)
> +{
> + unsigned char leds = ledstate;
> +
> + tasklet_disable(&keyboard_tasklet);
> + if (leds != 0xff) {
> + input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
> + input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02));
> + input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04));
> + }
> + tasklet_enable(&keyboard_tasklet);
> +}
> +
> #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64)
>
> static unsigned short x86_keycodes[256] =
> @@ -1159,6 +1175,7 @@
> handle->name = kbd_name;
>
> input_open_device(handle);
> + kbd_refresh_leds(handle);
>
> return handle;
> }
--
Vojtech Pavlik
SuSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-01-08 8:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-06 18:37 Fwd: Patch for initial CapsLock Pete Zaitcev
2003-01-06 21:52 ` Vojtech Pavlik
2003-01-06 22:17 ` Pete Zaitcev
2003-01-07 8:54 ` Vojtech Pavlik
2003-01-07 22:07 ` Pete Zaitcev
2003-01-08 8:45 ` Vojtech Pavlik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox