aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-29 12:48:34 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-29 12:48:34 -0400
commite0d7ff168a71299919f01500b3d507aae0c67513 (patch)
treede2a7807ec5642e7389191e66d8c5d6d1249096a /drivers/input
parentca49a601c2b4b74e5cf57fef62122204d1982372 (diff)
parent33fdfa97f2b3aab698ef849ec50dcc5102017f0a (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input
Diffstat (limited to 'drivers/input')
-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
14 files changed, 386 insertions, 359 deletions
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"