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
...

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