public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Ilnseher <illth@gmx.de>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Make atkbd.c use unsigned short instead of unsigned int
Date: Fri, 08 Aug 2008 23:06:23 +0200	[thread overview]
Message-ID: <1218229583.6152.14.camel@note.localnet> (raw)

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

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>

[-- Attachment #2: atkbd_short.path --]
[-- Type: text/x-patch, Size: 2829 bytes --]

--- 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++)

                 reply	other threads:[~2008-08-08 21:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218229583.6152.14.camel@note.localnet \
    --to=illth@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox