lkml.org 
[lkml]   [2008]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] Make atkbd.c use unsigned short instead of unsigned int
From
Date
Hi list,

I've got an Acer Extensa 5220 with some extra "Euro" and "Dollar" keys.
I wanted to make these keys known to the kernel, so I wrote an .fdi file
for hal.

Unfortunately the configuration of the "Euro" and "Dollar" (and some
other key) failed, because:
a) the atkbd driver uses unsigned char to store the keymap
b) the KEY_DOLLAR is 0x1b2 (which doesn't fit in 8 bits).

I created a small patch which changes the keymap to use
unsigned short.

PS: I'm not subscribed to the LKML, please email me directly.




--
Thomas Ilnseher <illth@gmx.de>
--- linux/drivers/input/keyboard/atkbd.c 2008-07-13 23:51:29.000000000 +0200
+++ linux/drivers/input/keyboard/atkbd.c.new 2008-08-08 22:22:15.483300222 +0200
@@ -64,10 +64,21 @@
MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards");

/*
+ * Keycode table type. This used to be unsigned char (= 8bit).
+ * Too small for dollar / euro (found on acer atkbd)
+ */
+typedef unsigned short keycode_table_t;
+
+/*
* Scancode to keycode tables. These are just the default setting, and
* are loadable via an userland utility.
*/

+/*
+ * This is left unsigned char to conserve some memory.
+ * the memcopy is replaces by a loop.
+ */
+
static unsigned char atkbd_set2_keycode[512] = {

#ifdef CONFIG_KEYBOARD_ATKBD_HP_KEYCODES
@@ -200,7 +211,7 @@
char phys[32];

unsigned short id;
- unsigned char keycode[512];
+ keycode_table_t keycode[512];
DECLARE_BITMAP(force_release_mask, 512);
unsigned char set;
unsigned char translated;
@@ -357,7 +368,7 @@
unsigned int code = data;
int scroll = 0, hscroll = 0, click = -1;
int value;
- unsigned char keycode;
+ keycode_table_t keycode;

#ifdef ATKBD_DEBUG
printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags);
@@ -807,8 +818,6 @@
static void atkbd_cleanup(struct serio *serio)
{
struct atkbd *atkbd = serio_get_drvdata(serio);
-
- atkbd_disable(atkbd);
ps2_command(&atkbd->ps2dev, NULL, ATKBD_CMD_RESET_BAT);
}

@@ -874,14 +883,20 @@
atkbd->keycode[i | 0x80] = atkbd_scroll_keys[j].keycode;
}
} else if (atkbd->set == 3) {
- memcpy(atkbd->keycode, atkbd_set3_keycode, sizeof(atkbd->keycode));
- } else {
- memcpy(atkbd->keycode, atkbd_set2_keycode, sizeof(atkbd->keycode));
+ /* at_kbd->keycode is keycode_table_t, but atkbd_set* is unsigned char.
+ * therefore we can't use memcpy
+ memcpy(atkbd->keycode, atkbd_set3_keycode, sizeof(atkbd->keycode)); */
+ for (i = 0; i < (sizeof(atkbd->keycode) / sizeof(keycode_table_t)); i++)
+ atkbd->keycode[i] = (keycode_table_t) atkbd_set3_keycode[i];
+ } else { /* see above
+ memcpy(atkbd->keycode, atkbd_set2_keycode, sizeof(atkbd->keycode)); */
+ for (i = 0; i < (sizeof(atkbd->keycode) / sizeof(keycode_table_t)); i++)
+ atkbd->keycode[i] = (keycode_table_t) atkbd_set2_keycode[i];

if (atkbd->scroll)
for (i = 0; i < ARRAY_SIZE(atkbd_scroll_keys); i++) {
scancode = atkbd_scroll_keys[i].set2;
- atkbd->keycode[scancode] = atkbd_scroll_keys[i].keycode;
+ atkbd->keycode[scancode] = (keycode_table_t)(atkbd_scroll_keys[i].keycode);
}
}

@@ -965,7 +980,7 @@
}

input_dev->keycode = atkbd->keycode;
- input_dev->keycodesize = sizeof(unsigned char);
+ input_dev->keycodesize = sizeof(keycode_table_t);
input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode);

for (i = 0; i < 512; i++)
\
 
 \ /
  Last update: 2008-08-08 23:09    [W:0.025 / U:2.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site