aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-08-06 12:12:49 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-08-06 12:12:49 -0400
commit6e1e63259b1e01f047796e7985d960ca040993e6 (patch)
tree43c895798f3f8565a34c61a0a7fa593c6900d74c
parenta05ef8bfdc03c5061f44d91826caa855b0aae481 (diff)
parent2ffc1ccad85e8c2e81a6a4beb390fb4ce143256b (diff)
Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/dtor/input: (24 commits) Input: ati_remote - use msec instead of jiffies Input: ati_remote - add missing input_sync() Input: ati_remote - relax permissions sysfs module parameters Input: ati_remote - make filter time a module parameter Input: atkbd - restore repeat rate when resuming Input: trackpoint - activate protocol when resuming Input: logips2pp - fix button mapping for MX300 Input: keyboard - change to use kzalloc Input: serio/gameport - check whether driver core calls succeeded Input: spaceball - make 4000FLX Lefty work Input: keyboard - simplify emulate_raw() implementation Input: keyboard - remove static variable and clean up initialization Input: hiddev - use standard list implementation Input: add missing handler->start() call Input: HID - fix potential out-of-bound array access Input: fix list iteration in input_release_device() Input: iforce - add Trust Force Feedback Race Master support Input: iforce - check array bounds before accessing elements Input: libps2 - warn instead of oopsing when passed bad arguments Input: fm801-gp - fix use after free ...
-rw-r--r--drivers/char/keyboard.c139
-rw-r--r--drivers/input/evdev.c10
-rw-r--r--drivers/input/gameport/fm801-gp.c4
-rw-r--r--drivers/input/gameport/gameport.c66
-rw-r--r--drivers/input/input.c57
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c19
-rw-r--r--drivers/input/joystick/spaceball.c2
-rw-r--r--drivers/input/keyboard/atkbd.c103
-rw-r--r--drivers/input/misc/wistron_btns.c20
-rw-r--r--drivers/input/mouse/logips2pp.c3
-rw-r--r--drivers/input/mouse/trackpoint.c52
-rw-r--r--drivers/input/serio/libps2.c5
-rw-r--r--drivers/input/serio/serio.c65
-rw-r--r--drivers/usb/input/ati_remote.c173
-rw-r--r--drivers/usb/input/hid-input.c3
-rw-r--r--drivers/usb/input/hiddev.c72
-rw-r--r--include/linux/input.h24
17 files changed, 509 insertions, 308 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 056ebe84b81d..3e90aac37510 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -107,7 +107,6 @@ const int NR_TYPES = ARRAY_SIZE(max_vals);
107 107
108struct kbd_struct kbd_table[MAX_NR_CONSOLES]; 108struct kbd_struct kbd_table[MAX_NR_CONSOLES];
109static struct kbd_struct *kbd = kbd_table; 109static struct kbd_struct *kbd = kbd_table;
110static struct kbd_struct kbd0;
111 110
112int spawnpid, spawnsig; 111int spawnpid, spawnsig;
113 112
@@ -223,13 +222,13 @@ static void kd_nosound(unsigned long ignored)
223{ 222{
224 struct list_head *node; 223 struct list_head *node;
225 224
226 list_for_each(node,&kbd_handler.h_list) { 225 list_for_each(node, &kbd_handler.h_list) {
227 struct input_handle *handle = to_handle_h(node); 226 struct input_handle *handle = to_handle_h(node);
228 if (test_bit(EV_SND, handle->dev->evbit)) { 227 if (test_bit(EV_SND, handle->dev->evbit)) {
229 if (test_bit(SND_TONE, handle->dev->sndbit)) 228 if (test_bit(SND_TONE, handle->dev->sndbit))
230 input_event(handle->dev, EV_SND, SND_TONE, 0); 229 input_inject_event(handle, EV_SND, SND_TONE, 0);
231 if (test_bit(SND_BELL, handle->dev->sndbit)) 230 if (test_bit(SND_BELL, handle->dev->sndbit))
232 input_event(handle->dev, EV_SND, SND_BELL, 0); 231 input_inject_event(handle, EV_SND, SND_BELL, 0);
233 } 232 }
234 } 233 }
235} 234}
@@ -247,11 +246,11 @@ void kd_mksound(unsigned int hz, unsigned int ticks)
247 struct input_handle *handle = to_handle_h(node); 246 struct input_handle *handle = to_handle_h(node);
248 if (test_bit(EV_SND, handle->dev->evbit)) { 247 if (test_bit(EV_SND, handle->dev->evbit)) {
249 if (test_bit(SND_TONE, handle->dev->sndbit)) { 248 if (test_bit(SND_TONE, handle->dev->sndbit)) {
250 input_event(handle->dev, EV_SND, SND_TONE, hz); 249 input_inject_event(handle, EV_SND, SND_TONE, hz);
251 break; 250 break;
252 } 251 }
253 if (test_bit(SND_BELL, handle->dev->sndbit)) { 252 if (test_bit(SND_BELL, handle->dev->sndbit)) {
254 input_event(handle->dev, EV_SND, SND_BELL, 1); 253 input_inject_event(handle, EV_SND, SND_BELL, 1);
255 break; 254 break;
256 } 255 }
257 } 256 }
@@ -272,15 +271,15 @@ int kbd_rate(struct kbd_repeat *rep)
272 unsigned int d = 0; 271 unsigned int d = 0;
273 unsigned int p = 0; 272 unsigned int p = 0;
274 273
275 list_for_each(node,&kbd_handler.h_list) { 274 list_for_each(node, &kbd_handler.h_list) {
276 struct input_handle *handle = to_handle_h(node); 275 struct input_handle *handle = to_handle_h(node);
277 struct input_dev *dev = handle->dev; 276 struct input_dev *dev = handle->dev;
278 277
279 if (test_bit(EV_REP, dev->evbit)) { 278 if (test_bit(EV_REP, dev->evbit)) {
280 if (rep->delay > 0) 279 if (rep->delay > 0)
281 input_event(dev, EV_REP, REP_DELAY, rep->delay); 280 input_inject_event(handle, EV_REP, REP_DELAY, rep->delay);
282 if (rep->period > 0) 281 if (rep->period > 0)
283 input_event(dev, EV_REP, REP_PERIOD, rep->period); 282 input_inject_event(handle, EV_REP, REP_PERIOD, rep->period);
284 d = dev->rep[REP_DELAY]; 283 d = dev->rep[REP_DELAY];
285 p = dev->rep[REP_PERIOD]; 284 p = dev->rep[REP_PERIOD];
286 } 285 }
@@ -988,7 +987,7 @@ static inline unsigned char getleds(void)
988 * interrupt routines for this thing allows us to easily mask 987 * interrupt routines for this thing allows us to easily mask
989 * this when we don't want any of the above to happen. 988 * this when we don't want any of the above to happen.
990 * This allows for easy and efficient race-condition prevention 989 * This allows for easy and efficient race-condition prevention
991 * for kbd_refresh_leds => input_event(dev, EV_LED, ...) => ... 990 * for kbd_start => input_inject_event(dev, EV_LED, ...) => ...
992 */ 991 */
993 992
994static void kbd_bh(unsigned long dummy) 993static void kbd_bh(unsigned long dummy)
@@ -998,11 +997,11 @@ static void kbd_bh(unsigned long dummy)
998 997
999 if (leds != ledstate) { 998 if (leds != ledstate) {
1000 list_for_each(node, &kbd_handler.h_list) { 999 list_for_each(node, &kbd_handler.h_list) {
1001 struct input_handle * handle = to_handle_h(node); 1000 struct input_handle *handle = to_handle_h(node);
1002 input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); 1001 input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
1003 input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); 1002 input_inject_event(handle, EV_LED, LED_NUML, !!(leds & 0x02));
1004 input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04)); 1003 input_inject_event(handle, EV_LED, LED_CAPSL, !!(leds & 0x04));
1005 input_sync(handle->dev); 1004 input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
1006 } 1005 }
1007 } 1006 }
1008 1007
@@ -1011,23 +1010,6 @@ static void kbd_bh(unsigned long dummy)
1011 1010
1012DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0); 1011DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
1013 1012
1014/*
1015 * This allows a newly plugged keyboard to pick the LED state.
1016 */
1017static void kbd_refresh_leds(struct input_handle *handle)
1018{
1019 unsigned char leds = ledstate;
1020
1021 tasklet_disable(&keyboard_tasklet);
1022 if (leds != 0xff) {
1023 input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01));
1024 input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02));
1025 input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04));
1026 input_sync(handle->dev);
1027 }
1028 tasklet_enable(&keyboard_tasklet);
1029}
1030
1031#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\ 1013#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
1032 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\ 1014 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
1033 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\ 1015 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
@@ -1043,7 +1025,7 @@ static const unsigned short x86_keycodes[256] =
1043 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1025 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
1044 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 1026 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1045 80, 81, 82, 83, 84,118, 86, 87, 88,115,120,119,121,112,123, 92, 1027 80, 81, 82, 83, 84,118, 86, 87, 88,115,120,119,121,112,123, 92,
1046 284,285,309,298,312, 91,327,328,329,331,333,335,336,337,338,339, 1028 284,285,309, 0,312, 91,327,328,329,331,333,335,336,337,338,339,
1047 367,288,302,304,350, 89,334,326,267,126,268,269,125,347,348,349, 1029 367,288,302,304,350, 89,334,326,267,126,268,269,125,347,348,349,
1048 360,261,262,263,268,376,100,101,321,316,373,286,289,102,351,355, 1030 360,261,262,263,268,376,100,101,321,316,373,286,289,102,351,355,
1049 103,104,105,275,287,279,306,106,274,107,294,364,358,363,362,361, 1031 103,104,105,275,287,279,306,106,274,107,294,364,358,363,362,361,
@@ -1065,38 +1047,55 @@ extern void sun_do_break(void);
1065static int emulate_raw(struct vc_data *vc, unsigned int keycode, 1047static int emulate_raw(struct vc_data *vc, unsigned int keycode,
1066 unsigned char up_flag) 1048 unsigned char up_flag)
1067{ 1049{
1068 if (keycode > 255 || !x86_keycodes[keycode]) 1050 int code;
1069 return -1;
1070 1051
1071 switch (keycode) { 1052 switch (keycode) {
1072 case KEY_PAUSE: 1053 case KEY_PAUSE:
1073 put_queue(vc, 0xe1); 1054 put_queue(vc, 0xe1);
1074 put_queue(vc, 0x1d | up_flag); 1055 put_queue(vc, 0x1d | up_flag);
1075 put_queue(vc, 0x45 | up_flag); 1056 put_queue(vc, 0x45 | up_flag);
1076 return 0; 1057 break;
1058
1077 case KEY_HANGEUL: 1059 case KEY_HANGEUL:
1078 if (!up_flag) 1060 if (!up_flag)
1079 put_queue(vc, 0xf2); 1061 put_queue(vc, 0xf2);
1080 return 0; 1062 break;
1063
1081 case KEY_HANJA: 1064 case KEY_HANJA:
1082 if (!up_flag) 1065 if (!up_flag)
1083 put_queue(vc, 0xf1); 1066 put_queue(vc, 0xf1);
1084 return 0; 1067 break;
1085 }
1086 1068
1087 if (keycode == KEY_SYSRQ && sysrq_alt) { 1069 case KEY_SYSRQ:
1088 put_queue(vc, 0x54 | up_flag); 1070 /*
1089 return 0; 1071 * Real AT keyboards (that's what we're trying
1090 } 1072 * to emulate here emit 0xe0 0x2a 0xe0 0x37 when
1073 * pressing PrtSc/SysRq alone, but simply 0x54
1074 * when pressing Alt+PrtSc/SysRq.
1075 */
1076 if (sysrq_alt) {
1077 put_queue(vc, 0x54 | up_flag);
1078 } else {
1079 put_queue(vc, 0xe0);
1080 put_queue(vc, 0x2a | up_flag);
1081 put_queue(vc, 0xe0);
1082 put_queue(vc, 0x37 | up_flag);
1083 }
1084 break;
1085
1086 default:
1087 if (keycode > 255)
1088 return -1;
1091 1089
1092 if (x86_keycodes[keycode] & 0x100) 1090 code = x86_keycodes[keycode];
1093 put_queue(vc, 0xe0); 1091 if (!code)
1092 return -1;
1094 1093
1095 put_queue(vc, (x86_keycodes[keycode] & 0x7f) | up_flag); 1094 if (code & 0x100)
1095 put_queue(vc, 0xe0);
1096 put_queue(vc, (code & 0x7f) | up_flag);
1096 1097
1097 if (keycode == KEY_SYSRQ) { 1098 break;
1098 put_queue(vc, 0xe0);
1099 put_queue(vc, 0x37 | up_flag);
1100 } 1099 }
1101 1100
1102 return 0; 1101 return 0;
@@ -1298,16 +1297,15 @@ static struct input_handle *kbd_connect(struct input_handler *handler,
1298 if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) 1297 if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit))
1299 return NULL; 1298 return NULL;
1300 1299
1301 if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) 1300 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
1301 if (!handle)
1302 return NULL; 1302 return NULL;
1303 memset(handle, 0, sizeof(struct input_handle));
1304 1303
1305 handle->dev = dev; 1304 handle->dev = dev;
1306 handle->handler = handler; 1305 handle->handler = handler;
1307 handle->name = "kbd"; 1306 handle->name = "kbd";
1308 1307
1309 input_open_device(handle); 1308 input_open_device(handle);
1310 kbd_refresh_leds(handle);
1311 1309
1312 return handle; 1310 return handle;
1313} 1311}
@@ -1318,6 +1316,24 @@ static void kbd_disconnect(struct input_handle *handle)
1318 kfree(handle); 1316 kfree(handle);
1319} 1317}
1320 1318
1319/*
1320 * Start keyboard handler on the new keyboard by refreshing LED state to
1321 * match the rest of the system.
1322 */
1323static void kbd_start(struct input_handle *handle)
1324{
1325 unsigned char leds = ledstate;
1326
1327 tasklet_disable(&keyboard_tasklet);
1328 if (leds != 0xff) {
1329 input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
1330 input_inject_event(handle, EV_LED, LED_NUML, !!(leds & 0x02));
1331 input_inject_event(handle, EV_LED, LED_CAPSL, !!(leds & 0x04));
1332 input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
1333 }
1334 tasklet_enable(&keyboard_tasklet);
1335}
1336
1321static struct input_device_id kbd_ids[] = { 1337static struct input_device_id kbd_ids[] = {
1322 { 1338 {
1323 .flags = INPUT_DEVICE_ID_MATCH_EVBIT, 1339 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
@@ -1338,6 +1354,7 @@ static struct input_handler kbd_handler = {
1338 .event = kbd_event, 1354 .event = kbd_event,
1339 .connect = kbd_connect, 1355 .connect = kbd_connect,
1340 .disconnect = kbd_disconnect, 1356 .disconnect = kbd_disconnect,
1357 .start = kbd_start,
1341 .name = "kbd", 1358 .name = "kbd",
1342 .id_table = kbd_ids, 1359 .id_table = kbd_ids,
1343}; 1360};
@@ -1346,15 +1363,15 @@ int __init kbd_init(void)
1346{ 1363{
1347 int i; 1364 int i;
1348 1365
1349 kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS; 1366 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1350 kbd0.ledmode = LED_SHOW_FLAGS; 1367 kbd_table[i].ledflagstate = KBD_DEFLEDS;
1351 kbd0.lockstate = KBD_DEFLOCK; 1368 kbd_table[i].default_ledflagstate = KBD_DEFLEDS;
1352 kbd0.slockstate = 0; 1369 kbd_table[i].ledmode = LED_SHOW_FLAGS;
1353 kbd0.modeflags = KBD_DEFMODE; 1370 kbd_table[i].lockstate = KBD_DEFLOCK;
1354 kbd0.kbdmode = VC_XLATE; 1371 kbd_table[i].slockstate = 0;
1355 1372 kbd_table[i].modeflags = KBD_DEFMODE;
1356 for (i = 0 ; i < MAX_NR_CONSOLES ; i++) 1373 kbd_table[i].kbdmode = VC_XLATE;
1357 kbd_table[i] = kbd0; 1374 }
1358 1375
1359 input_register_handler(&kbd_handler); 1376 input_register_handler(&kbd_handler);
1360 1377
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index a29d5ceb00cf..4bf48188cc91 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -127,14 +127,10 @@ static int evdev_open(struct inode * inode, struct file * file)
127{ 127{
128 struct evdev_list *list; 128 struct evdev_list *list;
129 int i = iminor(inode) - EVDEV_MINOR_BASE; 129 int i = iminor(inode) - EVDEV_MINOR_BASE;
130 int accept_err;
131 130
132 if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist) 131 if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist)
133 return -ENODEV; 132 return -ENODEV;
134 133
135 if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file)))
136 return accept_err;
137
138 if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL))) 134 if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
139 return -ENOMEM; 135 return -ENOMEM;
140 136
@@ -260,7 +256,7 @@ static ssize_t evdev_write(struct file * file, const char __user * buffer, size_
260 256
261 if (evdev_event_from_user(buffer + retval, &event)) 257 if (evdev_event_from_user(buffer + retval, &event))
262 return -EFAULT; 258 return -EFAULT;
263 input_event(list->evdev->handle.dev, event.type, event.code, event.value); 259 input_inject_event(&list->evdev->handle, event.type, event.code, event.value);
264 retval += evdev_event_size(); 260 retval += evdev_event_size();
265 } 261 }
266 262
@@ -428,8 +424,8 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
428 if (get_user(v, ip + 1)) 424 if (get_user(v, ip + 1))
429 return -EFAULT; 425 return -EFAULT;
430 426
431 input_event(dev, EV_REP, REP_DELAY, u); 427 input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u);
432 input_event(dev, EV_REP, REP_PERIOD, v); 428 input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v);
433 429
434 return 0; 430 return 0;
435 431
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 47e93daa0fa7..90de5afe03c2 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -106,10 +106,10 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
106 gp->gameport = port; 106 gp->gameport = port;
107 gp->res_port = request_region(port->io, 0x10, "FM801 GP"); 107 gp->res_port = request_region(port->io, 0x10, "FM801 GP");
108 if (!gp->res_port) { 108 if (!gp->res_port) {
109 kfree(gp);
110 gameport_free_port(port);
111 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n", 109 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
112 port->io, port->io + 0x0f); 110 port->io, port->io + 0x0f);
111 gameport_free_port(port);
112 kfree(gp);
113 return -EBUSY; 113 return -EBUSY;
114 } 114 }
115 115
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 36644bff379d..3f47ae55c6f3 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -53,6 +53,7 @@ static LIST_HEAD(gameport_list);
53 53
54static struct bus_type gameport_bus; 54static struct bus_type gameport_bus;
55 55
56static void gameport_add_driver(struct gameport_driver *drv);
56static void gameport_add_port(struct gameport *gameport); 57static void gameport_add_port(struct gameport *gameport);
57static void gameport_destroy_port(struct gameport *gameport); 58static void gameport_destroy_port(struct gameport *gameport);
58static void gameport_reconnect_port(struct gameport *gameport); 59static void gameport_reconnect_port(struct gameport *gameport);
@@ -211,8 +212,14 @@ static void gameport_release_driver(struct gameport *gameport)
211 212
212static void gameport_find_driver(struct gameport *gameport) 213static void gameport_find_driver(struct gameport *gameport)
213{ 214{
215 int error;
216
214 down_write(&gameport_bus.subsys.rwsem); 217 down_write(&gameport_bus.subsys.rwsem);
215 device_attach(&gameport->dev); 218 error = device_attach(&gameport->dev);
219 if (error < 0)
220 printk(KERN_WARNING
221 "gameport: device_attach() failed for %s (%s), error: %d\n",
222 gameport->phys, gameport->name, error);
216 up_write(&gameport_bus.subsys.rwsem); 223 up_write(&gameport_bus.subsys.rwsem);
217} 224}
218 225
@@ -316,7 +323,6 @@ static void gameport_remove_duplicate_events(struct gameport_event *event)
316 spin_unlock_irqrestore(&gameport_event_lock, flags); 323 spin_unlock_irqrestore(&gameport_event_lock, flags);
317} 324}
318 325
319
320static struct gameport_event *gameport_get_event(void) 326static struct gameport_event *gameport_get_event(void)
321{ 327{
322 struct gameport_event *event; 328 struct gameport_event *event;
@@ -342,7 +348,6 @@ static struct gameport_event *gameport_get_event(void)
342static void gameport_handle_event(void) 348static void gameport_handle_event(void)
343{ 349{
344 struct gameport_event *event; 350 struct gameport_event *event;
345 struct gameport_driver *gameport_drv;
346 351
347 mutex_lock(&gameport_mutex); 352 mutex_lock(&gameport_mutex);
348 353
@@ -369,8 +374,7 @@ static void gameport_handle_event(void)
369 break; 374 break;
370 375
371 case GAMEPORT_REGISTER_DRIVER: 376 case GAMEPORT_REGISTER_DRIVER:
372 gameport_drv = event->object; 377 gameport_add_driver(event->object);
373 driver_register(&gameport_drv->driver);
374 break; 378 break;
375 379
376 default: 380 default:
@@ -532,6 +536,7 @@ static void gameport_init_port(struct gameport *gameport)
532 if (gameport->parent) 536 if (gameport->parent)
533 gameport->dev.parent = &gameport->parent->dev; 537 gameport->dev.parent = &gameport->parent->dev;
534 538
539 INIT_LIST_HEAD(&gameport->node);
535 spin_lock_init(&gameport->timer_lock); 540 spin_lock_init(&gameport->timer_lock);
536 init_timer(&gameport->poll_timer); 541 init_timer(&gameport->poll_timer);
537 gameport->poll_timer.function = gameport_run_poll_handler; 542 gameport->poll_timer.function = gameport_run_poll_handler;
@@ -544,6 +549,8 @@ static void gameport_init_port(struct gameport *gameport)
544 */ 549 */
545static void gameport_add_port(struct gameport *gameport) 550static void gameport_add_port(struct gameport *gameport)
546{ 551{
552 int error;
553
547 if (gameport->parent) 554 if (gameport->parent)
548 gameport->parent->child = gameport; 555 gameport->parent->child = gameport;
549 556
@@ -558,8 +565,13 @@ static void gameport_add_port(struct gameport *gameport)
558 printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n", 565 printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n",
559 gameport->name, gameport->phys, gameport->speed); 566 gameport->name, gameport->phys, gameport->speed);
560 567
561 device_add(&gameport->dev); 568 error = device_add(&gameport->dev);
562 gameport->registered = 1; 569 if (error)
570 printk(KERN_ERR
571 "gameport: device_add() failed for %s (%s), error: %d\n",
572 gameport->phys, gameport->name, error);
573 else
574 gameport->registered = 1;
563} 575}
564 576
565/* 577/*
@@ -583,10 +595,11 @@ static void gameport_destroy_port(struct gameport *gameport)
583 595
584 if (gameport->registered) { 596 if (gameport->registered) {
585 device_del(&gameport->dev); 597 device_del(&gameport->dev);
586 list_del_init(&gameport->node);
587 gameport->registered = 0; 598 gameport->registered = 0;
588 } 599 }
589 600
601 list_del_init(&gameport->node);
602
590 gameport_remove_pending_events(gameport); 603 gameport_remove_pending_events(gameport);
591 put_device(&gameport->dev); 604 put_device(&gameport->dev);
592} 605}
@@ -704,11 +717,22 @@ static int gameport_driver_remove(struct device *dev)
704} 717}
705 718
706static struct bus_type gameport_bus = { 719static struct bus_type gameport_bus = {
707 .name = "gameport", 720 .name = "gameport",
708 .probe = gameport_driver_probe, 721 .probe = gameport_driver_probe,
709 .remove = gameport_driver_remove, 722 .remove = gameport_driver_remove,
710}; 723};
711 724
725static void gameport_add_driver(struct gameport_driver *drv)
726{
727 int error;
728
729 error = driver_register(&drv->driver);
730 if (error)
731 printk(KERN_ERR
732 "gameport: driver_register() failed for %s, error: %d\n",
733 drv->driver.name, error);
734}
735
712void __gameport_register_driver(struct gameport_driver *drv, struct module *owner) 736void __gameport_register_driver(struct gameport_driver *drv, struct module *owner)
713{ 737{
714 drv->driver.bus = &gameport_bus; 738 drv->driver.bus = &gameport_bus;
@@ -778,16 +802,24 @@ void gameport_close(struct gameport *gameport)
778 802
779static int __init gameport_init(void) 803static int __init gameport_init(void)
780{ 804{
781 gameport_task = kthread_run(gameport_thread, NULL, "kgameportd"); 805 int error;
782 if (IS_ERR(gameport_task)) {
783 printk(KERN_ERR "gameport: Failed to start kgameportd\n");
784 return PTR_ERR(gameport_task);
785 }
786 806
787 gameport_bus.dev_attrs = gameport_device_attrs; 807 gameport_bus.dev_attrs = gameport_device_attrs;
788 gameport_bus.drv_attrs = gameport_driver_attrs; 808 gameport_bus.drv_attrs = gameport_driver_attrs;
789 gameport_bus.match = gameport_bus_match; 809 gameport_bus.match = gameport_bus_match;
790 bus_register(&gameport_bus); 810 error = bus_register(&gameport_bus);
811 if (error) {
812 printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error);
813 return error;
814 }
815
816 gameport_task = kthread_run(gameport_thread, NULL, "kgameportd");
817 if (IS_ERR(gameport_task)) {
818 bus_unregister(&gameport_bus);
819 error = PTR_ERR(gameport_task);
820 printk(KERN_ERR "gameport: Failed to start kgameportd, error: %d\n", error);
821 return error;
822 }
791 823
792 return 0; 824 return 0;
793} 825}
diff --git a/drivers/input/input.c b/drivers/input/input.c
index a90486f5e491..9cb4b9a54f01 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -35,6 +35,16 @@ static LIST_HEAD(input_handler_list);
35 35
36static struct input_handler *input_table[8]; 36static struct input_handler *input_table[8];
37 37
38/**
39 * input_event() - report new input event
40 * @handle: device that generated the event
41 * @type: type of the event
42 * @code: event code
43 * @value: value of the event
44 *
45 * This function should be used by drivers implementing various input devices
46 * See also input_inject_event()
47 */
38void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 48void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
39{ 49{
40 struct input_handle *handle; 50 struct input_handle *handle;
@@ -183,6 +193,23 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
183} 193}
184EXPORT_SYMBOL(input_event); 194EXPORT_SYMBOL(input_event);
185 195
196/**
197 * input_inject_event() - send input event from input handler
198 * @handle: input handle to send event through
199 * @type: type of the event
200 * @code: event code
201 * @value: value of the event
202 *
203 * Similar to input_event() but will ignore event if device is "grabbed" and handle
204 * injecting event is not the one that owns the device.
205 */
206void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
207{
208 if (!handle->dev->grab || handle->dev->grab == handle)
209 input_event(handle->dev, type, code, value);
210}
211EXPORT_SYMBOL(input_inject_event);
212
186static void input_repeat_key(unsigned long data) 213static void input_repeat_key(unsigned long data)
187{ 214{
188 struct input_dev *dev = (void *) data; 215 struct input_dev *dev = (void *) data;
@@ -197,15 +224,6 @@ static void input_repeat_key(unsigned long data)
197 mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD])); 224 mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));
198} 225}
199 226
200int input_accept_process(struct input_handle *handle, struct file *file)
201{
202 if (handle->dev->accept)
203 return handle->dev->accept(handle->dev, file);
204
205 return 0;
206}
207EXPORT_SYMBOL(input_accept_process);
208
209int input_grab_device(struct input_handle *handle) 227int input_grab_device(struct input_handle *handle)
210{ 228{
211 if (handle->dev->grab) 229 if (handle->dev->grab)
@@ -218,8 +236,15 @@ EXPORT_SYMBOL(input_grab_device);
218 236
219void input_release_device(struct input_handle *handle) 237void input_release_device(struct input_handle *handle)
220{ 238{
221 if (handle->dev->grab == handle) 239 struct input_dev *dev = handle->dev;
222 handle->dev->grab = NULL; 240
241 if (dev->grab == handle) {
242 dev->grab = NULL;
243
244 list_for_each_entry(handle, &dev->h_list, d_node)
245 if (handle->handler->start)
246 handle->handler->start(handle);
247 }
223} 248}
224EXPORT_SYMBOL(input_release_device); 249EXPORT_SYMBOL(input_release_device);
225 250
@@ -963,8 +988,11 @@ int input_register_device(struct input_dev *dev)
963 list_for_each_entry(handler, &input_handler_list, node) 988 list_for_each_entry(handler, &input_handler_list, node)
964 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 989 if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
965 if ((id = input_match_device(handler->id_table, dev))) 990 if ((id = input_match_device(handler->id_table, dev)))
966 if ((handle = handler->connect(handler, dev, id))) 991 if ((handle = handler->connect(handler, dev, id))) {
967 input_link_handle(handle); 992 input_link_handle(handle);
993 if (handler->start)
994 handler->start(handle);
995 }
968 996
969 input_wakeup_procfs_readers(); 997 input_wakeup_procfs_readers();
970 998
@@ -1028,8 +1056,11 @@ void input_register_handler(struct input_handler *handler)
1028 list_for_each_entry(dev, &input_dev_list, node) 1056 list_for_each_entry(dev, &input_dev_list, node)
1029 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 1057 if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
1030 if ((id = input_match_device(handler->id_table, dev))) 1058 if ((id = input_match_device(handler->id_table, dev)))
1031 if ((handle = handler->connect(handler, dev, id))) 1059 if ((handle = handler->connect(handler, dev, id))) {
1032 input_link_handle(handle); 1060 input_link_handle(handle);
1061 if (handler->start)
1062 handler->start(handle);
1063 }
1033 1064
1034 input_wakeup_procfs_readers(); 1065 input_wakeup_procfs_readers();
1035} 1066}
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index 6d99e3c37884..b4914e7231f8 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -79,6 +79,7 @@ static struct iforce_device iforce_device[] = {
79 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? 79 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //?
80 { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? 80 { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //?
81 { 0x06f8, 0x0004, "Gullemot Jet Leader 3D", btn_joystick, abs_joystick, ff_iforce }, //? 81 { 0x06f8, 0x0004, "Gullemot Jet Leader 3D", btn_joystick, abs_joystick, ff_iforce }, //?
82 { 0x06d6, 0x29bc, "Trust Force Feedback Race Master", btn_wheel, abs_wheel, ff_iforce },
82 { 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]", btn_joystick, abs_joystick, ff_iforce } 83 { 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]", btn_joystick, abs_joystick, ff_iforce }
83}; 84};
84 85
@@ -222,22 +223,22 @@ static int iforce_erase_effect(struct input_dev *dev, int effect_id)
222 int err = 0; 223 int err = 0;
223 struct iforce_core_effect* core_effect; 224 struct iforce_core_effect* core_effect;
224 225
225 /* Check who is trying to erase this effect */
226 if (iforce->core_effects[effect_id].owner != current->pid) {
227 printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, iforce->core_effects[effect_id].owner);
228 return -EACCES;
229 }
230
231 if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX) 226 if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX)
232 return -EINVAL; 227 return -EINVAL;
233 228
234 core_effect = iforce->core_effects + effect_id; 229 core_effect = &iforce->core_effects[effect_id];
230
231 /* Check who is trying to erase this effect */
232 if (core_effect->owner != current->pid) {
233 printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, core_effect->owner);
234 return -EACCES;
235 }
235 236
236 if (test_bit(FF_MOD1_IS_USED, core_effect->flags)) 237 if (test_bit(FF_MOD1_IS_USED, core_effect->flags))
237 err = release_resource(&(iforce->core_effects[effect_id].mod1_chunk)); 238 err = release_resource(&core_effect->mod1_chunk);
238 239
239 if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags)) 240 if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags))
240 err = release_resource(&(iforce->core_effects[effect_id].mod2_chunk)); 241 err = release_resource(&core_effect->mod2_chunk);
241 242
242 /*TODO: remember to change that if more FF_MOD* bits are added */ 243 /*TODO: remember to change that if more FF_MOD* bits are added */
243 core_effect->flags[0] = 0; 244 core_effect->flags[0] = 0;
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index 75eb5ca59992..7a19ee052972 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -50,7 +50,7 @@ MODULE_LICENSE("GPL");
50 */ 50 */
51 51
52#define SPACEBALL_MAX_LENGTH 128 52#define SPACEBALL_MAX_LENGTH 128
53#define SPACEBALL_MAX_ID 8 53#define SPACEBALL_MAX_ID 9
54 54
55#define SPACEBALL_1003 1 55#define SPACEBALL_1003 1
56#define SPACEBALL_2003B 3 56#define SPACEBALL_2003B 3
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ce1f10e8984b..6bfa0cf4b1d2 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -482,13 +482,7 @@ out:
482 return IRQ_HANDLED; 482 return IRQ_HANDLED;
483} 483}
484 484
485/* 485static int atkbd_set_repeat_rate(struct atkbd *atkbd)
486 * atkbd_event_work() is used to complete processing of events that
487 * can not be processed by input_event() which is often called from
488 * interrupt context.
489 */
490
491static void atkbd_event_work(void *data)
492{ 486{
493 const short period[32] = 487 const short period[32] =
494 { 33, 37, 42, 46, 50, 54, 58, 63, 67, 75, 83, 92, 100, 109, 116, 125, 488 { 33, 37, 42, 46, 50, 54, 58, 63, 67, 75, 83, 92, 100, 109, 116, 125,
@@ -496,41 +490,64 @@ static void atkbd_event_work(void *data)
496 const short delay[4] = 490 const short delay[4] =
497 { 250, 500, 750, 1000 }; 491 { 250, 500, 750, 1000 };
498 492
499 struct atkbd *atkbd = data; 493 struct input_dev *dev = atkbd->dev;
494 unsigned char param;
495 int i = 0, j = 0;
496
497 while (i < ARRAY_SIZE(period) - 1 && period[i] < dev->rep[REP_PERIOD])
498 i++;
499 dev->rep[REP_PERIOD] = period[i];
500
501 while (j < ARRAY_SIZE(period) - 1 && delay[j] < dev->rep[REP_DELAY])
502 j++;
503 dev->rep[REP_DELAY] = delay[j];
504
505 param = i | (j << 5);
506 return ps2_command(&atkbd->ps2dev, &param, ATKBD_CMD_SETREP);
507}
508
509static int atkbd_set_leds(struct atkbd *atkbd)
510{
500 struct input_dev *dev = atkbd->dev; 511 struct input_dev *dev = atkbd->dev;
501 unsigned char param[2]; 512 unsigned char param[2];
502 int i, j;
503 513
504 mutex_lock(&atkbd->event_mutex); 514 param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0)
515 | (test_bit(LED_NUML, dev->led) ? 2 : 0)
516 | (test_bit(LED_CAPSL, dev->led) ? 4 : 0);
517 if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS))
518 return -1;
505 519
506 if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask)) { 520 if (atkbd->extra) {
507 param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0) 521 param[0] = 0;
508 | (test_bit(LED_NUML, dev->led) ? 2 : 0) 522 param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
509 | (test_bit(LED_CAPSL, dev->led) ? 4 : 0); 523 | (test_bit(LED_SLEEP, dev->led) ? 0x02 : 0)
510 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS); 524 | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0)
511 525 | (test_bit(LED_MISC, dev->led) ? 0x10 : 0)
512 if (atkbd->extra) { 526 | (test_bit(LED_MUTE, dev->led) ? 0x20 : 0);
513 param[0] = 0; 527 if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS))
514 param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0) 528 return -1;
515 | (test_bit(LED_SLEEP, dev->led) ? 0x02 : 0)
516 | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0)
517 | (test_bit(LED_MISC, dev->led) ? 0x10 : 0)
518 | (test_bit(LED_MUTE, dev->led) ? 0x20 : 0);
519 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS);
520 }
521 } 529 }
522 530
523 if (test_and_clear_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask)) { 531 return 0;
524 i = j = 0; 532}
525 while (i < 31 && period[i] < dev->rep[REP_PERIOD]) 533
526 i++; 534/*
527 while (j < 3 && delay[j] < dev->rep[REP_DELAY]) 535 * atkbd_event_work() is used to complete processing of events that
528 j++; 536 * can not be processed by input_event() which is often called from
529 dev->rep[REP_PERIOD] = period[i]; 537 * interrupt context.
530 dev->rep[REP_DELAY] = delay[j]; 538 */
531 param[0] = i | (j << 5); 539
532 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP); 540static void atkbd_event_work(void *data)
533 } 541{
542 struct atkbd *atkbd = data;
543
544 mutex_lock(&atkbd->event_mutex);
545
546 if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask))
547 atkbd_set_leds(atkbd);
548
549 if (test_and_clear_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask))
550 atkbd_set_repeat_rate(atkbd);
534 551
535 mutex_unlock(&atkbd->event_mutex); 552 mutex_unlock(&atkbd->event_mutex);
536} 553}
@@ -975,7 +992,6 @@ static int atkbd_reconnect(struct serio *serio)
975{ 992{
976 struct atkbd *atkbd = serio_get_drvdata(serio); 993 struct atkbd *atkbd = serio_get_drvdata(serio);
977 struct serio_driver *drv = serio->drv; 994 struct serio_driver *drv = serio->drv;
978 unsigned char param[1];
979 995
980 if (!atkbd || !drv) { 996 if (!atkbd || !drv) {
981 printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n"); 997 printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n");
@@ -985,10 +1001,6 @@ static int atkbd_reconnect(struct serio *serio)
985 atkbd_disable(atkbd); 1001 atkbd_disable(atkbd);
986 1002
987 if (atkbd->write) { 1003 if (atkbd->write) {
988 param[0] = (test_bit(LED_SCROLLL, atkbd->dev->led) ? 1 : 0)
989 | (test_bit(LED_NUML, atkbd->dev->led) ? 2 : 0)
990 | (test_bit(LED_CAPSL, atkbd->dev->led) ? 4 : 0);
991
992 if (atkbd_probe(atkbd)) 1004 if (atkbd_probe(atkbd))
993 return -1; 1005 return -1;
994 if (atkbd->set != atkbd_select_set(atkbd, atkbd->set, atkbd->extra)) 1006 if (atkbd->set != atkbd_select_set(atkbd, atkbd->set, atkbd->extra))
@@ -996,8 +1008,13 @@ static int atkbd_reconnect(struct serio *serio)
996 1008
997 atkbd_activate(atkbd); 1009 atkbd_activate(atkbd);
998 1010
999 if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS)) 1011/*
1000 return -1; 1012 * Restore repeat rate and LEDs (that were reset by atkbd_activate)
1013 * to pre-resume state
1014 */
1015 if (!atkbd->softrepeat)
1016 atkbd_set_repeat_rate(atkbd);
1017 atkbd_set_leds(atkbd);
1001 } 1018 }
1002 1019
1003 atkbd_enable(atkbd); 1020 atkbd_enable(atkbd);
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index ccf0faeee5c1..a8efc1af36cb 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -94,7 +94,7 @@ static void call_bios(struct regs *regs)
94 94
95static ssize_t __init locate_wistron_bios(void __iomem *base) 95static ssize_t __init locate_wistron_bios(void __iomem *base)
96{ 96{
97 static const unsigned char __initdata signature[] = 97 static unsigned char __initdata signature[] =
98 { 0x42, 0x21, 0x55, 0x30 }; 98 { 0x42, 0x21, 0x55, 0x30 };
99 ssize_t offset; 99 ssize_t offset;
100 100
@@ -259,11 +259,11 @@ static int __init dmi_matched(struct dmi_system_id *dmi)
259 return 1; 259 return 1;
260} 260}
261 261
262static struct key_entry keymap_empty[] = { 262static struct key_entry keymap_empty[] __initdata = {
263 { KE_END, 0 } 263 { KE_END, 0 }
264}; 264};
265 265
266static struct key_entry keymap_fs_amilo_pro_v2000[] = { 266static struct key_entry keymap_fs_amilo_pro_v2000[] __initdata = {
267 { KE_KEY, 0x01, KEY_HELP }, 267 { KE_KEY, 0x01, KEY_HELP },
268 { KE_KEY, 0x11, KEY_PROG1 }, 268 { KE_KEY, 0x11, KEY_PROG1 },
269 { KE_KEY, 0x12, KEY_PROG2 }, 269 { KE_KEY, 0x12, KEY_PROG2 },
@@ -273,7 +273,7 @@ static struct key_entry keymap_fs_amilo_pro_v2000[] = {
273 { KE_END, 0 } 273 { KE_END, 0 }
274}; 274};
275 275
276static struct key_entry keymap_fujitsu_n3510[] = { 276static struct key_entry keymap_fujitsu_n3510[] __initdata = {
277 { KE_KEY, 0x11, KEY_PROG1 }, 277 { KE_KEY, 0x11, KEY_PROG1 },
278 { KE_KEY, 0x12, KEY_PROG2 }, 278 { KE_KEY, 0x12, KEY_PROG2 },
279 { KE_KEY, 0x36, KEY_WWW }, 279 { KE_KEY, 0x36, KEY_WWW },
@@ -285,7 +285,7 @@ static struct key_entry keymap_fujitsu_n3510[] = {
285 { KE_END, 0 } 285 { KE_END, 0 }
286}; 286};
287 287
288static struct key_entry keymap_wistron_ms2111[] = { 288static struct key_entry keymap_wistron_ms2111[] __initdata = {
289 { KE_KEY, 0x11, KEY_PROG1 }, 289 { KE_KEY, 0x11, KEY_PROG1 },
290 { KE_KEY, 0x12, KEY_PROG2 }, 290 { KE_KEY, 0x12, KEY_PROG2 },
291 { KE_KEY, 0x13, KEY_PROG3 }, 291 { KE_KEY, 0x13, KEY_PROG3 },
@@ -294,7 +294,7 @@ static struct key_entry keymap_wistron_ms2111[] = {
294 { KE_END, 0 } 294 { KE_END, 0 }
295}; 295};
296 296
297static struct key_entry keymap_wistron_ms2141[] = { 297static struct key_entry keymap_wistron_ms2141[] __initdata = {
298 { KE_KEY, 0x11, KEY_PROG1 }, 298 { KE_KEY, 0x11, KEY_PROG1 },
299 { KE_KEY, 0x12, KEY_PROG2 }, 299 { KE_KEY, 0x12, KEY_PROG2 },
300 { KE_WIFI, 0x30, 0 }, 300 { KE_WIFI, 0x30, 0 },
@@ -307,7 +307,7 @@ static struct key_entry keymap_wistron_ms2141[] = {
307 { KE_END, 0 } 307 { KE_END, 0 }
308}; 308};
309 309
310static struct key_entry keymap_acer_aspire_1500[] = { 310static struct key_entry keymap_acer_aspire_1500[] __initdata = {
311 { KE_KEY, 0x11, KEY_PROG1 }, 311 { KE_KEY, 0x11, KEY_PROG1 },
312 { KE_KEY, 0x12, KEY_PROG2 }, 312 { KE_KEY, 0x12, KEY_PROG2 },
313 { KE_WIFI, 0x30, 0 }, 313 { KE_WIFI, 0x30, 0 },
@@ -317,7 +317,7 @@ static struct key_entry keymap_acer_aspire_1500[] = {
317 { KE_END, 0 } 317 { KE_END, 0 }
318}; 318};
319 319
320static struct key_entry keymap_acer_travelmate_240[] = { 320static struct key_entry keymap_acer_travelmate_240[] __initdata = {
321 { KE_KEY, 0x31, KEY_MAIL }, 321 { KE_KEY, 0x31, KEY_MAIL },
322 { KE_KEY, 0x36, KEY_WWW }, 322 { KE_KEY, 0x36, KEY_WWW },
323 { KE_KEY, 0x11, KEY_PROG1 }, 323 { KE_KEY, 0x11, KEY_PROG1 },
@@ -327,7 +327,7 @@ static struct key_entry keymap_acer_travelmate_240[] = {
327 { KE_END, 0 } 327 { KE_END, 0 }
328}; 328};
329 329
330static struct key_entry keymap_aopen_1559as[] = { 330static struct key_entry keymap_aopen_1559as[] __initdata = {
331 { KE_KEY, 0x01, KEY_HELP }, 331 { KE_KEY, 0x01, KEY_HELP },
332 { KE_KEY, 0x06, KEY_PROG3 }, 332 { KE_KEY, 0x06, KEY_PROG3 },
333 { KE_KEY, 0x11, KEY_PROG1 }, 333 { KE_KEY, 0x11, KEY_PROG1 },
@@ -343,7 +343,7 @@ static struct key_entry keymap_aopen_1559as[] = {
343 * a list of buttons and their key codes (reported when loading this module 343 * a list of buttons and their key codes (reported when loading this module
344 * with force=1) and the output of dmidecode to $MODULE_AUTHOR. 344 * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
345 */ 345 */
346static struct dmi_system_id dmi_ids[] = { 346static struct dmi_system_id dmi_ids[] __initdata = {
347 { 347 {
348 .callback = dmi_matched, 348 .callback = dmi_matched,
349 .ident = "Fujitsu-Siemens Amilo Pro V2000", 349 .ident = "Fujitsu-Siemens Amilo Pro V2000",
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 2f0d28840810..54b696cfe1e3 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -238,8 +238,7 @@ static struct ps2pp_info *get_model_info(unsigned char model)
238 { 100, PS2PP_KIND_MX, /* MX510 */ 238 { 100, PS2PP_KIND_MX, /* MX510 */
239 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | 239 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
240 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, 240 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
241 { 111, PS2PP_KIND_MX, /* MX300 */ 241 { 111, PS2PP_KIND_MX, PS2PP_WHEEL | PS2PP_SIDE_BTN }, /* MX300 reports task button as side */
242 PS2PP_WHEEL | PS2PP_EXTRA_BTN | PS2PP_TASK_BTN },
243 { 112, PS2PP_KIND_MX, /* MX500 */ 242 { 112, PS2PP_KIND_MX, /* MX500 */
244 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | 243 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
245 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, 244 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 6d9ec9ab1b90..ae5871a0e060 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -183,21 +183,26 @@ static struct attribute_group trackpoint_attr_group = {
183 .attrs = trackpoint_attrs, 183 .attrs = trackpoint_attrs,
184}; 184};
185 185
186static void trackpoint_disconnect(struct psmouse *psmouse) 186static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *firmware_id)
187{ 187{
188 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group); 188 unsigned char param[2] = { 0 };
189 189
190 kfree(psmouse->private); 190 if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
191 psmouse->private = NULL; 191 return -1;
192
193 if (param[0] != TP_MAGIC_IDENT)
194 return -1;
195
196 if (firmware_id)
197 *firmware_id = param[1];
198
199 return 0;
192} 200}
193 201
194static int trackpoint_sync(struct psmouse *psmouse) 202static int trackpoint_sync(struct psmouse *psmouse)
195{ 203{
196 unsigned char toggle;
197 struct trackpoint_data *tp = psmouse->private; 204 struct trackpoint_data *tp = psmouse->private;
198 205 unsigned char toggle;
199 if (!tp)
200 return -1;
201 206
202 /* Disable features that may make device unusable with this driver */ 207 /* Disable features that may make device unusable with this driver */
203 trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle); 208 trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle);
@@ -263,27 +268,38 @@ static void trackpoint_defaults(struct trackpoint_data *tp)
263 tp->ext_dev = TP_DEF_EXT_DEV; 268 tp->ext_dev = TP_DEF_EXT_DEV;
264} 269}
265 270
271static void trackpoint_disconnect(struct psmouse *psmouse)
272{
273 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group);
274
275 kfree(psmouse->private);
276 psmouse->private = NULL;
277}
278
279static int trackpoint_reconnect(struct psmouse *psmouse)
280{
281 if (trackpoint_start_protocol(psmouse, NULL))
282 return -1;
283
284 if (trackpoint_sync(psmouse))
285 return -1;
286
287 return 0;
288}
289
266int trackpoint_detect(struct psmouse *psmouse, int set_properties) 290int trackpoint_detect(struct psmouse *psmouse, int set_properties)
267{ 291{
268 struct trackpoint_data *priv; 292 struct trackpoint_data *priv;
269 struct ps2dev *ps2dev = &psmouse->ps2dev; 293 struct ps2dev *ps2dev = &psmouse->ps2dev;
270 unsigned char firmware_id; 294 unsigned char firmware_id;
271 unsigned char button_info; 295 unsigned char button_info;
272 unsigned char param[2];
273
274 param[0] = param[1] = 0;
275 296
276 if (ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID))) 297 if (trackpoint_start_protocol(psmouse, &firmware_id))
277 return -1;
278
279 if (param[0] != TP_MAGIC_IDENT)
280 return -1; 298 return -1;
281 299
282 if (!set_properties) 300 if (!set_properties)
283 return 0; 301 return 0;
284 302
285 firmware_id = param[1];
286
287 if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { 303 if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) {
288 printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n"); 304 printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n");
289 button_info = 0; 305 button_info = 0;
@@ -296,7 +312,7 @@ int trackpoint_detect(struct psmouse *psmouse, int set_properties)
296 psmouse->vendor = "IBM"; 312 psmouse->vendor = "IBM";
297 psmouse->name = "TrackPoint"; 313 psmouse->name = "TrackPoint";
298 314
299 psmouse->reconnect = trackpoint_sync; 315 psmouse->reconnect = trackpoint_reconnect;
300 psmouse->disconnect = trackpoint_disconnect; 316 psmouse->disconnect = trackpoint_disconnect;
301 317
302 trackpoint_defaults(priv); 318 trackpoint_defaults(priv);
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 61a6f977846f..ed202f2f251a 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -177,6 +177,11 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
177 return -1; 177 return -1;
178 } 178 }
179 179
180 if (send && !param) {
181 WARN_ON(1);
182 return -1;
183 }
184
180 mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING); 185 mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING);
181 186
182 serio_pause_rx(ps2dev->serio); 187 serio_pause_rx(ps2dev->serio);
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 6521034bc933..3e76ad71c9a0 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -62,6 +62,7 @@ static LIST_HEAD(serio_list);
62 62
63static struct bus_type serio_bus; 63static struct bus_type serio_bus;
64 64
65static void serio_add_driver(struct serio_driver *drv);
65static void serio_add_port(struct serio *serio); 66static void serio_add_port(struct serio *serio);
66static void serio_destroy_port(struct serio *serio); 67static void serio_destroy_port(struct serio *serio);
67static void serio_reconnect_port(struct serio *serio); 68static void serio_reconnect_port(struct serio *serio);
@@ -140,8 +141,14 @@ static void serio_release_driver(struct serio *serio)
140 141
141static void serio_find_driver(struct serio *serio) 142static void serio_find_driver(struct serio *serio)
142{ 143{
144 int error;
145
143 down_write(&serio_bus.subsys.rwsem); 146 down_write(&serio_bus.subsys.rwsem);
144 device_attach(&serio->dev); 147 error = device_attach(&serio->dev);
148 if (error < 0)
149 printk(KERN_WARNING
150 "serio: device_attach() failed for %s (%s), error: %d\n",
151 serio->phys, serio->name, error);
145 up_write(&serio_bus.subsys.rwsem); 152 up_write(&serio_bus.subsys.rwsem);
146} 153}
147 154
@@ -272,7 +279,6 @@ static struct serio_event *serio_get_event(void)
272static void serio_handle_event(void) 279static void serio_handle_event(void)
273{ 280{
274 struct serio_event *event; 281 struct serio_event *event;
275 struct serio_driver *serio_drv;
276 282
277 mutex_lock(&serio_mutex); 283 mutex_lock(&serio_mutex);
278 284
@@ -304,8 +310,7 @@ static void serio_handle_event(void)
304 break; 310 break;
305 311
306 case SERIO_REGISTER_DRIVER: 312 case SERIO_REGISTER_DRIVER:
307 serio_drv = event->object; 313 serio_add_driver(event->object);
308 driver_register(&serio_drv->driver);
309 break; 314 break;
310 315
311 default: 316 default:
@@ -525,6 +530,7 @@ static void serio_init_port(struct serio *serio)
525 530
526 __module_get(THIS_MODULE); 531 __module_get(THIS_MODULE);
527 532
533 INIT_LIST_HEAD(&serio->node);
528 spin_lock_init(&serio->lock); 534 spin_lock_init(&serio->lock);
529 mutex_init(&serio->drv_mutex); 535 mutex_init(&serio->drv_mutex);
530 device_initialize(&serio->dev); 536 device_initialize(&serio->dev);
@@ -542,6 +548,8 @@ static void serio_init_port(struct serio *serio)
542 */ 548 */
543static void serio_add_port(struct serio *serio) 549static void serio_add_port(struct serio *serio)
544{ 550{
551 int error;
552
545 if (serio->parent) { 553 if (serio->parent) {
546 serio_pause_rx(serio->parent); 554 serio_pause_rx(serio->parent);
547 serio->parent->child = serio; 555 serio->parent->child = serio;
@@ -551,9 +559,19 @@ static void serio_add_port(struct serio *serio)
551 list_add_tail(&serio->node, &serio_list); 559 list_add_tail(&serio->node, &serio_list);
552 if (serio->start) 560 if (serio->start)
553 serio->start(serio); 561 serio->start(serio);
554 device_add(&serio->dev); 562 error = device_add(&serio->dev);
555 sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group); 563 if (error)
556 serio->registered = 1; 564 printk(KERN_ERR
565 "serio: device_add() failed for %s (%s), error: %d\n",
566 serio->phys, serio->name, error);
567 else {
568 serio->registered = 1;
569 error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
570 if (error)
571 printk(KERN_ERR
572 "serio: sysfs_create_group() failed for %s (%s), error: %d\n",
573 serio->phys, serio->name, error);
574 }
557} 575}
558 576
559/* 577/*
@@ -583,10 +601,10 @@ static void serio_destroy_port(struct serio *serio)
583 if (serio->registered) { 601 if (serio->registered) {
584 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group); 602 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
585 device_del(&serio->dev); 603 device_del(&serio->dev);
586 list_del_init(&serio->node);
587 serio->registered = 0; 604 serio->registered = 0;
588 } 605 }
589 606
607 list_del_init(&serio->node);
590 serio_remove_pending_events(serio); 608 serio_remove_pending_events(serio);
591 put_device(&serio->dev); 609 put_device(&serio->dev);
592} 610}
@@ -756,6 +774,17 @@ static struct bus_type serio_bus = {
756 .remove = serio_driver_remove, 774 .remove = serio_driver_remove,
757}; 775};
758 776
777static void serio_add_driver(struct serio_driver *drv)
778{
779 int error;
780
781 error = driver_register(&drv->driver);
782 if (error)
783 printk(KERN_ERR
784 "serio: driver_register() failed for %s, error: %d\n",
785 drv->driver.name, error);
786}
787
759void __serio_register_driver(struct serio_driver *drv, struct module *owner) 788void __serio_register_driver(struct serio_driver *drv, struct module *owner)
760{ 789{
761 drv->driver.bus = &serio_bus; 790 drv->driver.bus = &serio_bus;
@@ -903,18 +932,26 @@ irqreturn_t serio_interrupt(struct serio *serio,
903 932
904static int __init serio_init(void) 933static int __init serio_init(void)
905{ 934{
906 serio_task = kthread_run(serio_thread, NULL, "kseriod"); 935 int error;
907 if (IS_ERR(serio_task)) {
908 printk(KERN_ERR "serio: Failed to start kseriod\n");
909 return PTR_ERR(serio_task);
910 }
911 936
912 serio_bus.dev_attrs = serio_device_attrs; 937 serio_bus.dev_attrs = serio_device_attrs;
913 serio_bus.drv_attrs = serio_driver_attrs; 938 serio_bus.drv_attrs = serio_driver_attrs;
914 serio_bus.match = serio_bus_match; 939 serio_bus.match = serio_bus_match;
915 serio_bus.uevent = serio_uevent; 940 serio_bus.uevent = serio_uevent;
916 serio_bus.resume = serio_resume; 941 serio_bus.resume = serio_resume;
917 bus_register(&serio_bus); 942 error = bus_register(&serio_bus);
943 if (error) {
944 printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error);
945 return error;
946 }
947
948 serio_task = kthread_run(serio_thread, NULL, "kseriod");
949 if (IS_ERR(serio_task)) {
950 bus_unregister(&serio_bus);
951 error = PTR_ERR(serio_task);
952 printk(KERN_ERR "serio: Failed to start kseriod, error: %d\n", error);
953 return error;
954 }
918 955
919 return 0; 956 return 0;
920} 957}
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index df198cf76f52..3719fcb04b8f 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -111,14 +111,28 @@
111#define NAME_BUFSIZE 80 /* size of product name, path buffers */ 111#define NAME_BUFSIZE 80 /* size of product name, path buffers */
112#define DATA_BUFSIZE 63 /* size of URB data buffers */ 112#define DATA_BUFSIZE 63 /* size of URB data buffers */
113 113
114/*
115 * Duplicate event filtering time.
116 * Sequential, identical KIND_FILTERED inputs with less than
117 * FILTER_TIME milliseconds between them are considered as repeat
118 * events. The hardware generates 5 events for the first keypress
119 * and we have to take this into account for an accurate repeat
120 * behaviour.
121 */
122#define FILTER_TIME 60 /* msec */
123
114static unsigned long channel_mask; 124static unsigned long channel_mask;
115module_param(channel_mask, ulong, 0444); 125module_param(channel_mask, ulong, 0644);
116MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore"); 126MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore");
117 127
118static int debug; 128static int debug;
119module_param(debug, int, 0444); 129module_param(debug, int, 0644);
120MODULE_PARM_DESC(debug, "Enable extra debug messages and information"); 130MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
121 131
132static int repeat_filter = FILTER_TIME;
133module_param(repeat_filter, int, 0644);
134MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec");
135
122#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) 136#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
123#undef err 137#undef err
124#define err(format, arg...) printk(KERN_ERR format , ## arg) 138#define err(format, arg...) printk(KERN_ERR format , ## arg)
@@ -143,18 +157,6 @@ MODULE_DEVICE_TABLE(usb, ati_remote_table);
143static char init1[] = { 0x01, 0x00, 0x20, 0x14 }; 157static char init1[] = { 0x01, 0x00, 0x20, 0x14 };
144static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 }; 158static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 };
145 159
146/* Acceleration curve for directional control pad */
147static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
148
149/* Duplicate event filtering time.
150 * Sequential, identical KIND_FILTERED inputs with less than
151 * FILTER_TIME jiffies between them are considered as repeat
152 * events. The hardware generates 5 events for the first keypress
153 * and we have to take this into account for an accurate repeat
154 * behaviour.
155 */
156#define FILTER_TIME 60 /* msec */
157
158struct ati_remote { 160struct ati_remote {
159 struct input_dev *idev; 161 struct input_dev *idev;
160 struct usb_device *udev; 162 struct usb_device *udev;
@@ -412,6 +414,43 @@ static int ati_remote_event_lookup(int rem, unsigned char d1, unsigned char d2)
412} 414}
413 415
414/* 416/*
417 * ati_remote_compute_accel
418 *
419 * Implements acceleration curve for directional control pad
420 * If elapsed time since last event is > 1/4 second, user "stopped",
421 * so reset acceleration. Otherwise, user is probably holding the control
422 * pad down, so we increase acceleration, ramping up over two seconds to
423 * a maximum speed.
424 */
425static int ati_remote_compute_accel(struct ati_remote *ati_remote)
426{
427 static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
428 unsigned long now = jiffies;
429 int acc;
430
431 if (time_after(now, ati_remote->old_jiffies + msecs_to_jiffies(250))) {
432 acc = 1;
433 ati_remote->acc_jiffies = now;
434 }
435 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(125)))
436 acc = accel[0];
437 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(250)))
438 acc = accel[1];
439 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(500)))
440 acc = accel[2];
441 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1000)))
442 acc = accel[3];
443 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1500)))
444 acc = accel[4];
445 else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(2000)))
446 acc = accel[5];
447 else
448 acc = accel[6];
449
450 return acc;
451}
452
453/*
415 * ati_remote_report_input 454 * ati_remote_report_input
416 */ 455 */
417static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) 456static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
@@ -464,9 +503,9 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
464 503
465 if (ati_remote_tbl[index].kind == KIND_FILTERED) { 504 if (ati_remote_tbl[index].kind == KIND_FILTERED) {
466 /* Filter duplicate events which happen "too close" together. */ 505 /* Filter duplicate events which happen "too close" together. */
467 if ((ati_remote->old_data[0] == data[1]) && 506 if (ati_remote->old_data[0] == data[1] &&
468 (ati_remote->old_data[1] == data[2]) && 507 ati_remote->old_data[1] == data[2] &&
469 time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(FILTER_TIME))) { 508 time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) {
470 ati_remote->repeat_count++; 509 ati_remote->repeat_count++;
471 } else { 510 } else {
472 ati_remote->repeat_count = 0; 511 ati_remote->repeat_count = 0;
@@ -476,75 +515,61 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
476 ati_remote->old_data[1] = data[2]; 515 ati_remote->old_data[1] = data[2];
477 ati_remote->old_jiffies = jiffies; 516 ati_remote->old_jiffies = jiffies;
478 517
479 if ((ati_remote->repeat_count > 0) 518 if (ati_remote->repeat_count > 0 &&
480 && (ati_remote->repeat_count < 5)) 519 ati_remote->repeat_count < 5)
481 return; 520 return;
482 521
483 522
484 input_regs(dev, regs); 523 input_regs(dev, regs);
485 input_event(dev, ati_remote_tbl[index].type, 524 input_event(dev, ati_remote_tbl[index].type,
486 ati_remote_tbl[index].code, 1); 525 ati_remote_tbl[index].code, 1);
526 input_sync(dev);
487 input_event(dev, ati_remote_tbl[index].type, 527 input_event(dev, ati_remote_tbl[index].type,
488 ati_remote_tbl[index].code, 0); 528 ati_remote_tbl[index].code, 0);
489 input_sync(dev); 529 input_sync(dev);
490 530
491 return; 531 } else {
492 }
493 532
494 /* 533 /*
495 * Other event kinds are from the directional control pad, and have an 534 * Other event kinds are from the directional control pad, and have an
496 * acceleration factor applied to them. Without this acceleration, the 535 * acceleration factor applied to them. Without this acceleration, the
497 * control pad is mostly unusable. 536 * control pad is mostly unusable.
498 * 537 */
499 * If elapsed time since last event is > 1/4 second, user "stopped", 538 acc = ati_remote_compute_accel(ati_remote);
500 * so reset acceleration. Otherwise, user is probably holding the control 539
501 * pad down, so we increase acceleration, ramping up over two seconds to 540 input_regs(dev, regs);
502 * a maximum speed. The acceleration curve is #defined above. 541 switch (ati_remote_tbl[index].kind) {
503 */ 542 case KIND_ACCEL:
504 if (time_after(jiffies, ati_remote->old_jiffies + (HZ >> 2))) { 543 input_event(dev, ati_remote_tbl[index].type,
505 acc = 1; 544 ati_remote_tbl[index].code,
506 ati_remote->acc_jiffies = jiffies; 545 ati_remote_tbl[index].value * acc);
507 } 546 break;
508 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3))) acc = accel[0]; 547 case KIND_LU:
509 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2))) acc = accel[1]; 548 input_report_rel(dev, REL_X, -acc);
510 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1))) acc = accel[2]; 549 input_report_rel(dev, REL_Y, -acc);
511 else if (time_before(jiffies, ati_remote->acc_jiffies + HZ)) acc = accel[3]; 550 break;
512 else if (time_before(jiffies, ati_remote->acc_jiffies + HZ+(HZ>>1))) acc = accel[4]; 551 case KIND_RU:
513 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ << 1))) acc = accel[5]; 552 input_report_rel(dev, REL_X, acc);
514 else acc = accel[6]; 553 input_report_rel(dev, REL_Y, -acc);
515 554 break;
516 input_regs(dev, regs); 555 case KIND_LD:
517 switch (ati_remote_tbl[index].kind) { 556 input_report_rel(dev, REL_X, -acc);
518 case KIND_ACCEL: 557 input_report_rel(dev, REL_Y, acc);
519 input_event(dev, ati_remote_tbl[index].type, 558 break;
520 ati_remote_tbl[index].code, 559 case KIND_RD:
521 ati_remote_tbl[index].value * acc); 560 input_report_rel(dev, REL_X, acc);
522 break; 561 input_report_rel(dev, REL_Y, acc);
523 case KIND_LU: 562 break;
524 input_report_rel(dev, REL_X, -acc); 563 default:
525 input_report_rel(dev, REL_Y, -acc); 564 dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n",
526 break; 565 ati_remote_tbl[index].kind);
527 case KIND_RU: 566 }
528 input_report_rel(dev, REL_X, acc); 567 input_sync(dev);
529 input_report_rel(dev, REL_Y, -acc);
530 break;
531 case KIND_LD:
532 input_report_rel(dev, REL_X, -acc);
533 input_report_rel(dev, REL_Y, acc);
534 break;
535 case KIND_RD:
536 input_report_rel(dev, REL_X, acc);
537 input_report_rel(dev, REL_Y, acc);
538 break;
539 default:
540 dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n",
541 ati_remote_tbl[index].kind);
542 }
543 input_sync(dev);
544 568
545 ati_remote->old_jiffies = jiffies; 569 ati_remote->old_jiffies = jiffies;
546 ati_remote->old_data[0] = data[1]; 570 ati_remote->old_data[0] = data[1];
547 ati_remote->old_data[1] = data[2]; 571 ati_remote->old_data[1] = data[2];
572 }
548} 573}
549 574
550/* 575/*
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 028e1ad89f5d..7208839f2dbf 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -607,7 +607,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
607 607
608 } 608 }
609 609
610 if (usage->hat_min < usage->hat_max || usage->hat_dir) { 610 if (usage->type == EV_ABS &&
611 (usage->hat_min < usage->hat_max || usage->hat_dir)) {
611 int i; 612 int i;
612 for (i = usage->code; i < usage->code + 2 && i <= max; i++) { 613 for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
613 input_set_abs_params(input, i, -1, 1, 0, 0); 614 input_set_abs_params(input, i, -1, 1, 0, 0);
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index 70477f02cc29..f6b839c257a7 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -49,7 +49,7 @@ struct hiddev {
49 int open; 49 int open;
50 wait_queue_head_t wait; 50 wait_queue_head_t wait;
51 struct hid_device *hid; 51 struct hid_device *hid;
52 struct hiddev_list *list; 52 struct list_head list;
53}; 53};
54 54
55struct hiddev_list { 55struct hiddev_list {
@@ -59,7 +59,7 @@ struct hiddev_list {
59 unsigned flags; 59 unsigned flags;
60 struct fasync_struct *fasync; 60 struct fasync_struct *fasync;
61 struct hiddev *hiddev; 61 struct hiddev *hiddev;
62 struct hiddev_list *next; 62 struct list_head node;
63}; 63};
64 64
65static struct hiddev *hiddev_table[HIDDEV_MINORS]; 65static struct hiddev *hiddev_table[HIDDEV_MINORS];
@@ -73,12 +73,15 @@ static struct hiddev *hiddev_table[HIDDEV_MINORS];
73static struct hid_report * 73static struct hid_report *
74hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo) 74hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
75{ 75{
76 unsigned flags = rinfo->report_id & ~HID_REPORT_ID_MASK; 76 unsigned int flags = rinfo->report_id & ~HID_REPORT_ID_MASK;
77 unsigned int rid = rinfo->report_id & HID_REPORT_ID_MASK;
77 struct hid_report_enum *report_enum; 78 struct hid_report_enum *report_enum;
79 struct hid_report *report;
78 struct list_head *list; 80 struct list_head *list;
79 81
80 if (rinfo->report_type < HID_REPORT_TYPE_MIN || 82 if (rinfo->report_type < HID_REPORT_TYPE_MIN ||
81 rinfo->report_type > HID_REPORT_TYPE_MAX) return NULL; 83 rinfo->report_type > HID_REPORT_TYPE_MAX)
84 return NULL;
82 85
83 report_enum = hid->report_enum + 86 report_enum = hid->report_enum +
84 (rinfo->report_type - HID_REPORT_TYPE_MIN); 87 (rinfo->report_type - HID_REPORT_TYPE_MIN);
@@ -88,21 +91,25 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
88 break; 91 break;
89 92
90 case HID_REPORT_ID_FIRST: 93 case HID_REPORT_ID_FIRST:
91 list = report_enum->report_list.next; 94 if (list_empty(&report_enum->report_list))
92 if (list == &report_enum->report_list)
93 return NULL; 95 return NULL;
94 rinfo->report_id = ((struct hid_report *) list)->id; 96
97 list = report_enum->report_list.next;
98 report = list_entry(list, struct hid_report, list);
99 rinfo->report_id = report->id;
95 break; 100 break;
96 101
97 case HID_REPORT_ID_NEXT: 102 case HID_REPORT_ID_NEXT:
98 list = (struct list_head *) 103 report = report_enum->report_id_hash[rid];
99 report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK]; 104 if (!report)
100 if (list == NULL)
101 return NULL; 105 return NULL;
102 list = list->next; 106
107 list = report->list.next;
103 if (list == &report_enum->report_list) 108 if (list == &report_enum->report_list)
104 return NULL; 109 return NULL;
105 rinfo->report_id = ((struct hid_report *) list)->id; 110
111 report = list_entry(list, struct hid_report, list);
112 rinfo->report_id = report->id;
106 break; 113 break;
107 114
108 default: 115 default:
@@ -125,12 +132,13 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
125 struct hid_field *field; 132 struct hid_field *field;
126 133
127 if (uref->report_type < HID_REPORT_TYPE_MIN || 134 if (uref->report_type < HID_REPORT_TYPE_MIN ||
128 uref->report_type > HID_REPORT_TYPE_MAX) return NULL; 135 uref->report_type > HID_REPORT_TYPE_MAX)
136 return NULL;
129 137
130 report_enum = hid->report_enum + 138 report_enum = hid->report_enum +
131 (uref->report_type - HID_REPORT_TYPE_MIN); 139 (uref->report_type - HID_REPORT_TYPE_MIN);
132 140
133 list_for_each_entry(report, &report_enum->report_list, list) 141 list_for_each_entry(report, &report_enum->report_list, list) {
134 for (i = 0; i < report->maxfield; i++) { 142 for (i = 0; i < report->maxfield; i++) {
135 field = report->field[i]; 143 field = report->field[i];
136 for (j = 0; j < field->maxusage; j++) { 144 for (j = 0; j < field->maxusage; j++) {
@@ -142,6 +150,7 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
142 } 150 }
143 } 151 }
144 } 152 }
153 }
145 154
146 return NULL; 155 return NULL;
147} 156}
@@ -150,9 +159,9 @@ static void hiddev_send_event(struct hid_device *hid,
150 struct hiddev_usage_ref *uref) 159 struct hiddev_usage_ref *uref)
151{ 160{
152 struct hiddev *hiddev = hid->hiddev; 161 struct hiddev *hiddev = hid->hiddev;
153 struct hiddev_list *list = hiddev->list; 162 struct hiddev_list *list;
154 163
155 while (list) { 164 list_for_each_entry(list, &hiddev->list, node) {
156 if (uref->field_index != HID_FIELD_INDEX_NONE || 165 if (uref->field_index != HID_FIELD_INDEX_NONE ||
157 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 166 (list->flags & HIDDEV_FLAG_REPORT) != 0) {
158 list->buffer[list->head] = *uref; 167 list->buffer[list->head] = *uref;
@@ -160,8 +169,6 @@ static void hiddev_send_event(struct hid_device *hid,
160 (HIDDEV_BUFFER_SIZE - 1); 169 (HIDDEV_BUFFER_SIZE - 1);
161 kill_fasync(&list->fasync, SIGIO, POLL_IN); 170 kill_fasync(&list->fasync, SIGIO, POLL_IN);
162 } 171 }
163
164 list = list->next;
165 } 172 }
166 173
167 wake_up_interruptible(&hiddev->wait); 174 wake_up_interruptible(&hiddev->wait);
@@ -180,7 +187,7 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
180 uref.report_type = 187 uref.report_type =
181 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : 188 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
182 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 189 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
183 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); 190 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE : 0));
184 uref.report_id = field->report->id; 191 uref.report_id = field->report->id;
185 uref.field_index = field->index; 192 uref.field_index = field->index;
186 uref.usage_index = (usage - field->usage); 193 uref.usage_index = (usage - field->usage);
@@ -200,7 +207,7 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
200 uref.report_type = 207 uref.report_type =
201 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : 208 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
202 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 209 ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
203 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); 210 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE : 0));
204 uref.report_id = report->id; 211 uref.report_id = report->id;
205 uref.field_index = HID_FIELD_INDEX_NONE; 212 uref.field_index = HID_FIELD_INDEX_NONE;
206 213
@@ -213,7 +220,9 @@ static int hiddev_fasync(int fd, struct file *file, int on)
213{ 220{
214 int retval; 221 int retval;
215 struct hiddev_list *list = file->private_data; 222 struct hiddev_list *list = file->private_data;
223
216 retval = fasync_helper(fd, file, on, &list->fasync); 224 retval = fasync_helper(fd, file, on, &list->fasync);
225
217 return retval < 0 ? retval : 0; 226 return retval < 0 ? retval : 0;
218} 227}
219 228
@@ -224,14 +233,9 @@ static int hiddev_fasync(int fd, struct file *file, int on)
224static int hiddev_release(struct inode * inode, struct file * file) 233static int hiddev_release(struct inode * inode, struct file * file)
225{ 234{
226 struct hiddev_list *list = file->private_data; 235 struct hiddev_list *list = file->private_data;
227 struct hiddev_list **listptr;
228 236
229 listptr = &list->hiddev->list;
230 hiddev_fasync(-1, file, 0); 237 hiddev_fasync(-1, file, 0);
231 238 list_del(&list->node);
232 while (*listptr && (*listptr != list))
233 listptr = &((*listptr)->next);
234 *listptr = (*listptr)->next;
235 239
236 if (!--list->hiddev->open) { 240 if (!--list->hiddev->open) {
237 if (list->hiddev->exist) 241 if (list->hiddev->exist)
@@ -248,7 +252,8 @@ static int hiddev_release(struct inode * inode, struct file * file)
248/* 252/*
249 * open file op 253 * open file op
250 */ 254 */
251static int hiddev_open(struct inode * inode, struct file * file) { 255static int hiddev_open(struct inode *inode, struct file *file)
256{
252 struct hiddev_list *list; 257 struct hiddev_list *list;
253 258
254 int i = iminor(inode) - HIDDEV_MINOR_BASE; 259 int i = iminor(inode) - HIDDEV_MINOR_BASE;
@@ -260,9 +265,7 @@ static int hiddev_open(struct inode * inode, struct file * file) {
260 return -ENOMEM; 265 return -ENOMEM;
261 266
262 list->hiddev = hiddev_table[i]; 267 list->hiddev = hiddev_table[i];
263 list->next = hiddev_table[i]->list; 268 list_add_tail(&list->node, &hiddev_table[i]->list);
264 hiddev_table[i]->list = list;
265
266 file->private_data = list; 269 file->private_data = list;
267 270
268 if (!list->hiddev->open++) 271 if (!list->hiddev->open++)
@@ -362,6 +365,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
362static unsigned int hiddev_poll(struct file *file, poll_table *wait) 365static unsigned int hiddev_poll(struct file *file, poll_table *wait)
363{ 366{
364 struct hiddev_list *list = file->private_data; 367 struct hiddev_list *list = file->private_data;
368
365 poll_wait(file, &list->hiddev->wait, wait); 369 poll_wait(file, &list->hiddev->wait, wait);
366 if (list->head != list->tail) 370 if (list->head != list->tail)
367 return POLLIN | POLLRDNORM; 371 return POLLIN | POLLRDNORM;
@@ -382,7 +386,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
382 struct hiddev_collection_info cinfo; 386 struct hiddev_collection_info cinfo;
383 struct hiddev_report_info rinfo; 387 struct hiddev_report_info rinfo;
384 struct hiddev_field_info finfo; 388 struct hiddev_field_info finfo;
385 struct hiddev_usage_ref_multi *uref_multi=NULL; 389 struct hiddev_usage_ref_multi *uref_multi = NULL;
386 struct hiddev_usage_ref *uref; 390 struct hiddev_usage_ref *uref;
387 struct hiddev_devinfo dinfo; 391 struct hiddev_devinfo dinfo;
388 struct hid_report *report; 392 struct hid_report *report;
@@ -764,15 +768,15 @@ int hiddev_connect(struct hid_device *hid)
764 } 768 }
765 769
766 init_waitqueue_head(&hiddev->wait); 770 init_waitqueue_head(&hiddev->wait);
767 771 INIT_LIST_HEAD(&hiddev->list);
768 hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
769
770 hiddev->hid = hid; 772 hiddev->hid = hid;
771 hiddev->exist = 1; 773 hiddev->exist = 1;
772 774
773 hid->minor = hid->intf->minor; 775 hid->minor = hid->intf->minor;
774 hid->hiddev = hiddev; 776 hid->hiddev = hiddev;
775 777
778 hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
779
776 return 0; 780 return 0;
777} 781}
778 782
diff --git a/include/linux/input.h b/include/linux/input.h
index 56f1e0e1e598..b3253ab72ff7 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -893,7 +893,6 @@ struct input_dev {
893 893
894 int (*open)(struct input_dev *dev); 894 int (*open)(struct input_dev *dev);
895 void (*close)(struct input_dev *dev); 895 void (*close)(struct input_dev *dev);
896 int (*accept)(struct input_dev *dev, struct file *file);
897 int (*flush)(struct input_dev *dev, struct file *file); 896 int (*flush)(struct input_dev *dev, struct file *file);
898 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); 897 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
899 int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect); 898 int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
@@ -961,6 +960,26 @@ struct input_dev {
961 960
962struct input_handle; 961struct input_handle;
963 962
963/**
964 * struct input_handler - implements one of interfaces for input devices
965 * @private: driver-specific data
966 * @event: event handler
967 * @connect: called when attaching a handler to an input device
968 * @disconnect: disconnects a handler from input device
969 * @start: starts handler for given handle. This function is called by
970 * input core right after connect() method and also when a process
971 * that "grabbed" a device releases it
972 * @fops: file operations this driver implements
973 * @minor: beginning of range of 32 minors for devices this driver
974 * can provide
975 * @name: name of the handler, to be shown in /proc/bus/input/handlers
976 * @id_table: pointer to a table of input_device_ids this driver can
977 * handle
978 * @blacklist: prointer to a table of input_device_ids this driver should
979 * ignore even if they match @id_table
980 * @h_list: list of input handles associated with the handler
981 * @node: for placing the driver onto input_handler_list
982 */
964struct input_handler { 983struct input_handler {
965 984
966 void *private; 985 void *private;
@@ -968,6 +987,7 @@ struct input_handler {
968 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 987 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
969 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id); 988 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
970 void (*disconnect)(struct input_handle *handle); 989 void (*disconnect)(struct input_handle *handle);
990 void (*start)(struct input_handle *handle);
971 991
972 const struct file_operations *fops; 992 const struct file_operations *fops;
973 int minor; 993 int minor;
@@ -1030,10 +1050,10 @@ void input_release_device(struct input_handle *);
1030int input_open_device(struct input_handle *); 1050int input_open_device(struct input_handle *);
1031void input_close_device(struct input_handle *); 1051void input_close_device(struct input_handle *);
1032 1052
1033int input_accept_process(struct input_handle *handle, struct file *file);
1034int input_flush_device(struct input_handle* handle, struct file* file); 1053int input_flush_device(struct input_handle* handle, struct file* file);
1035 1054
1036void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 1055void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
1056void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
1037 1057
1038static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) 1058static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
1039{ 1059{