|
From: <jsi...@us...> - 2007-05-11 13:14:21
|
Revision: 2378
http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2378&view=rev
Author: jsimmons
Date: 2007-05-11 06:14:20 -0700 (Fri, 11 May 2007)
Log Message:
-----------
update to git tree.
Modified Paths:
--------------
branches/ruby-2.6.21/ruby-2.6/drivers/char/keyboard.c
Modified: branches/ruby-2.6.21/ruby-2.6/drivers/char/keyboard.c
===================================================================
--- branches/ruby-2.6.21/ruby-2.6/drivers/char/keyboard.c 2007-04-21 16:45:57 UTC (rev 2377)
+++ branches/ruby-2.6.21/ruby-2.6/drivers/char/keyboard.c 2007-05-11 13:14:20 UTC (rev 2378)
@@ -41,7 +41,6 @@
#include <linux/input.h>
#include <linux/reboot.h>
-static void kbd_disconnect(struct input_handle *handle);
extern void ctrl_alt_del(void);
void compute_shiftstate(void);
@@ -131,45 +130,33 @@
static int sysrq_alt;
/*
- * Translation of scancodes to keycodes. We set them on only the first attached
- * keyboard - for per-keyboard setting, /dev/input/event is more useful.
+ * Translation of scancodes to keycodes. We set them on only the first
+ * keyboard in the list that accepts the scancode and keycode.
+ * Explanation for not choosing the first attached keyboard anymore:
+ * USB keyboards for example have two event devices: one for all "normal"
+ * keys and one for extra function keys (like "volume up", "make coffee",
+ * etc.). So this means that scancodes for the extra function keys won't
+ * be valid for the first event device, but will be for the second.
*/
int getkeycode(struct input_handle *handle, unsigned int scancode)
{
- struct input_dev *dev = handle->dev;
+ int error = -ENODEV, keycode;
- if (!dev)
- return -ENODEV;
-
- if (!dev->keycodesize || scancode >= dev->keycodemax)
- return -EINVAL;
-
- return INPUT_KEYCODE(dev, scancode);
+ if (handle) {
+ error = handle->dev->getkeycode(handle->dev, scancode, &keycode);
+ if (!error)
+ error = keycode;
+ }
+ return error;
}
int setkeycode(struct input_handle *handle, unsigned int scancode, unsigned int keycode)
{
- struct input_dev *dev = handle->dev;
- int i, oldkey;
+ int error = -ENODEV;
- if (!dev)
- return -ENODEV;
-
- if (scancode >= dev->keycodemax || keycode > KEY_MAX)
- return -EINVAL;
- if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
- return -EINVAL;
-
- oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
-
- clear_bit(oldkey, dev->keybit);
- set_bit(keycode, dev->keybit);
-
- for (i = 0; i < dev->keycodemax; i++)
- if (INPUT_KEYCODE(dev,i) == oldkey)
- set_bit(oldkey, dev->keybit);
-
- return 0;
+ if (handle)
+ error = handle->dev->setkeycode(handle->dev, scancode, keycode);
+ return error;
}
/*
@@ -1120,7 +1107,7 @@
if ((raw_mode = (vc->kbd_table.kbdmode == VC_RAW)) && !hw_raw)
if (emulate_raw(vc, keycode, !down << 7))
- if (keycode < BTN_MISC)
+ if (keycode < BTN_MISC && printk_ratelimit())
printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
@@ -1245,12 +1232,11 @@
* likes it, it can open it and get events from it. In this (kbd_connect)
* function, we should decide which VT to bind that keyboard to initially.
*/
-static struct input_handle *kbd_connect(struct input_handler *handler,
- struct input_dev *dev,
- const struct input_device_id *id)
+static int kbd_connect(struct input_handler *handler, struct input_dev *dev,
+ const struct input_device_id *id)
{
- struct vt_struct *vt = NULL;
struct input_handle *handle;
+ struct vt_struct *vt = NULL;
int i;
for (i = KEY_RESERVED; i < BTN_MISC; i++)
@@ -1258,17 +1244,24 @@
break;
if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
- return NULL;
+ return -ENODEV;
handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
if (!handle)
- return NULL;
+ return -ENOMEM;
handle->dev = dev;
handle->handler = handler;
handle->name = "kbd";
- input_open_device(handle);
+ error = input_register_handle(handle);
+ if (error)
+ goto err_free_handle;
+
+ error = input_open_device(handle);
+ if (error)
+ goto err_unregister_handle;
+
/*
* If we have more keyboards than VTs we still register the handler.
* It is possible someone might add a graphics card thus needing the
@@ -1299,7 +1292,12 @@
handle->private = admin_vt;
vt_map_input(admin_vt);
}
- return handle;
+
+err_unregister_handle:
+ input_unregister_handle(handle);
+err_free_handle:
+ kfree(handle);
+ return error;
}
static void kbd_disconnect(struct input_handle *handle)
@@ -1310,7 +1308,7 @@
vt->keyboard = NULL;
handle->private = NULL;
}
- input_close_device(handle);
+ input_unregister_handle(handle);
kfree(handle);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|