aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/keyboard.c4
-rw-r--r--drivers/char/sonypi.c146
-rw-r--r--drivers/input/evdev.c1
-rw-r--r--drivers/input/input.c389
-rw-r--r--drivers/input/joydev.c6
-rw-r--r--drivers/input/misc/uinput.c181
-rw-r--r--drivers/input/mouse/alps.c29
-rw-r--r--drivers/input/mouse/logips2pp.c2
-rw-r--r--drivers/input/mouse/psmouse-base.c2
-rw-r--r--drivers/input/mouse/synaptics.c14
-rw-r--r--drivers/input/serio/Kconfig2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h14
-rw-r--r--drivers/input/serio/i8042.c60
-rw-r--r--drivers/input/serio/serio.c42
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/input/touchscreen/Kconfig2
-rw-r--r--drivers/usb/input/acecad.c14
-rw-r--r--drivers/usb/input/aiptek.c6
-rw-r--r--drivers/usb/input/ati_remote.c8
-rw-r--r--drivers/usb/input/hid-core.c24
-rw-r--r--drivers/usb/input/hid-input.c6
-rw-r--r--drivers/usb/input/itmtouch.c6
-rw-r--r--drivers/usb/input/kbtab.c6
-rw-r--r--drivers/usb/input/mtouchusb.c6
-rw-r--r--drivers/usb/input/powermate.c6
-rw-r--r--drivers/usb/input/touchkitusb.c7
-rw-r--r--drivers/usb/input/usbkbd.c6
-rw-r--r--drivers/usb/input/usbmouse.c6
-rw-r--r--drivers/usb/input/wacom.c6
-rw-r--r--drivers/usb/input/xpad.c6
-rw-r--r--drivers/usb/media/konicawc.c6
-rw-r--r--include/linux/input.h6
-rw-r--r--include/linux/uinput.h5
-rw-r--r--include/linux/usb_input.h25
34 files changed, 530 insertions, 520 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 7b19e02f112f..523fd3c8bbaa 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -198,10 +198,10 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
198 198
199 if (scancode >= dev->keycodemax) 199 if (scancode >= dev->keycodemax)
200 return -EINVAL; 200 return -EINVAL;
201 if (keycode > KEY_MAX)
202 return -EINVAL;
203 if (keycode < 0 || keycode > KEY_MAX) 201 if (keycode < 0 || keycode > KEY_MAX)
204 return -EINVAL; 202 return -EINVAL;
203 if (keycode >> (dev->keycodesize * 8))
204 return -EINVAL;
205 205
206 oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode); 206 oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
207 207
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index fd042060809a..cefbe985e55c 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -439,6 +439,11 @@ static struct {
439 { 0, 0 }, 439 { 0, 0 },
440}; 440};
441 441
442struct sonypi_keypress {
443 struct input_dev *dev;
444 int key;
445};
446
442static struct sonypi_device { 447static struct sonypi_device {
443 struct pci_dev *dev; 448 struct pci_dev *dev;
444 struct platform_device *pdev; 449 struct platform_device *pdev;
@@ -710,22 +715,61 @@ static void sonypi_setbluetoothpower(u8 state)
710 715
711static void input_keyrelease(void *data) 716static void input_keyrelease(void *data)
712{ 717{
713 struct input_dev *input_dev; 718 struct sonypi_keypress kp;
714 int key;
715
716 while (1) {
717 if (kfifo_get(sonypi_device.input_fifo,
718 (unsigned char *)&input_dev,
719 sizeof(input_dev)) != sizeof(input_dev))
720 return;
721 if (kfifo_get(sonypi_device.input_fifo,
722 (unsigned char *)&key,
723 sizeof(key)) != sizeof(key))
724 return;
725 719
720 while (kfifo_get(sonypi_device.input_fifo, (unsigned char *)&kp,
721 sizeof(kp)) == sizeof(kp)) {
726 msleep(10); 722 msleep(10);
727 input_report_key(input_dev, key, 0); 723 input_report_key(kp.dev, kp.key, 0);
728 input_sync(input_dev); 724 input_sync(kp.dev);
725 }
726}
727
728static void sonypi_report_input_event(u8 event)
729{
730 struct input_dev *jog_dev = &sonypi_device.input_jog_dev;
731 struct input_dev *key_dev = &sonypi_device.input_key_dev;
732 struct sonypi_keypress kp = { NULL };
733 int i;
734
735 switch (event) {
736 case SONYPI_EVENT_JOGDIAL_UP:
737 case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
738 input_report_rel(jog_dev, REL_WHEEL, 1);
739 input_sync(jog_dev);
740 break;
741
742 case SONYPI_EVENT_JOGDIAL_DOWN:
743 case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
744 input_report_rel(jog_dev, REL_WHEEL, -1);
745 input_sync(jog_dev);
746 break;
747
748 case SONYPI_EVENT_JOGDIAL_PRESSED:
749 kp.key = BTN_MIDDLE;
750 kp.dev = jog_dev;
751 break;
752
753 case SONYPI_EVENT_FNKEY_RELEASED:
754 /* Nothing, not all VAIOs generate this event */
755 break;
756
757 default:
758 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
759 if (event == sonypi_inputkeys[i].sonypiev) {
760 kp.dev = key_dev;
761 kp.key = sonypi_inputkeys[i].inputev;
762 break;
763 }
764 break;
765 }
766
767 if (kp.dev) {
768 input_report_key(kp.dev, kp.key, 1);
769 input_sync(kp.dev);
770 kfifo_put(sonypi_device.input_fifo,
771 (unsigned char *)&kp, sizeof(kp));
772 schedule_work(&sonypi_device.input_work);
729 } 773 }
730} 774}
731 775
@@ -768,51 +812,8 @@ found:
768 printk(KERN_INFO 812 printk(KERN_INFO
769 "sonypi: event port1=0x%02x,port2=0x%02x\n", v1, v2); 813 "sonypi: event port1=0x%02x,port2=0x%02x\n", v1, v2);
770 814
771 if (useinput) { 815 if (useinput)
772 struct input_dev *input_jog_dev = &sonypi_device.input_jog_dev; 816 sonypi_report_input_event(event);
773 struct input_dev *input_key_dev = &sonypi_device.input_key_dev;
774 switch (event) {
775 case SONYPI_EVENT_JOGDIAL_UP:
776 case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
777 input_report_rel(input_jog_dev, REL_WHEEL, 1);
778 break;
779 case SONYPI_EVENT_JOGDIAL_DOWN:
780 case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
781 input_report_rel(input_jog_dev, REL_WHEEL, -1);
782 break;
783 case SONYPI_EVENT_JOGDIAL_PRESSED: {
784 int key = BTN_MIDDLE;
785 input_report_key(input_jog_dev, key, 1);
786 kfifo_put(sonypi_device.input_fifo,
787 (unsigned char *)&input_jog_dev,
788 sizeof(input_jog_dev));
789 kfifo_put(sonypi_device.input_fifo,
790 (unsigned char *)&key, sizeof(key));
791 break;
792 }
793 case SONYPI_EVENT_FNKEY_RELEASED:
794 /* Nothing, not all VAIOs generate this event */
795 break;
796 }
797 input_sync(input_jog_dev);
798
799 for (i = 0; sonypi_inputkeys[i].sonypiev; i++) {
800 int key;
801
802 if (event != sonypi_inputkeys[i].sonypiev)
803 continue;
804
805 key = sonypi_inputkeys[i].inputev;
806 input_report_key(input_key_dev, key, 1);
807 kfifo_put(sonypi_device.input_fifo,
808 (unsigned char *)&input_key_dev,
809 sizeof(input_key_dev));
810 kfifo_put(sonypi_device.input_fifo,
811 (unsigned char *)&key, sizeof(key));
812 }
813 input_sync(input_key_dev);
814 schedule_work(&sonypi_device.input_work);
815 }
816 817
817 kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event)); 818 kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
818 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); 819 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
@@ -1227,14 +1228,7 @@ static int __devinit sonypi_probe(void)
1227 sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] = 1228 sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
1228 BIT(BTN_MIDDLE); 1229 BIT(BTN_MIDDLE);
1229 sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL); 1230 sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
1230 sonypi_device.input_jog_dev.name = 1231 sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;
1231 kmalloc(sizeof(SONYPI_JOG_INPUTNAME), GFP_KERNEL);
1232 if (!sonypi_device.input_jog_dev.name) {
1233 printk(KERN_ERR "sonypi: kmalloc failed\n");
1234 ret = -ENOMEM;
1235 goto out_inkmallocinput1;
1236 }
1237 sprintf(sonypi_device.input_jog_dev.name, SONYPI_JOG_INPUTNAME);
1238 sonypi_device.input_jog_dev.id.bustype = BUS_ISA; 1232 sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
1239 sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY; 1233 sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
1240 1234
@@ -1248,14 +1242,7 @@ static int __devinit sonypi_probe(void)
1248 if (sonypi_inputkeys[i].inputev) 1242 if (sonypi_inputkeys[i].inputev)
1249 set_bit(sonypi_inputkeys[i].inputev, 1243 set_bit(sonypi_inputkeys[i].inputev,
1250 sonypi_device.input_key_dev.keybit); 1244 sonypi_device.input_key_dev.keybit);
1251 sonypi_device.input_key_dev.name = 1245 sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;
1252 kmalloc(sizeof(SONYPI_KEY_INPUTNAME), GFP_KERNEL);
1253 if (!sonypi_device.input_key_dev.name) {
1254 printk(KERN_ERR "sonypi: kmalloc failed\n");
1255 ret = -ENOMEM;
1256 goto out_inkmallocinput2;
1257 }
1258 sprintf(sonypi_device.input_key_dev.name, SONYPI_KEY_INPUTNAME);
1259 sonypi_device.input_key_dev.id.bustype = BUS_ISA; 1246 sonypi_device.input_key_dev.id.bustype = BUS_ISA;
1260 sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY; 1247 sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;
1261 1248
@@ -1313,11 +1300,7 @@ out_platformdev:
1313 kfifo_free(sonypi_device.input_fifo); 1300 kfifo_free(sonypi_device.input_fifo);
1314out_infifo: 1301out_infifo:
1315 input_unregister_device(&sonypi_device.input_key_dev); 1302 input_unregister_device(&sonypi_device.input_key_dev);
1316 kfree(sonypi_device.input_key_dev.name);
1317out_inkmallocinput2:
1318 input_unregister_device(&sonypi_device.input_jog_dev); 1303 input_unregister_device(&sonypi_device.input_jog_dev);
1319 kfree(sonypi_device.input_jog_dev.name);
1320out_inkmallocinput1:
1321 free_irq(sonypi_device.irq, sonypi_irq); 1304 free_irq(sonypi_device.irq, sonypi_irq);
1322out_reqirq: 1305out_reqirq:
1323 release_region(sonypi_device.ioport1, sonypi_device.region_size); 1306 release_region(sonypi_device.ioport1, sonypi_device.region_size);
@@ -1337,13 +1320,14 @@ static void __devexit sonypi_remove(void)
1337{ 1320{
1338 sonypi_disable(); 1321 sonypi_disable();
1339 1322
1323 synchronize_sched(); /* Allow sonypi interrupt to complete. */
1324 flush_scheduled_work();
1325
1340 platform_device_unregister(sonypi_device.pdev); 1326 platform_device_unregister(sonypi_device.pdev);
1341 1327
1342 if (useinput) { 1328 if (useinput) {
1343 input_unregister_device(&sonypi_device.input_key_dev); 1329 input_unregister_device(&sonypi_device.input_key_dev);
1344 kfree(sonypi_device.input_key_dev.name);
1345 input_unregister_device(&sonypi_device.input_jog_dev); 1330 input_unregister_device(&sonypi_device.input_jog_dev);
1346 kfree(sonypi_device.input_jog_dev.name);
1347 kfifo_free(sonypi_device.input_fifo); 1331 kfifo_free(sonypi_device.input_fifo);
1348 } 1332 }
1349 1333
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 374f404e81da..20e3a165989f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -320,6 +320,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
320 if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL; 320 if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;
321 if (get_user(v, ip + 1)) return -EFAULT; 321 if (get_user(v, ip + 1)) return -EFAULT;
322 if (v < 0 || v > KEY_MAX) return -EINVAL; 322 if (v < 0 || v > KEY_MAX) return -EINVAL;
323 if (v >> (dev->keycodesize * 8)) return -EINVAL;
323 u = SET_INPUT_KEYCODE(dev, t, v); 324 u = SET_INPUT_KEYCODE(dev, t, v);
324 clear_bit(u, dev->keybit); 325 clear_bit(u, dev->keybit);
325 set_bit(v, dev->keybit); 326 set_bit(v, dev->keybit);
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7c4b4d37b3e6..a275211c8e1e 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -48,12 +48,6 @@ static LIST_HEAD(input_handler_list);
48 48
49static struct input_handler *input_table[8]; 49static struct input_handler *input_table[8];
50 50
51#ifdef CONFIG_PROC_FS
52static struct proc_dir_entry *proc_bus_input_dir;
53static DECLARE_WAIT_QUEUE_HEAD(input_devices_poll_wait);
54static int input_devices_state;
55#endif
56
57void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 51void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
58{ 52{
59 struct input_handle *handle; 53 struct input_handle *handle;
@@ -312,6 +306,7 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st
312 return NULL; 306 return NULL;
313} 307}
314 308
309
315/* 310/*
316 * Input hotplugging interface - loading event handlers based on 311 * Input hotplugging interface - loading event handlers based on
317 * device bitfields. 312 * device bitfields.
@@ -428,6 +423,177 @@ static void input_call_hotplug(char *verb, struct input_dev *dev)
428 423
429#endif 424#endif
430 425
426#ifdef CONFIG_PROC_FS
427
428static struct proc_dir_entry *proc_bus_input_dir;
429static DECLARE_WAIT_QUEUE_HEAD(input_devices_poll_wait);
430static int input_devices_state;
431
432static inline void input_wakeup_procfs_readers(void)
433{
434 input_devices_state++;
435 wake_up(&input_devices_poll_wait);
436}
437
438static unsigned int input_devices_poll(struct file *file, poll_table *wait)
439{
440 int state = input_devices_state;
441 poll_wait(file, &input_devices_poll_wait, wait);
442 if (state != input_devices_state)
443 return POLLIN | POLLRDNORM;
444 return 0;
445}
446
447#define SPRINTF_BIT_B(bit, name, max) \
448 do { \
449 len += sprintf(buf + len, "B: %s", name); \
450 for (i = NBITS(max) - 1; i >= 0; i--) \
451 if (dev->bit[i]) break; \
452 for (; i >= 0; i--) \
453 len += sprintf(buf + len, "%lx ", dev->bit[i]); \
454 len += sprintf(buf + len, "\n"); \
455 } while (0)
456
457#define SPRINTF_BIT_B2(bit, name, max, ev) \
458 do { \
459 if (test_bit(ev, dev->evbit)) \
460 SPRINTF_BIT_B(bit, name, max); \
461 } while (0)
462
463static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data)
464{
465 struct input_dev *dev;
466 struct input_handle *handle;
467
468 off_t at = 0;
469 int i, len, cnt = 0;
470
471 list_for_each_entry(dev, &input_dev_list, node) {
472
473 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
474 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
475
476 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : "");
477 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : "");
478 len += sprintf(buf + len, "H: Handlers=");
479
480 list_for_each_entry(handle, &dev->h_list, d_node)
481 len += sprintf(buf + len, "%s ", handle->name);
482
483 len += sprintf(buf + len, "\n");
484
485 SPRINTF_BIT_B(evbit, "EV=", EV_MAX);
486 SPRINTF_BIT_B2(keybit, "KEY=", KEY_MAX, EV_KEY);
487 SPRINTF_BIT_B2(relbit, "REL=", REL_MAX, EV_REL);
488 SPRINTF_BIT_B2(absbit, "ABS=", ABS_MAX, EV_ABS);
489 SPRINTF_BIT_B2(mscbit, "MSC=", MSC_MAX, EV_MSC);
490 SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED);
491 SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND);
492 SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF);
493
494 len += sprintf(buf + len, "\n");
495
496 at += len;
497
498 if (at >= pos) {
499 if (!*start) {
500 *start = buf + (pos - (at - len));
501 cnt = at - pos;
502 } else cnt += len;
503 buf += len;
504 if (cnt >= count)
505 break;
506 }
507 }
508
509 if (&dev->node == &input_dev_list)
510 *eof = 1;
511
512 return (count > cnt) ? cnt : count;
513}
514
515static int input_handlers_read(char *buf, char **start, off_t pos, int count, int *eof, void *data)
516{
517 struct input_handler *handler;
518
519 off_t at = 0;
520 int len = 0, cnt = 0;
521 int i = 0;
522
523 list_for_each_entry(handler, &input_handler_list, node) {
524
525 if (handler->fops)
526 len = sprintf(buf, "N: Number=%d Name=%s Minor=%d\n",
527 i++, handler->name, handler->minor);
528 else
529 len = sprintf(buf, "N: Number=%d Name=%s\n",
530 i++, handler->name);
531
532 at += len;
533
534 if (at >= pos) {
535 if (!*start) {
536 *start = buf + (pos - (at - len));
537 cnt = at - pos;
538 } else cnt += len;
539 buf += len;
540 if (cnt >= count)
541 break;
542 }
543 }
544 if (&handler->node == &input_handler_list)
545 *eof = 1;
546
547 return (count > cnt) ? cnt : count;
548}
549
550static struct file_operations input_fileops;
551
552static int __init input_proc_init(void)
553{
554 struct proc_dir_entry *entry;
555
556 proc_bus_input_dir = proc_mkdir("input", proc_bus);
557 if (!proc_bus_input_dir)
558 return -ENOMEM;
559
560 proc_bus_input_dir->owner = THIS_MODULE;
561
562 entry = create_proc_read_entry("devices", 0, proc_bus_input_dir, input_devices_read, NULL);
563 if (!entry)
564 goto fail1;
565
566 entry->owner = THIS_MODULE;
567 input_fileops = *entry->proc_fops;
568 entry->proc_fops = &input_fileops;
569 entry->proc_fops->poll = input_devices_poll;
570
571 entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL);
572 if (!entry)
573 goto fail2;
574
575 entry->owner = THIS_MODULE;
576
577 return 0;
578
579 fail2: remove_proc_entry("devices", proc_bus_input_dir);
580 fail1: remove_proc_entry("input", proc_bus);
581 return -ENOMEM;
582}
583
584static void input_proc_exit(void)
585{
586 remove_proc_entry("devices", proc_bus_input_dir);
587 remove_proc_entry("handlers", proc_bus_input_dir);
588 remove_proc_entry("input", proc_bus);
589}
590
591#else /* !CONFIG_PROC_FS */
592static inline void input_wakeup_procfs_readers(void) { }
593static inline int input_proc_init(void) { return 0; }
594static inline void input_proc_exit(void) { }
595#endif
596
431void input_register_device(struct input_dev *dev) 597void input_register_device(struct input_dev *dev)
432{ 598{
433 struct input_handle *handle; 599 struct input_handle *handle;
@@ -464,10 +630,7 @@ void input_register_device(struct input_dev *dev)
464 input_call_hotplug("add", dev); 630 input_call_hotplug("add", dev);
465#endif 631#endif
466 632
467#ifdef CONFIG_PROC_FS 633 input_wakeup_procfs_readers();
468 input_devices_state++;
469 wake_up(&input_devices_poll_wait);
470#endif
471} 634}
472 635
473void input_unregister_device(struct input_dev *dev) 636void input_unregister_device(struct input_dev *dev)
@@ -491,10 +654,7 @@ void input_unregister_device(struct input_dev *dev)
491 654
492 list_del_init(&dev->node); 655 list_del_init(&dev->node);
493 656
494#ifdef CONFIG_PROC_FS 657 input_wakeup_procfs_readers();
495 input_devices_state++;
496 wake_up(&input_devices_poll_wait);
497#endif
498} 658}
499 659
500void input_register_handler(struct input_handler *handler) 660void input_register_handler(struct input_handler *handler)
@@ -518,10 +678,7 @@ void input_register_handler(struct input_handler *handler)
518 if ((handle = handler->connect(handler, dev, id))) 678 if ((handle = handler->connect(handler, dev, id)))
519 input_link_handle(handle); 679 input_link_handle(handle);
520 680
521#ifdef CONFIG_PROC_FS 681 input_wakeup_procfs_readers();
522 input_devices_state++;
523 wake_up(&input_devices_poll_wait);
524#endif
525} 682}
526 683
527void input_unregister_handler(struct input_handler *handler) 684void input_unregister_handler(struct input_handler *handler)
@@ -540,10 +697,7 @@ void input_unregister_handler(struct input_handler *handler)
540 if (handler->fops != NULL) 697 if (handler->fops != NULL)
541 input_table[handler->minor >> 5] = NULL; 698 input_table[handler->minor >> 5] = NULL;
542 699
543#ifdef CONFIG_PROC_FS 700 input_wakeup_procfs_readers();
544 input_devices_state++;
545 wake_up(&input_devices_poll_wait);
546#endif
547} 701}
548 702
549static int input_open_file(struct inode *inode, struct file *file) 703static int input_open_file(struct inode *inode, struct file *file)
@@ -582,190 +736,43 @@ static struct file_operations input_fops = {
582 .open = input_open_file, 736 .open = input_open_file,
583}; 737};
584 738
585#ifdef CONFIG_PROC_FS 739struct class *input_class;
586
587#define SPRINTF_BIT_B(bit, name, max) \
588 do { \
589 len += sprintf(buf + len, "B: %s", name); \
590 for (i = NBITS(max) - 1; i >= 0; i--) \
591 if (dev->bit[i]) break; \
592 for (; i >= 0; i--) \
593 len += sprintf(buf + len, "%lx ", dev->bit[i]); \
594 len += sprintf(buf + len, "\n"); \
595 } while (0)
596
597#define SPRINTF_BIT_B2(bit, name, max, ev) \
598 do { \
599 if (test_bit(ev, dev->evbit)) \
600 SPRINTF_BIT_B(bit, name, max); \
601 } while (0)
602
603
604static unsigned int input_devices_poll(struct file *file, poll_table *wait)
605{
606 int state = input_devices_state;
607 poll_wait(file, &input_devices_poll_wait, wait);
608 if (state != input_devices_state)
609 return POLLIN | POLLRDNORM;
610 return 0;
611}
612 740
613static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) 741static int __init input_init(void)
614{ 742{
615 struct input_dev *dev; 743 int err;
616 struct input_handle *handle;
617
618 off_t at = 0;
619 int i, len, cnt = 0;
620
621 list_for_each_entry(dev, &input_dev_list, node) {
622
623 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
624 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
625
626 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : "");
627 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : "");
628 len += sprintf(buf + len, "H: Handlers=");
629
630 list_for_each_entry(handle, &dev->h_list, d_node)
631 len += sprintf(buf + len, "%s ", handle->name);
632
633 len += sprintf(buf + len, "\n");
634
635 SPRINTF_BIT_B(evbit, "EV=", EV_MAX);
636 SPRINTF_BIT_B2(keybit, "KEY=", KEY_MAX, EV_KEY);
637 SPRINTF_BIT_B2(relbit, "REL=", REL_MAX, EV_REL);
638 SPRINTF_BIT_B2(absbit, "ABS=", ABS_MAX, EV_ABS);
639 SPRINTF_BIT_B2(mscbit, "MSC=", MSC_MAX, EV_MSC);
640 SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED);
641 SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND);
642 SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF);
643
644 len += sprintf(buf + len, "\n");
645
646 at += len;
647 744
648 if (at >= pos) { 745 input_class = class_create(THIS_MODULE, "input");
649 if (!*start) { 746 if (IS_ERR(input_class)) {
650 *start = buf + (pos - (at - len)); 747 printk(KERN_ERR "input: unable to register input class\n");
651 cnt = at - pos; 748 return PTR_ERR(input_class);
652 } else cnt += len;
653 buf += len;
654 if (cnt >= count)
655 break;
656 }
657 } 749 }
658 750
659 if (&dev->node == &input_dev_list) 751 err = input_proc_init();
660 *eof = 1; 752 if (err)
661 753 goto fail1;
662 return (count > cnt) ? cnt : count;
663}
664
665static int input_handlers_read(char *buf, char **start, off_t pos, int count, int *eof, void *data)
666{
667 struct input_handler *handler;
668
669 off_t at = 0;
670 int len = 0, cnt = 0;
671 int i = 0;
672
673 list_for_each_entry(handler, &input_handler_list, node) {
674
675 if (handler->fops)
676 len = sprintf(buf, "N: Number=%d Name=%s Minor=%d\n",
677 i++, handler->name, handler->minor);
678 else
679 len = sprintf(buf, "N: Number=%d Name=%s\n",
680 i++, handler->name);
681
682 at += len;
683 754
684 if (at >= pos) { 755 err = register_chrdev(INPUT_MAJOR, "input", &input_fops);
685 if (!*start) { 756 if (err) {
686 *start = buf + (pos - (at - len)); 757 printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR);
687 cnt = at - pos; 758 goto fail2;
688 } else cnt += len;
689 buf += len;
690 if (cnt >= count)
691 break;
692 }
693 } 759 }
694 if (&handler->node == &input_handler_list)
695 *eof = 1;
696
697 return (count > cnt) ? cnt : count;
698}
699
700static struct file_operations input_fileops;
701 760
702static int __init input_proc_init(void) 761 err = devfs_mk_dir("input");
703{ 762 if (err)
704 struct proc_dir_entry *entry; 763 goto fail3;
705 764
706 proc_bus_input_dir = proc_mkdir("input", proc_bus);
707 if (proc_bus_input_dir == NULL)
708 return -ENOMEM;
709 proc_bus_input_dir->owner = THIS_MODULE;
710 entry = create_proc_read_entry("devices", 0, proc_bus_input_dir, input_devices_read, NULL);
711 if (entry == NULL) {
712 remove_proc_entry("input", proc_bus);
713 return -ENOMEM;
714 }
715 entry->owner = THIS_MODULE;
716 input_fileops = *entry->proc_fops;
717 entry->proc_fops = &input_fileops;
718 entry->proc_fops->poll = input_devices_poll;
719 entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL);
720 if (entry == NULL) {
721 remove_proc_entry("devices", proc_bus_input_dir);
722 remove_proc_entry("input", proc_bus);
723 return -ENOMEM;
724 }
725 entry->owner = THIS_MODULE;
726 return 0; 765 return 0;
727}
728#else /* !CONFIG_PROC_FS */
729static inline int input_proc_init(void) { return 0; }
730#endif
731 766
732struct class *input_class; 767 fail3: unregister_chrdev(INPUT_MAJOR, "input");
733 768 fail2: input_proc_exit();
734static int __init input_init(void) 769 fail1: class_destroy(input_class);
735{ 770 return err;
736 int retval = -ENOMEM;
737
738 input_class = class_create(THIS_MODULE, "input");
739 if (IS_ERR(input_class))
740 return PTR_ERR(input_class);
741 input_proc_init();
742 retval = register_chrdev(INPUT_MAJOR, "input", &input_fops);
743 if (retval) {
744 printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR);
745 remove_proc_entry("devices", proc_bus_input_dir);
746 remove_proc_entry("handlers", proc_bus_input_dir);
747 remove_proc_entry("input", proc_bus);
748 class_destroy(input_class);
749 return retval;
750 }
751
752 retval = devfs_mk_dir("input");
753 if (retval) {
754 remove_proc_entry("devices", proc_bus_input_dir);
755 remove_proc_entry("handlers", proc_bus_input_dir);
756 remove_proc_entry("input", proc_bus);
757 unregister_chrdev(INPUT_MAJOR, "input");
758 class_destroy(input_class);
759 }
760 return retval;
761} 771}
762 772
763static void __exit input_exit(void) 773static void __exit input_exit(void)
764{ 774{
765 remove_proc_entry("devices", proc_bus_input_dir); 775 input_proc_exit();
766 remove_proc_entry("handlers", proc_bus_input_dir);
767 remove_proc_entry("input", proc_bus);
768
769 devfs_remove("input"); 776 devfs_remove("input");
770 unregister_chrdev(INPUT_MAJOR, "input"); 777 unregister_chrdev(INPUT_MAJOR, "input");
771 class_destroy(input_class); 778 class_destroy(input_class);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index ff8e1bbd0e13..e0938d1d3ad7 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -37,8 +37,6 @@ MODULE_LICENSE("GPL");
37#define JOYDEV_MINORS 16 37#define JOYDEV_MINORS 16
38#define JOYDEV_BUFFER_SIZE 64 38#define JOYDEV_BUFFER_SIZE 64
39 39
40#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
41
42struct joydev { 40struct joydev {
43 int exist; 41 int exist;
44 int open; 42 int open;
@@ -117,7 +115,7 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne
117 return; 115 return;
118 } 116 }
119 117
120 event.time = MSECS(jiffies); 118 event.time = jiffies_to_msecs(jiffies);
121 119
122 list_for_each_entry(list, &joydev->list, node) { 120 list_for_each_entry(list, &joydev->list, node) {
123 121
@@ -245,7 +243,7 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo
245 243
246 struct js_event event; 244 struct js_event event;
247 245
248 event.time = MSECS(jiffies); 246 event.time = jiffies_to_msecs(jiffies);
249 247
250 if (list->startup < joydev->nkey) { 248 if (list->startup < joydev->nkey) {
251 event.type = JS_EVENT_BUTTON | JS_EVENT_INIT; 249 event.type = JS_EVENT_BUTTON | JS_EVENT_INIT;
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 98710997aaaa..d5c5b32045af 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -36,16 +36,6 @@
36#include <linux/miscdevice.h> 36#include <linux/miscdevice.h>
37#include <linux/uinput.h> 37#include <linux/uinput.h>
38 38
39static int uinput_dev_open(struct input_dev *dev)
40{
41 return 0;
42}
43
44static void uinput_dev_close(struct input_dev *dev)
45{
46
47}
48
49static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 39static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
50{ 40{
51 struct uinput_device *udev; 41 struct uinput_device *udev;
@@ -63,22 +53,24 @@ static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned i
63 return 0; 53 return 0;
64} 54}
65 55
66static int uinput_request_alloc_id(struct input_dev *dev, struct uinput_request *request) 56static int uinput_request_alloc_id(struct uinput_device *udev, struct uinput_request *request)
67{ 57{
68 /* Atomically allocate an ID for the given request. Returns 0 on success. */ 58 /* Atomically allocate an ID for the given request. Returns 0 on success. */
69 struct uinput_device *udev = dev->private;
70 int id; 59 int id;
60 int err = -1;
61
62 spin_lock(&udev->requests_lock);
71 63
72 down(&udev->requests_sem); 64 for (id = 0; id < UINPUT_NUM_REQUESTS; id++)
73 for (id=0; id<UINPUT_NUM_REQUESTS; id++)
74 if (!udev->requests[id]) { 65 if (!udev->requests[id]) {
75 udev->requests[id] = request;
76 request->id = id; 66 request->id = id;
77 up(&udev->requests_sem); 67 udev->requests[id] = request;
78 return 0; 68 err = 0;
69 break;
79 } 70 }
80 up(&udev->requests_sem); 71
81 return -1; 72 spin_unlock(&udev->requests_lock);
73 return err;
82} 74}
83 75
84static struct uinput_request* uinput_request_find(struct uinput_device *udev, int id) 76static struct uinput_request* uinput_request_find(struct uinput_device *udev, int id)
@@ -86,70 +78,78 @@ static struct uinput_request* uinput_request_find(struct uinput_device *udev, in
86 /* Find an input request, by ID. Returns NULL if the ID isn't valid. */ 78 /* Find an input request, by ID. Returns NULL if the ID isn't valid. */
87 if (id >= UINPUT_NUM_REQUESTS || id < 0) 79 if (id >= UINPUT_NUM_REQUESTS || id < 0)
88 return NULL; 80 return NULL;
89 if (udev->requests[id]->completed)
90 return NULL;
91 return udev->requests[id]; 81 return udev->requests[id];
92} 82}
93 83
94static void uinput_request_init(struct input_dev *dev, struct uinput_request *request, int code) 84static inline int uinput_request_reserve_slot(struct uinput_device *udev, struct uinput_request *request)
95{ 85{
96 struct uinput_device *udev = dev->private; 86 /* Allocate slot. If none are available right away, wait. */
87 return wait_event_interruptible(udev->requests_waitq,
88 !uinput_request_alloc_id(udev, request));
89}
97 90
98 memset(request, 0, sizeof(struct uinput_request)); 91static void uinput_request_done(struct uinput_device *udev, struct uinput_request *request)
99 request->code = code; 92{
100 init_waitqueue_head(&request->waitq); 93 complete(&request->done);
101 94
102 /* Allocate an ID. If none are available right away, wait. */ 95 /* Mark slot as available */
103 request->retval = wait_event_interruptible(udev->requests_waitq, 96 udev->requests[request->id] = NULL;
104 !uinput_request_alloc_id(dev, request)); 97 wake_up_interruptible(&udev->requests_waitq);
105} 98}
106 99
107static void uinput_request_submit(struct input_dev *dev, struct uinput_request *request) 100static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request)
108{ 101{
109 struct uinput_device *udev = dev->private;
110 int retval; 102 int retval;
111 103
112 /* Tell our userspace app about this new request by queueing an input event */ 104 /* Tell our userspace app about this new request by queueing an input event */
113 uinput_dev_event(dev, EV_UINPUT, request->code, request->id); 105 uinput_dev_event(dev, EV_UINPUT, request->code, request->id);
114 106
115 /* Wait for the request to complete */ 107 /* Wait for the request to complete */
116 retval = wait_event_interruptible(request->waitq, request->completed); 108 retval = wait_for_completion_interruptible(&request->done);
117 if (retval) 109 if (!retval)
118 request->retval = retval; 110 retval = request->retval;
119 111
120 /* Release this request's ID, let others know it's available */ 112 return retval;
121 udev->requests[request->id] = NULL;
122 wake_up_interruptible(&udev->requests_waitq);
123} 113}
124 114
125static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect) 115static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect)
126{ 116{
127 struct uinput_request request; 117 struct uinput_request request;
118 int retval;
128 119
129 if (!test_bit(EV_FF, dev->evbit)) 120 if (!test_bit(EV_FF, dev->evbit))
130 return -ENOSYS; 121 return -ENOSYS;
131 122
132 uinput_request_init(dev, &request, UI_FF_UPLOAD); 123 request.id = -1;
133 if (request.retval) 124 init_completion(&request.done);
134 return request.retval; 125 request.code = UI_FF_UPLOAD;
135 request.u.effect = effect; 126 request.u.effect = effect;
136 uinput_request_submit(dev, &request); 127
137 return request.retval; 128 retval = uinput_request_reserve_slot(dev->private, &request);
129 if (!retval)
130 retval = uinput_request_submit(dev, &request);
131
132 return retval;
138} 133}
139 134
140static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id) 135static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)
141{ 136{
142 struct uinput_request request; 137 struct uinput_request request;
138 int retval;
143 139
144 if (!test_bit(EV_FF, dev->evbit)) 140 if (!test_bit(EV_FF, dev->evbit))
145 return -ENOSYS; 141 return -ENOSYS;
146 142
147 uinput_request_init(dev, &request, UI_FF_ERASE); 143 request.id = -1;
148 if (request.retval) 144 init_completion(&request.done);
149 return request.retval; 145 request.code = UI_FF_ERASE;
150 request.u.effect_id = effect_id; 146 request.u.effect_id = effect_id;
151 uinput_request_submit(dev, &request); 147
152 return request.retval; 148 retval = uinput_request_reserve_slot(dev->private, &request);
149 if (!retval)
150 retval = uinput_request_submit(dev, &request);
151
152 return retval;
153} 153}
154 154
155static int uinput_create_device(struct uinput_device *udev) 155static int uinput_create_device(struct uinput_device *udev)
@@ -159,32 +159,30 @@ static int uinput_create_device(struct uinput_device *udev)
159 return -EINVAL; 159 return -EINVAL;
160 } 160 }
161 161
162 udev->dev->open = uinput_dev_open;
163 udev->dev->close = uinput_dev_close;
164 udev->dev->event = uinput_dev_event; 162 udev->dev->event = uinput_dev_event;
165 udev->dev->upload_effect = uinput_dev_upload_effect; 163 udev->dev->upload_effect = uinput_dev_upload_effect;
166 udev->dev->erase_effect = uinput_dev_erase_effect; 164 udev->dev->erase_effect = uinput_dev_erase_effect;
167 udev->dev->private = udev; 165 udev->dev->private = udev;
168 166
169 init_waitqueue_head(&(udev->waitq)); 167 init_waitqueue_head(&udev->waitq);
170 168
171 input_register_device(udev->dev); 169 input_register_device(udev->dev);
172 170
173 set_bit(UIST_CREATED, &(udev->state)); 171 set_bit(UIST_CREATED, &udev->state);
174 172
175 return 0; 173 return 0;
176} 174}
177 175
178static int uinput_destroy_device(struct uinput_device *udev) 176static int uinput_destroy_device(struct uinput_device *udev)
179{ 177{
180 if (!test_bit(UIST_CREATED, &(udev->state))) { 178 if (!test_bit(UIST_CREATED, &udev->state)) {
181 printk(KERN_WARNING "%s: create the device first\n", UINPUT_NAME); 179 printk(KERN_WARNING "%s: create the device first\n", UINPUT_NAME);
182 return -EINVAL; 180 return -EINVAL;
183 } 181 }
184 182
185 input_unregister_device(udev->dev); 183 input_unregister_device(udev->dev);
186 184
187 clear_bit(UIST_CREATED, &(udev->state)); 185 clear_bit(UIST_CREATED, &udev->state);
188 186
189 return 0; 187 return 0;
190} 188}
@@ -198,7 +196,7 @@ static int uinput_open(struct inode *inode, struct file *file)
198 if (!newdev) 196 if (!newdev)
199 goto error; 197 goto error;
200 memset(newdev, 0, sizeof(struct uinput_device)); 198 memset(newdev, 0, sizeof(struct uinput_device));
201 init_MUTEX(&newdev->requests_sem); 199 spin_lock_init(&newdev->requests_lock);
202 init_waitqueue_head(&newdev->requests_waitq); 200 init_waitqueue_head(&newdev->requests_waitq);
203 201
204 newinput = kmalloc(sizeof(struct input_dev), GFP_KERNEL); 202 newinput = kmalloc(sizeof(struct input_dev), GFP_KERNEL);
@@ -253,15 +251,16 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
253 struct uinput_user_dev *user_dev; 251 struct uinput_user_dev *user_dev;
254 struct input_dev *dev; 252 struct input_dev *dev;
255 struct uinput_device *udev; 253 struct uinput_device *udev;
256 int size, 254 char *name;
257 retval; 255 int size;
256 int retval;
258 257
259 retval = count; 258 retval = count;
260 259
261 udev = file->private_data; 260 udev = file->private_data;
262 dev = udev->dev; 261 dev = udev->dev;
263 262
264 user_dev = kmalloc(sizeof(*user_dev), GFP_KERNEL); 263 user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL);
265 if (!user_dev) { 264 if (!user_dev) {
266 retval = -ENOMEM; 265 retval = -ENOMEM;
267 goto exit; 266 goto exit;
@@ -272,17 +271,17 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
272 goto exit; 271 goto exit;
273 } 272 }
274 273
275 if (NULL != dev->name) 274 if (dev->name)
276 kfree(dev->name); 275 kfree(dev->name);
277 276
278 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 277 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
279 dev->name = kmalloc(size, GFP_KERNEL); 278 dev->name = name = kmalloc(size, GFP_KERNEL);
280 if (!dev->name) { 279 if (!name) {
281 retval = -ENOMEM; 280 retval = -ENOMEM;
282 goto exit; 281 goto exit;
283 } 282 }
283 strlcpy(name, user_dev->name, size);
284 284
285 strlcpy(dev->name, user_dev->name, size);
286 dev->id.bustype = user_dev->id.bustype; 285 dev->id.bustype = user_dev->id.bustype;
287 dev->id.vendor = user_dev->id.vendor; 286 dev->id.vendor = user_dev->id.vendor;
288 dev->id.product = user_dev->id.product; 287 dev->id.product = user_dev->id.product;
@@ -314,14 +313,13 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t
314{ 313{
315 struct uinput_device *udev = file->private_data; 314 struct uinput_device *udev = file->private_data;
316 315
317 if (test_bit(UIST_CREATED, &(udev->state))) { 316 if (test_bit(UIST_CREATED, &udev->state)) {
318 struct input_event ev; 317 struct input_event ev;
319 318
320 if (copy_from_user(&ev, buffer, sizeof(struct input_event))) 319 if (copy_from_user(&ev, buffer, sizeof(struct input_event)))
321 return -EFAULT; 320 return -EFAULT;
322 input_event(udev->dev, ev.type, ev.code, ev.value); 321 input_event(udev->dev, ev.type, ev.code, ev.value);
323 } 322 } else
324 else
325 count = uinput_alloc_device(file, buffer, count); 323 count = uinput_alloc_device(file, buffer, count);
326 324
327 return count; 325 return count;
@@ -332,26 +330,24 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
332 struct uinput_device *udev = file->private_data; 330 struct uinput_device *udev = file->private_data;
333 int retval = 0; 331 int retval = 0;
334 332
335 if (!test_bit(UIST_CREATED, &(udev->state))) 333 if (!test_bit(UIST_CREATED, &udev->state))
336 return -ENODEV; 334 return -ENODEV;
337 335
338 if ((udev->head == udev->tail) && (file->f_flags & O_NONBLOCK)) 336 if (udev->head == udev->tail && (file->f_flags & O_NONBLOCK))
339 return -EAGAIN; 337 return -EAGAIN;
340 338
341 retval = wait_event_interruptible(udev->waitq, 339 retval = wait_event_interruptible(udev->waitq,
342 (udev->head != udev->tail) || 340 udev->head != udev->tail || !test_bit(UIST_CREATED, &udev->state));
343 !test_bit(UIST_CREATED, &(udev->state)));
344
345 if (retval) 341 if (retval)
346 return retval; 342 return retval;
347 343
348 if (!test_bit(UIST_CREATED, &(udev->state))) 344 if (!test_bit(UIST_CREATED, &udev->state))
349 return -ENODEV; 345 return -ENODEV;
350 346
351 while ((udev->head != udev->tail) && 347 while ((udev->head != udev->tail) &&
352 (retval + sizeof(struct input_event) <= count)) { 348 (retval + sizeof(struct input_event) <= count)) {
353 if (copy_to_user(buffer + retval, &(udev->buff[udev->tail]), 349 if (copy_to_user(buffer + retval, &udev->buff[udev->tail], sizeof(struct input_event)))
354 sizeof(struct input_event))) return -EFAULT; 350 return -EFAULT;
355 udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE; 351 udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE;
356 retval += sizeof(struct input_event); 352 retval += sizeof(struct input_event);
357 } 353 }
@@ -373,12 +369,12 @@ static unsigned int uinput_poll(struct file *file, poll_table *wait)
373 369
374static int uinput_burn_device(struct uinput_device *udev) 370static int uinput_burn_device(struct uinput_device *udev)
375{ 371{
376 if (test_bit(UIST_CREATED, &(udev->state))) 372 if (test_bit(UIST_CREATED, &udev->state))
377 uinput_destroy_device(udev); 373 uinput_destroy_device(udev);
378 374
379 if (NULL != udev->dev->name) 375 if (udev->dev->name)
380 kfree(udev->dev->name); 376 kfree(udev->dev->name);
381 if (NULL != udev->dev->phys) 377 if (udev->dev->phys)
382 kfree(udev->dev->phys); 378 kfree(udev->dev->phys);
383 379
384 kfree(udev->dev); 380 kfree(udev->dev);
@@ -389,7 +385,8 @@ static int uinput_burn_device(struct uinput_device *udev)
389 385
390static int uinput_close(struct inode *inode, struct file *file) 386static int uinput_close(struct inode *inode, struct file *file)
391{ 387{
392 return uinput_burn_device(file->private_data); 388 uinput_burn_device(file->private_data);
389 return 0;
393} 390}
394 391
395static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 392static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
@@ -401,6 +398,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
401 struct uinput_ff_erase ff_erase; 398 struct uinput_ff_erase ff_erase;
402 struct uinput_request *req; 399 struct uinput_request *req;
403 int length; 400 int length;
401 char *phys;
404 402
405 udev = file->private_data; 403 udev = file->private_data;
406 404
@@ -415,7 +413,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
415 case UI_SET_SNDBIT: 413 case UI_SET_SNDBIT:
416 case UI_SET_FFBIT: 414 case UI_SET_FFBIT:
417 case UI_SET_PHYS: 415 case UI_SET_PHYS:
418 if (test_bit(UIST_CREATED, &(udev->state))) 416 if (test_bit(UIST_CREATED, &udev->state))
419 return -EINVAL; 417 return -EINVAL;
420 } 418 }
421 419
@@ -498,20 +496,19 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
498 retval = -EFAULT; 496 retval = -EFAULT;
499 break; 497 break;
500 } 498 }
501 if (NULL != udev->dev->phys) 499 kfree(udev->dev->phys);
502 kfree(udev->dev->phys); 500 udev->dev->phys = phys = kmalloc(length, GFP_KERNEL);
503 udev->dev->phys = kmalloc(length, GFP_KERNEL); 501 if (!phys) {
504 if (!udev->dev->phys) {
505 retval = -ENOMEM; 502 retval = -ENOMEM;
506 break; 503 break;
507 } 504 }
508 if (copy_from_user(udev->dev->phys, p, length)) { 505 if (copy_from_user(phys, p, length)) {
509 retval = -EFAULT;
510 kfree(udev->dev->phys);
511 udev->dev->phys = NULL; 506 udev->dev->phys = NULL;
507 kfree(phys);
508 retval = -EFAULT;
512 break; 509 break;
513 } 510 }
514 udev->dev->phys[length-1] = '\0'; 511 phys[length - 1] = '\0';
515 break; 512 break;
516 513
517 case UI_BEGIN_FF_UPLOAD: 514 case UI_BEGIN_FF_UPLOAD:
@@ -520,7 +517,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
520 break; 517 break;
521 } 518 }
522 req = uinput_request_find(udev, ff_up.request_id); 519 req = uinput_request_find(udev, ff_up.request_id);
523 if (!(req && req->code==UI_FF_UPLOAD && req->u.effect)) { 520 if (!(req && req->code == UI_FF_UPLOAD && req->u.effect)) {
524 retval = -EINVAL; 521 retval = -EINVAL;
525 break; 522 break;
526 } 523 }
@@ -538,7 +535,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
538 break; 535 break;
539 } 536 }
540 req = uinput_request_find(udev, ff_erase.request_id); 537 req = uinput_request_find(udev, ff_erase.request_id);
541 if (!(req && req->code==UI_FF_ERASE)) { 538 if (!(req && req->code == UI_FF_ERASE)) {
542 retval = -EINVAL; 539 retval = -EINVAL;
543 break; 540 break;
544 } 541 }
@@ -556,14 +553,13 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
556 break; 553 break;
557 } 554 }
558 req = uinput_request_find(udev, ff_up.request_id); 555 req = uinput_request_find(udev, ff_up.request_id);
559 if (!(req && req->code==UI_FF_UPLOAD && req->u.effect)) { 556 if (!(req && req->code == UI_FF_UPLOAD && req->u.effect)) {
560 retval = -EINVAL; 557 retval = -EINVAL;
561 break; 558 break;
562 } 559 }
563 req->retval = ff_up.retval; 560 req->retval = ff_up.retval;
564 memcpy(req->u.effect, &ff_up.effect, sizeof(struct ff_effect)); 561 memcpy(req->u.effect, &ff_up.effect, sizeof(struct ff_effect));
565 req->completed = 1; 562 uinput_request_done(udev, req);
566 wake_up_interruptible(&req->waitq);
567 break; 563 break;
568 564
569 case UI_END_FF_ERASE: 565 case UI_END_FF_ERASE:
@@ -572,13 +568,12 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
572 break; 568 break;
573 } 569 }
574 req = uinput_request_find(udev, ff_erase.request_id); 570 req = uinput_request_find(udev, ff_erase.request_id);
575 if (!(req && req->code==UI_FF_ERASE)) { 571 if (!(req && req->code == UI_FF_ERASE)) {
576 retval = -EINVAL; 572 retval = -EINVAL;
577 break; 573 break;
578 } 574 }
579 req->retval = ff_erase.retval; 575 req->retval = ff_erase.retval;
580 req->completed = 1; 576 uinput_request_done(udev, req);
581 wake_up_interruptible(&req->waitq);
582 break; 577 break;
583 578
584 default: 579 default:
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index a12e98158a75..0d68e5e0182a 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -2,7 +2,7 @@
2 * ALPS touchpad PS/2 mouse driver 2 * ALPS touchpad PS/2 mouse driver
3 * 3 *
4 * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au> 4 * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au>
5 * Copyright (c) 2003 Peter Osterlund <petero2@telia.com> 5 * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
6 * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru> 6 * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru>
7 * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> 7 * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
8 * 8 *
@@ -350,7 +350,6 @@ static int alps_tap_mode(struct psmouse *psmouse, int enable)
350static int alps_reconnect(struct psmouse *psmouse) 350static int alps_reconnect(struct psmouse *psmouse)
351{ 351{
352 struct alps_data *priv = psmouse->private; 352 struct alps_data *priv = psmouse->private;
353 unsigned char param[4];
354 int version; 353 int version;
355 354
356 psmouse_reset(psmouse); 355 psmouse_reset(psmouse);
@@ -358,21 +357,20 @@ static int alps_reconnect(struct psmouse *psmouse)
358 if (!(priv->i = alps_get_model(psmouse, &version))) 357 if (!(priv->i = alps_get_model(psmouse, &version)))
359 return -1; 358 return -1;
360 359
361 if (priv->i->flags & ALPS_PASS && alps_passthrough_mode(psmouse, 1)) 360 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1))
362 return -1; 361 return -1;
363 362
364 if (alps_get_status(psmouse, param)) 363 if (alps_tap_mode(psmouse, 1)) {
364 printk(KERN_WARNING "alps.c: Failed to reenable hardware tapping\n");
365 return -1; 365 return -1;
366 366 }
367 if (!(param[0] & 0x04))
368 alps_tap_mode(psmouse, 1);
369 367
370 if (alps_absolute_mode(psmouse)) { 368 if (alps_absolute_mode(psmouse)) {
371 printk(KERN_ERR "alps.c: Failed to enable absolute mode\n"); 369 printk(KERN_ERR "alps.c: Failed to reenable absolute mode\n");
372 return -1; 370 return -1;
373 } 371 }
374 372
375 if (priv->i->flags == ALPS_PASS && alps_passthrough_mode(psmouse, 0)) 373 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
376 return -1; 374 return -1;
377 375
378 return 0; 376 return 0;
@@ -389,7 +387,6 @@ static void alps_disconnect(struct psmouse *psmouse)
389int alps_init(struct psmouse *psmouse) 387int alps_init(struct psmouse *psmouse)
390{ 388{
391 struct alps_data *priv; 389 struct alps_data *priv;
392 unsigned char param[4];
393 int version; 390 int version;
394 391
395 psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL); 392 psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL);
@@ -403,16 +400,8 @@ int alps_init(struct psmouse *psmouse)
403 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1)) 400 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1))
404 goto init_fail; 401 goto init_fail;
405 402
406 if (alps_get_status(psmouse, param)) { 403 if (alps_tap_mode(psmouse, 1))
407 printk(KERN_ERR "alps.c: touchpad status report request failed\n"); 404 printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
408 goto init_fail;
409 }
410
411 if (param[0] & 0x04) {
412 printk(KERN_INFO "alps.c: Enabling hardware tapping\n");
413 if (alps_tap_mode(psmouse, 1))
414 printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
415 }
416 405
417 if (alps_absolute_mode(psmouse)) { 406 if (alps_absolute_mode(psmouse)) {
418 printk(KERN_ERR "alps.c: Failed to enable absolute mode\n"); 407 printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 5ab1bd7d529d..48d2b20d2642 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -385,8 +385,6 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
385 385
386 if (buttons < 3) 386 if (buttons < 3)
387 clear_bit(BTN_MIDDLE, psmouse->dev.keybit); 387 clear_bit(BTN_MIDDLE, psmouse->dev.keybit);
388 if (buttons < 2)
389 clear_bit(BTN_RIGHT, psmouse->dev.keybit);
390 388
391 if (model_info) 389 if (model_info)
392 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); 390 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 19785a6c5abd..2bb2fe78bdca 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -344,6 +344,7 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
344 return -1; 344 return -1;
345 345
346 if (set_properties) { 346 if (set_properties) {
347 set_bit(BTN_MIDDLE, psmouse->dev.keybit);
347 set_bit(REL_WHEEL, psmouse->dev.relbit); 348 set_bit(REL_WHEEL, psmouse->dev.relbit);
348 349
349 if (!psmouse->vendor) psmouse->vendor = "Generic"; 350 if (!psmouse->vendor) psmouse->vendor = "Generic";
@@ -376,6 +377,7 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
376 return -1; 377 return -1;
377 378
378 if (set_properties) { 379 if (set_properties) {
380 set_bit(BTN_MIDDLE, psmouse->dev.keybit);
379 set_bit(REL_WHEEL, psmouse->dev.relbit); 381 set_bit(REL_WHEEL, psmouse->dev.relbit);
380 set_bit(BTN_SIDE, psmouse->dev.keybit); 382 set_bit(BTN_SIDE, psmouse->dev.keybit);
381 set_bit(BTN_EXTRA, psmouse->dev.keybit); 383 set_bit(BTN_EXTRA, psmouse->dev.keybit);
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 36c721227b68..029309422409 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -219,7 +219,7 @@ static void synaptics_pass_pt_packet(struct serio *ptport, unsigned char *packet
219 serio_interrupt(ptport, packet[1], 0, NULL); 219 serio_interrupt(ptport, packet[1], 0, NULL);
220 serio_interrupt(ptport, packet[4], 0, NULL); 220 serio_interrupt(ptport, packet[4], 0, NULL);
221 serio_interrupt(ptport, packet[5], 0, NULL); 221 serio_interrupt(ptport, packet[5], 0, NULL);
222 if (child->type >= PSMOUSE_GENPS) 222 if (child->pktsize == 4)
223 serio_interrupt(ptport, packet[2], 0, NULL); 223 serio_interrupt(ptport, packet[2], 0, NULL);
224 } else 224 } else
225 serio_interrupt(ptport, packet[1], 0, NULL); 225 serio_interrupt(ptport, packet[1], 0, NULL);
@@ -233,7 +233,7 @@ static void synaptics_pt_activate(struct psmouse *psmouse)
233 233
234 /* adjust the touchpad to child's choice of protocol */ 234 /* adjust the touchpad to child's choice of protocol */
235 if (child) { 235 if (child) {
236 if (child->type >= PSMOUSE_GENPS) 236 if (child->pktsize == 4)
237 priv->mode |= SYN_BIT_FOUR_BYTE_CLIENT; 237 priv->mode |= SYN_BIT_FOUR_BYTE_CLIENT;
238 else 238 else
239 priv->mode &= ~SYN_BIT_FOUR_BYTE_CLIENT; 239 priv->mode &= ~SYN_BIT_FOUR_BYTE_CLIENT;
@@ -608,6 +608,13 @@ static struct dmi_system_id toshiba_dmi_table[] = {
608 DMI_MATCH(DMI_PRODUCT_NAME , "Satellite"), 608 DMI_MATCH(DMI_PRODUCT_NAME , "Satellite"),
609 }, 609 },
610 }, 610 },
611 {
612 .ident = "Toshiba Dynabook",
613 .matches = {
614 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
615 DMI_MATCH(DMI_PRODUCT_NAME , "dynabook"),
616 },
617 },
611 { } 618 { }
612}; 619};
613#endif 620#endif
@@ -656,7 +663,8 @@ int synaptics_init(struct psmouse *psmouse)
656 * thye same as rate of standard PS/2 mouse. 663 * thye same as rate of standard PS/2 mouse.
657 */ 664 */
658 if (psmouse->rate >= 80 && dmi_check_system(toshiba_dmi_table)) { 665 if (psmouse->rate >= 80 && dmi_check_system(toshiba_dmi_table)) {
659 printk(KERN_INFO "synaptics: Toshiba Satellite detected, limiting rate to 40pps.\n"); 666 printk(KERN_INFO "synaptics: Toshiba %s detected, limiting rate to 40pps.\n",
667 dmi_get_system_info(DMI_PRODUCT_NAME));
660 psmouse->rate = 40; 668 psmouse->rate = 40;
661 } 669 }
662#endif 670#endif
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index b3710733b36b..98acf170252c 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -175,7 +175,7 @@ config SERIO_RAW
175 allocating minor 1 (that historically corresponds to /dev/psaux) 175 allocating minor 1 (that historically corresponds to /dev/psaux)
176 first. To bind this driver to a serio port use sysfs interface: 176 first. To bind this driver to a serio port use sysfs interface:
177 177
178 echo -n "serio_raw" > /sys/bus/serio/devices/serioX/driver 178 echo -n "serio_raw" > /sys/bus/serio/devices/serioX/drvctl
179 179
180 To compile this driver as a module, choose M here: the 180 To compile this driver as a module, choose M here: the
181 module will be called serio_raw. 181 module will be called serio_raw.
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 0487ecbb8a49..03877c84e6ff 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -131,12 +131,26 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
131 }, 131 },
132 }, 132 },
133 { 133 {
134 .ident = "Fujitsu-Siemens Lifebook T3010",
135 .matches = {
136 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
137 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
138 },
139 },
140 {
134 .ident = "Toshiba P10", 141 .ident = "Toshiba P10",
135 .matches = { 142 .matches = {
136 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 143 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
137 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"), 144 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
138 }, 145 },
139 }, 146 },
147 {
148 .ident = "Alienware Sentia",
149 .matches = {
150 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
151 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
152 },
153 },
140 { } 154 { }
141}; 155};
142 156
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index a9bf549c8dc5..708a1d3beab9 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -100,7 +100,7 @@ struct i8042_port {
100static struct i8042_port i8042_ports[I8042_NUM_PORTS] = { 100static struct i8042_port i8042_ports[I8042_NUM_PORTS] = {
101 { 101 {
102 .disable = I8042_CTR_KBDDIS, 102 .disable = I8042_CTR_KBDDIS,
103 .irqen = I8042_CTR_KBDINT, 103 .irqen = I8042_CTR_KBDINT,
104 .mux = -1, 104 .mux = -1,
105 .name = "KBD", 105 .name = "KBD",
106 }, 106 },
@@ -191,41 +191,45 @@ static int i8042_flush(void)
191static int i8042_command(unsigned char *param, int command) 191static int i8042_command(unsigned char *param, int command)
192{ 192{
193 unsigned long flags; 193 unsigned long flags;
194 int retval = 0, i = 0; 194 int i, retval, auxerr = 0;
195 195
196 if (i8042_noloop && command == I8042_CMD_AUX_LOOP) 196 if (i8042_noloop && command == I8042_CMD_AUX_LOOP)
197 return -1; 197 return -1;
198 198
199 spin_lock_irqsave(&i8042_lock, flags); 199 spin_lock_irqsave(&i8042_lock, flags);
200 200
201 retval = i8042_wait_write(); 201 if ((retval = i8042_wait_write()))
202 if (!retval) { 202 goto out;
203 dbg("%02x -> i8042 (command)", command & 0xff); 203
204 i8042_write_command(command & 0xff); 204 dbg("%02x -> i8042 (command)", command & 0xff);
205 i8042_write_command(command & 0xff);
206
207 for (i = 0; i < ((command >> 12) & 0xf); i++) {
208 if ((retval = i8042_wait_write()))
209 goto out;
210 dbg("%02x -> i8042 (parameter)", param[i]);
211 i8042_write_data(param[i]);
205 } 212 }
206 213
207 if (!retval) 214 for (i = 0; i < ((command >> 8) & 0xf); i++) {
208 for (i = 0; i < ((command >> 12) & 0xf); i++) { 215 if ((retval = i8042_wait_read()))
209 if ((retval = i8042_wait_write())) break; 216 goto out;
210 dbg("%02x -> i8042 (parameter)", param[i]);
211 i8042_write_data(param[i]);
212 }
213 217
214 if (!retval) 218 if (command == I8042_CMD_AUX_LOOP &&
215 for (i = 0; i < ((command >> 8) & 0xf); i++) { 219 !(i8042_read_status() & I8042_STR_AUXDATA)) {
216 if ((retval = i8042_wait_read())) break; 220 retval = auxerr = -1;
217 if (i8042_read_status() & I8042_STR_AUXDATA) 221 goto out;
218 param[i] = ~i8042_read_data();
219 else
220 param[i] = i8042_read_data();
221 dbg("%02x <- i8042 (return)", param[i]);
222 } 222 }
223 223
224 spin_unlock_irqrestore(&i8042_lock, flags); 224 param[i] = i8042_read_data();
225 dbg("%02x <- i8042 (return)", param[i]);
226 }
225 227
226 if (retval) 228 if (retval)
227 dbg(" -- i8042 (timeout)"); 229 dbg(" -- i8042 (%s)", auxerr ? "auxerr" : "timeout");
228 230
231 out:
232 spin_unlock_irqrestore(&i8042_lock, flags);
229 return retval; 233 return retval;
230} 234}
231 235
@@ -507,17 +511,17 @@ static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version)
507 */ 511 */
508 512
509 param = 0xf0; 513 param = 0xf0;
510 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0x0f) 514 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xf0)
511 return -1; 515 return -1;
512 param = mode ? 0x56 : 0xf6; 516 param = mode ? 0x56 : 0xf6;
513 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != (mode ? 0xa9 : 0x09)) 517 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != (mode ? 0x56 : 0xf6))
514 return -1; 518 return -1;
515 param = mode ? 0xa4 : 0xa5; 519 param = mode ? 0xa4 : 0xa5;
516 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param == (mode ? 0x5b : 0x5a)) 520 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param == (mode ? 0xa4 : 0xa5))
517 return -1; 521 return -1;
518 522
519 if (mux_version) 523 if (mux_version)
520 *mux_version = ~param; 524 *mux_version = param;
521 525
522 return 0; 526 return 0;
523} 527}
@@ -619,7 +623,7 @@ static int __init i8042_check_aux(void)
619 */ 623 */
620 624
621 param = 0x5a; 625 param = 0x5a;
622 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xa5) { 626 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0x5a) {
623 627
624/* 628/*
625 * External connection test - filters out AT-soldered PS/2 i8042's 629 * External connection test - filters out AT-soldered PS/2 i8042's
@@ -630,7 +634,7 @@ static int __init i8042_check_aux(void)
630 */ 634 */
631 635
632 if (i8042_command(&param, I8042_CMD_AUX_TEST) 636 if (i8042_command(&param, I8042_CMD_AUX_TEST)
633 || (param && param != 0xfa && param != 0xff)) 637 || (param && param != 0xfa && param != 0xff))
634 return -1; 638 return -1;
635 } 639 }
636 640
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index f367695e69b5..edd15db17715 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -389,6 +389,14 @@ static ssize_t serio_show_description(struct device *dev, struct device_attribut
389 return sprintf(buf, "%s\n", serio->name); 389 return sprintf(buf, "%s\n", serio->name);
390} 390}
391 391
392static ssize_t serio_show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
393{
394 struct serio *serio = to_serio_port(dev);
395
396 return sprintf(buf, "serio:ty%02Xpr%02Xid%02Xex%02X\n",
397 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
398}
399
392static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf) 400static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf)
393{ 401{
394 struct serio *serio = to_serio_port(dev); 402 struct serio *serio = to_serio_port(dev);
@@ -487,6 +495,7 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *
487 495
488static struct device_attribute serio_device_attrs[] = { 496static struct device_attribute serio_device_attrs[] = {
489 __ATTR(description, S_IRUGO, serio_show_description, NULL), 497 __ATTR(description, S_IRUGO, serio_show_description, NULL),
498 __ATTR(modalias, S_IRUGO, serio_show_modalias, NULL),
490 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver), 499 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver),
491 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode), 500 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
492 __ATTR_NULL 501 __ATTR_NULL
@@ -785,36 +794,37 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv)
785 794
786#ifdef CONFIG_HOTPLUG 795#ifdef CONFIG_HOTPLUG
787 796
788#define PUT_ENVP(fmt, val) \ 797#define SERIO_ADD_HOTPLUG_VAR(fmt, val...) \
789do { \ 798 do { \
790 envp[i++] = buffer; \ 799 int err = add_hotplug_env_var(envp, num_envp, &i, \
791 length += snprintf(buffer, buffer_size - length, fmt, val); \ 800 buffer, buffer_size, &len, \
792 if (buffer_size - length <= 0 || i >= num_envp) \ 801 fmt, val); \
793 return -ENOMEM; \ 802 if (err) \
794 length++; \ 803 return err; \
795 buffer += length; \ 804 } while (0)
796} while (0) 805
797static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 806static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
798{ 807{
799 struct serio *serio; 808 struct serio *serio;
800 int i = 0; 809 int i = 0;
801 int length = 0; 810 int len = 0;
802 811
803 if (!dev) 812 if (!dev)
804 return -ENODEV; 813 return -ENODEV;
805 814
806 serio = to_serio_port(dev); 815 serio = to_serio_port(dev);
807 816
808 PUT_ENVP("SERIO_TYPE=%02x", serio->id.type); 817 SERIO_ADD_HOTPLUG_VAR("SERIO_TYPE=%02x", serio->id.type);
809 PUT_ENVP("SERIO_PROTO=%02x", serio->id.proto); 818 SERIO_ADD_HOTPLUG_VAR("SERIO_PROTO=%02x", serio->id.proto);
810 PUT_ENVP("SERIO_ID=%02x", serio->id.id); 819 SERIO_ADD_HOTPLUG_VAR("SERIO_ID=%02x", serio->id.id);
811 PUT_ENVP("SERIO_EXTRA=%02x", serio->id.extra); 820 SERIO_ADD_HOTPLUG_VAR("SERIO_EXTRA=%02x", serio->id.extra);
812 821 SERIO_ADD_HOTPLUG_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X",
822 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
813 envp[i] = NULL; 823 envp[i] = NULL;
814 824
815 return 0; 825 return 0;
816} 826}
817#undef PUT_ENVP 827#undef SERIO_ADD_HOTPLUG_VAR
818 828
819#else 829#else
820 830
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index d914e7e93db4..47e08de18d07 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -299,6 +299,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
299 299
300 serio_raw->dev.minor = PSMOUSE_MINOR; 300 serio_raw->dev.minor = PSMOUSE_MINOR;
301 serio_raw->dev.name = serio_raw->name; 301 serio_raw->dev.name = serio_raw->name;
302 serio_raw->dev.dev = &serio->dev;
302 serio_raw->dev.fops = &serio_raw_fops; 303 serio_raw->dev.fops = &serio_raw_fops;
303 304
304 err = misc_register(&serio_raw->dev); 305 err = misc_register(&serio_raw->dev);
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 7e991274ea40..0489af5a80c9 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -58,7 +58,7 @@ config TOUCHSCREEN_ELO
58 If unsure, say N. 58 If unsure, say N.
59 59
60 To compile this driver as a module, choose M here: the 60 To compile this driver as a module, choose M here: the
61 module will be called gunze. 61 module will be called elo.
62 62
63config TOUCHSCREEN_MTOUCH 63config TOUCHSCREEN_MTOUCH
64 tristate "MicroTouch serial touchscreens" 64 tristate "MicroTouch serial touchscreens"
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index ebcf7c955800..13532f3e3efc 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include <linux/usb_input.h>
34 35
35/* 36/*
36 * Version Information 37 * Version Information
@@ -87,8 +88,8 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs)
87 if (prox) { 88 if (prox) {
88 int x = data[1] | (data[2] << 8); 89 int x = data[1] | (data[2] << 8);
89 int y = data[3] | (data[4] << 8); 90 int y = data[3] | (data[4] << 8);
90 /*Pressure should compute the same way for flair and 302*/ 91 /* Pressure should compute the same way for flair and 302 */
91 int pressure = data[5] | ((int)data[6] << 8); 92 int pressure = data[5] | (data[6] << 8);
92 int touch = data[0] & 0x01; 93 int touch = data[0] & 0x01;
93 int stylus = (data[0] & 0x10) >> 4; 94 int stylus = (data[0] & 0x10) >> 4;
94 int stylus2 = (data[0] & 0x20) >> 5; 95 int stylus2 = (data[0] & 0x20) >> 5;
@@ -104,9 +105,9 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs)
104 input_sync(dev); 105 input_sync(dev);
105 106
106resubmit: 107resubmit:
107 status = usb_submit_urb (urb, GFP_ATOMIC); 108 status = usb_submit_urb(urb, GFP_ATOMIC);
108 if (status) 109 if (status)
109 err ("can't resubmit intr, %s-%s/input0, status %d", 110 err("can't resubmit intr, %s-%s/input0, status %d",
110 acecad->usbdev->bus->bus_name, acecad->usbdev->devpath, status); 111 acecad->usbdev->bus->bus_name, acecad->usbdev->devpath, status);
111} 112}
112 113
@@ -212,10 +213,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
212 213
213 acecad->dev.name = acecad->name; 214 acecad->dev.name = acecad->name;
214 acecad->dev.phys = acecad->phys; 215 acecad->dev.phys = acecad->phys;
215 acecad->dev.id.bustype = BUS_USB; 216 usb_to_input_id(dev, &acecad->dev.id);
216 acecad->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
217 acecad->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
218 acecad->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
219 acecad->dev.dev = &intf->dev; 217 acecad->dev.dev = &intf->dev;
220 218
221 usb_fill_int_urb(acecad->irq, dev, pipe, 219 usb_fill_int_urb(acecad->irq, dev, pipe,
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 6bb0f25e8e93..cd0cbfe20723 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -77,6 +77,7 @@
77#include <linux/module.h> 77#include <linux/module.h>
78#include <linux/init.h> 78#include <linux/init.h>
79#include <linux/usb.h> 79#include <linux/usb.h>
80#include <linux/usb_input.h>
80#include <linux/sched.h> 81#include <linux/sched.h>
81#include <asm/uaccess.h> 82#include <asm/uaccess.h>
82#include <asm/unaligned.h> 83#include <asm/unaligned.h>
@@ -2125,10 +2126,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2125 aiptek->inputdev.absflat[ABS_WHEEL] = 0; 2126 aiptek->inputdev.absflat[ABS_WHEEL] = 0;
2126 aiptek->inputdev.name = "Aiptek"; 2127 aiptek->inputdev.name = "Aiptek";
2127 aiptek->inputdev.phys = aiptek->features.usbPath; 2128 aiptek->inputdev.phys = aiptek->features.usbPath;
2128 aiptek->inputdev.id.bustype = BUS_USB; 2129 usb_to_input_id(usbdev, &aiptek->inputdev.id);
2129 aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor);
2130 aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct);
2131 aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice);
2132 aiptek->inputdev.dev = &intf->dev; 2130 aiptek->inputdev.dev = &intf->dev;
2133 2131
2134 aiptek->usbdev = usbdev; 2132 aiptek->usbdev = usbdev;
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 654ac454744d..fd99681ee483 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -94,6 +94,7 @@
94#include <linux/moduleparam.h> 94#include <linux/moduleparam.h>
95#include <linux/input.h> 95#include <linux/input.h>
96#include <linux/usb.h> 96#include <linux/usb.h>
97#include <linux/usb_input.h>
97#include <linux/wait.h> 98#include <linux/wait.h>
98 99
99/* 100/*
@@ -635,11 +636,8 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
635 idev->name = ati_remote->name; 636 idev->name = ati_remote->name;
636 idev->phys = ati_remote->phys; 637 idev->phys = ati_remote->phys;
637 638
638 idev->id.bustype = BUS_USB; 639 usb_to_input_id(ati_remote->udev, &idev->id);
639 idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor); 640 idev->dev = &ati_remote->udev->dev;
640 idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct);
641 idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice);
642 idev->dev = &(ati_remote->udev->dev);
643} 641}
644 642
645static int ati_remote_initialize(struct ati_remote *ati_remote) 643static int ati_remote_initialize(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 2350e7a5ad70..b2cb2b35892e 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -789,12 +789,12 @@ static __inline__ int search(__s32 *array, __s32 value, unsigned n)
789 return -1; 789 return -1;
790} 790}
791 791
792static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs) 792static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt, struct pt_regs *regs)
793{ 793{
794 hid_dump_input(usage, value); 794 hid_dump_input(usage, value);
795 if (hid->claimed & HID_CLAIMED_INPUT) 795 if (hid->claimed & HID_CLAIMED_INPUT)
796 hidinput_hid_event(hid, field, usage, value, regs); 796 hidinput_hid_event(hid, field, usage, value, regs);
797 if (hid->claimed & HID_CLAIMED_HIDDEV) 797 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt)
798 hiddev_hid_event(hid, field, usage, value, regs); 798 hiddev_hid_event(hid, field, usage, value, regs);
799} 799}
800 800
@@ -804,7 +804,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s
804 * reporting to the layer). 804 * reporting to the layer).
805 */ 805 */
806 806
807static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, struct pt_regs *regs) 807static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt, struct pt_regs *regs)
808{ 808{
809 unsigned n; 809 unsigned n;
810 unsigned count = field->report_count; 810 unsigned count = field->report_count;
@@ -831,19 +831,19 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u
831 for (n = 0; n < count; n++) { 831 for (n = 0; n < count; n++) {
832 832
833 if (HID_MAIN_ITEM_VARIABLE & field->flags) { 833 if (HID_MAIN_ITEM_VARIABLE & field->flags) {
834 hid_process_event(hid, field, &field->usage[n], value[n], regs); 834 hid_process_event(hid, field, &field->usage[n], value[n], interrupt, regs);
835 continue; 835 continue;
836 } 836 }
837 837
838 if (field->value[n] >= min && field->value[n] <= max 838 if (field->value[n] >= min && field->value[n] <= max
839 && field->usage[field->value[n] - min].hid 839 && field->usage[field->value[n] - min].hid
840 && search(value, field->value[n], count)) 840 && search(value, field->value[n], count))
841 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, regs); 841 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt, regs);
842 842
843 if (value[n] >= min && value[n] <= max 843 if (value[n] >= min && value[n] <= max
844 && field->usage[value[n] - min].hid 844 && field->usage[value[n] - min].hid
845 && search(field->value, value[n], count)) 845 && search(field->value, value[n], count))
846 hid_process_event(hid, field, &field->usage[value[n] - min], 1, regs); 846 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt, regs);
847 } 847 }
848 848
849 memcpy(field->value, value, count * sizeof(__s32)); 849 memcpy(field->value, value, count * sizeof(__s32));
@@ -851,7 +851,7 @@ exit:
851 kfree(value); 851 kfree(value);
852} 852}
853 853
854static int hid_input_report(int type, struct urb *urb, struct pt_regs *regs) 854static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_regs *regs)
855{ 855{
856 struct hid_device *hid = urb->context; 856 struct hid_device *hid = urb->context;
857 struct hid_report_enum *report_enum = hid->report_enum + type; 857 struct hid_report_enum *report_enum = hid->report_enum + type;
@@ -899,7 +899,7 @@ static int hid_input_report(int type, struct urb *urb, struct pt_regs *regs)
899 hiddev_report_event(hid, report); 899 hiddev_report_event(hid, report);
900 900
901 for (n = 0; n < report->maxfield; n++) 901 for (n = 0; n < report->maxfield; n++)
902 hid_input_field(hid, report->field[n], data, regs); 902 hid_input_field(hid, report->field[n], data, interrupt, regs);
903 903
904 if (hid->claimed & HID_CLAIMED_INPUT) 904 if (hid->claimed & HID_CLAIMED_INPUT)
905 hidinput_report_event(hid, report); 905 hidinput_report_event(hid, report);
@@ -918,7 +918,7 @@ static void hid_irq_in(struct urb *urb, struct pt_regs *regs)
918 918
919 switch (urb->status) { 919 switch (urb->status) {
920 case 0: /* success */ 920 case 0: /* success */
921 hid_input_report(HID_INPUT_REPORT, urb, regs); 921 hid_input_report(HID_INPUT_REPORT, urb, 1, regs);
922 break; 922 break;
923 case -ECONNRESET: /* unlink */ 923 case -ECONNRESET: /* unlink */
924 case -ENOENT: 924 case -ENOENT:
@@ -1142,7 +1142,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs)
1142 switch (urb->status) { 1142 switch (urb->status) {
1143 case 0: /* success */ 1143 case 0: /* success */
1144 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) 1144 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN)
1145 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, regs); 1145 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs);
1146 case -ESHUTDOWN: /* unplug */ 1146 case -ESHUTDOWN: /* unplug */
1147 case -EILSEQ: /* unplug timectrl on uhci */ 1147 case -EILSEQ: /* unplug timectrl on uhci */
1148 unplug = 1; 1148 unplug = 1;
@@ -1372,6 +1372,9 @@ void hid_init_reports(struct hid_device *hid)
1372#define USB_VENDOR_ID_A4TECH 0x09da 1372#define USB_VENDOR_ID_A4TECH 0x09da
1373#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 1373#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
1374 1374
1375#define USB_VENDOR_ID_AASHIMA 0x06D6
1376#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
1377
1375#define USB_VENDOR_ID_CYPRESS 0x04b4 1378#define USB_VENDOR_ID_CYPRESS 0x04b4
1376#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 1379#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
1377#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 1380#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
@@ -1548,6 +1551,7 @@ static struct hid_blacklist {
1548 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, 1551 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
1549 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, 1552 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 },
1550 1553
1554 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD },
1551 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 1555 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
1552 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 1556 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
1553 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 1557 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 9ac1e9095334..e071c8eeccee 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -31,6 +31,7 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include <linux/usb_input.h>
34 35
35#undef DEBUG 36#undef DEBUG
36 37
@@ -581,10 +582,7 @@ int hidinput_connect(struct hid_device *hid)
581 hidinput->input.name = hid->name; 582 hidinput->input.name = hid->name;
582 hidinput->input.phys = hid->phys; 583 hidinput->input.phys = hid->phys;
583 hidinput->input.uniq = hid->uniq; 584 hidinput->input.uniq = hid->uniq;
584 hidinput->input.id.bustype = BUS_USB; 585 usb_to_input_id(dev, &hidinput->input.id);
585 hidinput->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
586 hidinput->input.id.product = le16_to_cpu(dev->descriptor.idProduct);
587 hidinput->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
588 hidinput->input.dev = &hid->intf->dev; 586 hidinput->input.dev = &hid->intf->dev;
589 } 587 }
590 588
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
index 47dec6a1b344..0dc439f10823 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -53,6 +53,7 @@
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/usb_input.h>
56 57
57/* only an 8 byte buffer necessary for a single packet */ 58/* only an 8 byte buffer necessary for a single packet */
58#define ITM_BUFSIZE 8 59#define ITM_BUFSIZE 8
@@ -184,10 +185,7 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id
184 185
185 itmtouch->inputdev.name = itmtouch->name; 186 itmtouch->inputdev.name = itmtouch->name;
186 itmtouch->inputdev.phys = itmtouch->phys; 187 itmtouch->inputdev.phys = itmtouch->phys;
187 itmtouch->inputdev.id.bustype = BUS_USB; 188 usb_to_input_id(udev, &itmtouch->inputdev.id);
188 itmtouch->inputdev.id.vendor = udev->descriptor.idVendor;
189 itmtouch->inputdev.id.product = udev->descriptor.idProduct;
190 itmtouch->inputdev.id.version = udev->descriptor.bcdDevice;
191 itmtouch->inputdev.dev = &intf->dev; 189 itmtouch->inputdev.dev = &intf->dev;
192 190
193 if (!strlen(itmtouch->name)) 191 if (!strlen(itmtouch->name))
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index d2f0f90a9bcd..b6f6ac8d9c2f 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -4,6 +4,7 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/usb.h> 6#include <linux/usb.h>
7#include <linux/usb_input.h>
7#include <asm/unaligned.h> 8#include <asm/unaligned.h>
8#include <asm/byteorder.h> 9#include <asm/byteorder.h>
9 10
@@ -167,10 +168,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
167 168
168 kbtab->dev.name = "KB Gear Tablet"; 169 kbtab->dev.name = "KB Gear Tablet";
169 kbtab->dev.phys = kbtab->phys; 170 kbtab->dev.phys = kbtab->phys;
170 kbtab->dev.id.bustype = BUS_USB; 171 usb_to_input_id(dev, &kbtab->dev.id);
171 kbtab->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
172 kbtab->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
173 kbtab->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
174 kbtab->dev.dev = &intf->dev; 172 kbtab->dev.dev = &intf->dev;
175 kbtab->usbdev = dev; 173 kbtab->usbdev = dev;
176 174
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 09b5cc7c66de..ff9275057a18 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -53,6 +53,7 @@
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/usb_input.h>
56 57
57#define MTOUCHUSB_MIN_XC 0x0 58#define MTOUCHUSB_MIN_XC 0x0
58#define MTOUCHUSB_MAX_RAW_XC 0x4000 59#define MTOUCHUSB_MAX_RAW_XC 0x4000
@@ -232,10 +233,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i
232 233
233 mtouch->input.name = mtouch->name; 234 mtouch->input.name = mtouch->name;
234 mtouch->input.phys = mtouch->phys; 235 mtouch->input.phys = mtouch->phys;
235 mtouch->input.id.bustype = BUS_USB; 236 usb_to_input_id(udev, &mtouch->input.id);
236 mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
237 mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
238 mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
239 mtouch->input.dev = &intf->dev; 237 mtouch->input.dev = &intf->dev;
240 238
241 mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 239 mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index 3975b309d55f..ad4afe7e5897 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -35,6 +35,7 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/usb_input.h>
38 39
39#define POWERMATE_VENDOR 0x077d /* Griffin Technology, Inc. */ 40#define POWERMATE_VENDOR 0x077d /* Griffin Technology, Inc. */
40#define POWERMATE_PRODUCT_NEW 0x0410 /* Griffin PowerMate */ 41#define POWERMATE_PRODUCT_NEW 0x0410 /* Griffin PowerMate */
@@ -389,10 +390,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
389 pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0); 390 pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
390 pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); 391 pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL);
391 pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); 392 pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED);
392 pm->input.id.bustype = BUS_USB; 393 usb_to_input_id(udev, &pm->input.id);
393 pm->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
394 pm->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
395 pm->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
396 pm->input.event = powermate_input_event; 394 pm->input.event = powermate_input_event;
397 pm->input.dev = &intf->dev; 395 pm->input.dev = &intf->dev;
398 pm->input.phys = pm->phys; 396 pm->input.phys = pm->phys;
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 386595ee21c0..4276c24a5080 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -35,7 +35,7 @@
35#define DEBUG 35#define DEBUG
36#endif 36#endif
37#include <linux/usb.h> 37#include <linux/usb.h>
38 38#include <linux/usb_input.h>
39 39
40#define TOUCHKIT_MIN_XC 0x0 40#define TOUCHKIT_MIN_XC 0x0
41#define TOUCHKIT_MAX_XC 0x07ff 41#define TOUCHKIT_MAX_XC 0x07ff
@@ -202,10 +202,7 @@ static int touchkit_probe(struct usb_interface *intf,
202 202
203 touchkit->input.name = touchkit->name; 203 touchkit->input.name = touchkit->name;
204 touchkit->input.phys = touchkit->phys; 204 touchkit->input.phys = touchkit->phys;
205 touchkit->input.id.bustype = BUS_USB; 205 usb_to_input_id(udev, &touchkit->input.id);
206 touchkit->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
207 touchkit->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
208 touchkit->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
209 touchkit->input.dev = &intf->dev; 206 touchkit->input.dev = &intf->dev;
210 207
211 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 208 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index f35db1974c42..28987f15eeee 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -32,6 +32,7 @@
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/usb_input.h>
35 36
36/* 37/*
37 * Version Information 38 * Version Information
@@ -288,10 +289,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
288 289
289 kbd->dev.name = kbd->name; 290 kbd->dev.name = kbd->name;
290 kbd->dev.phys = kbd->phys; 291 kbd->dev.phys = kbd->phys;
291 kbd->dev.id.bustype = BUS_USB; 292 usb_to_input_id(dev, &kbd->dev.id);
292 kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
293 kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
294 kbd->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
295 kbd->dev.dev = &iface->dev; 293 kbd->dev.dev = &iface->dev;
296 294
297 if (dev->manufacturer) 295 if (dev->manufacturer)
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 1ec41b5effe6..4104dec847fb 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/usb_input.h>
35 36
36/* 37/*
37 * Version Information 38 * Version Information
@@ -171,10 +172,7 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
171 172
172 mouse->dev.name = mouse->name; 173 mouse->dev.name = mouse->name;
173 mouse->dev.phys = mouse->phys; 174 mouse->dev.phys = mouse->phys;
174 mouse->dev.id.bustype = BUS_USB; 175 usb_to_input_id(dev, &mouse->dev.id);
175 mouse->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
176 mouse->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
177 mouse->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
178 mouse->dev.dev = &intf->dev; 176 mouse->dev.dev = &intf->dev;
179 177
180 if (dev->manufacturer) 178 if (dev->manufacturer)
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
index f6b34af66b3d..02412e31a46b 100644
--- a/drivers/usb/input/wacom.c
+++ b/drivers/usb/input/wacom.c
@@ -69,6 +69,7 @@
69#include <linux/module.h> 69#include <linux/module.h>
70#include <linux/init.h> 70#include <linux/init.h>
71#include <linux/usb.h> 71#include <linux/usb.h>
72#include <linux/usb_input.h>
72#include <asm/unaligned.h> 73#include <asm/unaligned.h>
73#include <asm/byteorder.h> 74#include <asm/byteorder.h>
74 75
@@ -823,10 +824,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
823 824
824 wacom->dev.name = wacom->features->name; 825 wacom->dev.name = wacom->features->name;
825 wacom->dev.phys = wacom->phys; 826 wacom->dev.phys = wacom->phys;
826 wacom->dev.id.bustype = BUS_USB; 827 usb_to_input_id(dev, &wacom->dev.id);
827 wacom->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
828 wacom->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
829 wacom->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
830 wacom->dev.dev = &intf->dev; 828 wacom->dev.dev = &intf->dev;
831 wacom->usbdev = dev; 829 wacom->usbdev = dev;
832 830
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index a7fa1b17dcfe..18125e0bffa2 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -62,6 +62,7 @@
62#include <linux/module.h> 62#include <linux/module.h>
63#include <linux/smp_lock.h> 63#include <linux/smp_lock.h>
64#include <linux/usb.h> 64#include <linux/usb.h>
65#include <linux/usb_input.h>
65 66
66#define DRIVER_VERSION "v0.0.5" 67#define DRIVER_VERSION "v0.0.5"
67#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>" 68#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
@@ -256,10 +257,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
256 257
257 xpad->udev = udev; 258 xpad->udev = udev;
258 259
259 xpad->dev.id.bustype = BUS_USB; 260 usb_to_input_id(udev, &xpad->dev.id);
260 xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
261 xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct);
262 xpad->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
263 xpad->dev.dev = &intf->dev; 261 xpad->dev.dev = &intf->dev;
264 xpad->dev.private = xpad; 262 xpad->dev.private = xpad;
265 xpad->dev.name = xpad_device[i].name; 263 xpad->dev.name = xpad_device[i].name;
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c
index 08521a2b4f3d..20ac9e1069d4 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/usb/media/konicawc.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/usb_input.h>
19 20
20#include "usbvideo.h" 21#include "usbvideo.h"
21 22
@@ -845,10 +846,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
845 cam->input.private = cam; 846 cam->input.private = cam;
846 cam->input.evbit[0] = BIT(EV_KEY); 847 cam->input.evbit[0] = BIT(EV_KEY);
847 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0); 848 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
848 cam->input.id.bustype = BUS_USB; 849 usb_to_input_id(dev, &cam->input.id);
849 cam->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
850 cam->input.id.product = le16_to_cpu(dev->descriptor.idProduct);
851 cam->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
852 input_register_device(&cam->input); 850 input_register_device(&cam->input);
853 851
854 usb_make_path(dev, cam->input_physname, 56); 852 usb_make_path(dev, cam->input_physname, 56);
diff --git a/include/linux/input.h b/include/linux/input.h
index b9cc0ac71f44..bdc53c6cc962 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -811,9 +811,9 @@ struct input_dev {
811 811
812 void *private; 812 void *private;
813 813
814 char *name; 814 const char *name;
815 char *phys; 815 const char *phys;
816 char *uniq; 816 const char *uniq;
817 struct input_id id; 817 struct input_id id;
818 818
819 unsigned long evbit[NBITS(EV_MAX)]; 819 unsigned long evbit[NBITS(EV_MAX)];
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
index 4c2c82336d10..84876077027f 100644
--- a/include/linux/uinput.h
+++ b/include/linux/uinput.h
@@ -42,8 +42,7 @@ struct uinput_request {
42 int code; /* UI_FF_UPLOAD, UI_FF_ERASE */ 42 int code; /* UI_FF_UPLOAD, UI_FF_ERASE */
43 43
44 int retval; 44 int retval;
45 wait_queue_head_t waitq; 45 struct completion done;
46 int completed;
47 46
48 union { 47 union {
49 int effect_id; 48 int effect_id;
@@ -62,7 +61,7 @@ struct uinput_device {
62 61
63 struct uinput_request *requests[UINPUT_NUM_REQUESTS]; 62 struct uinput_request *requests[UINPUT_NUM_REQUESTS];
64 wait_queue_head_t requests_waitq; 63 wait_queue_head_t requests_waitq;
65 struct semaphore requests_sem; 64 spinlock_t requests_lock;
66}; 65};
67#endif /* __KERNEL__ */ 66#endif /* __KERNEL__ */
68 67
diff --git a/include/linux/usb_input.h b/include/linux/usb_input.h
new file mode 100644
index 000000000000..716e0cc16043
--- /dev/null
+++ b/include/linux/usb_input.h
@@ -0,0 +1,25 @@
1#ifndef __USB_INPUT_H
2#define __USB_INPUT_H
3
4/*
5 * Copyright (C) 2005 Dmitry Torokhov
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11
12#include <linux/usb.h>
13#include <linux/input.h>
14#include <asm/byteorder.h>
15
16static inline void
17usb_to_input_id(const struct usb_device *dev, struct input_id *id)
18{
19 id->bustype = BUS_USB;
20 id->vendor = le16_to_cpu(dev->descriptor.idVendor);
21 id->product = le16_to_cpu(dev->descriptor.idProduct);
22 id->version = le16_to_cpu(dev->descriptor.bcdDevice);
23}
24
25#endif