aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-12-22 12:57:02 -0500
committerJiri Kosina <jkosina@suse.cz>2010-12-22 12:57:02 -0500
commit4b7bd364700d9ac8372eff48832062b936d0793b (patch)
tree0dbf78c95456a0b02d07fcd473281f04a87e266d /drivers/input
parentc0d8768af260e2cbb4bf659ae6094a262c86b085 (diff)
parent90a8a73c06cc32b609a880d48449d7083327e11a (diff)
Merge branch 'master' into for-next
Conflicts: MAINTAINERS arch/arm/mach-omap2/pm24xx.c drivers/scsi/bfa/bfa_fcpim.c Needed to update to apply fixes for which the old branch was too outdated.
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/evdev.c113
-rw-r--r--drivers/input/input.c90
-rw-r--r--drivers/input/joystick/turbografx.c1
-rw-r--r--drivers/input/keyboard/Kconfig16
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/adp5588-keys.c74
-rw-r--r--drivers/input/keyboard/atkbd.c12
-rw-r--r--drivers/input/keyboard/gpio_keys_polled.c261
-rw-r--r--drivers/input/misc/pcf8574_keypad.c23
-rw-r--r--drivers/input/mouse/appletouch.c2
-rw-r--r--drivers/input/mouse/synaptics.h3
-rw-r--r--drivers/input/serio/gscps2.c2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h11
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/input/tablet/acecad.c3
-rw-r--r--drivers/input/tablet/aiptek.c28
-rw-r--r--drivers/input/tablet/wacom_wac.c12
-rw-r--r--drivers/input/touchscreen/ad7879.c32
-rw-r--r--drivers/input/touchscreen/bu21013_ts.c2
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c1
20 files changed, 517 insertions, 171 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e3f7fc6f9565..68f09a868434 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -534,76 +534,73 @@ static int handle_eviocgbit(struct input_dev *dev,
534} 534}
535#undef OLD_KEY_MAX 535#undef OLD_KEY_MAX
536 536
537static int evdev_handle_get_keycode(struct input_dev *dev, 537static int evdev_handle_get_keycode(struct input_dev *dev, void __user *p)
538 void __user *p, size_t size)
539{ 538{
540 struct input_keymap_entry ke; 539 struct input_keymap_entry ke = {
540 .len = sizeof(unsigned int),
541 .flags = 0,
542 };
543 int __user *ip = (int __user *)p;
541 int error; 544 int error;
542 545
543 memset(&ke, 0, sizeof(ke)); 546 /* legacy case */
544 547 if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
545 if (size == sizeof(unsigned int[2])) { 548 return -EFAULT;
546 /* legacy case */
547 int __user *ip = (int __user *)p;
548 549
549 if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) 550 error = input_get_keycode(dev, &ke);
550 return -EFAULT; 551 if (error)
552 return error;
551 553
552 ke.len = sizeof(unsigned int); 554 if (put_user(ke.keycode, ip + 1))
553 ke.flags = 0; 555 return -EFAULT;
554 556
555 error = input_get_keycode(dev, &ke); 557 return 0;
556 if (error) 558}
557 return error;
558 559
559 if (put_user(ke.keycode, ip + 1)) 560static int evdev_handle_get_keycode_v2(struct input_dev *dev, void __user *p)
560 return -EFAULT; 561{
562 struct input_keymap_entry ke;
563 int error;
561 564
562 } else { 565 if (copy_from_user(&ke, p, sizeof(ke)))
563 size = min(size, sizeof(ke)); 566 return -EFAULT;
564 567
565 if (copy_from_user(&ke, p, size)) 568 error = input_get_keycode(dev, &ke);
566 return -EFAULT; 569 if (error)
570 return error;
567 571
568 error = input_get_keycode(dev, &ke); 572 if (copy_to_user(p, &ke, sizeof(ke)))
569 if (error) 573 return -EFAULT;
570 return error;
571 574
572 if (copy_to_user(p, &ke, size))
573 return -EFAULT;
574 }
575 return 0; 575 return 0;
576} 576}
577 577
578static int evdev_handle_set_keycode(struct input_dev *dev, 578static int evdev_handle_set_keycode(struct input_dev *dev, void __user *p)
579 void __user *p, size_t size)
580{ 579{
581 struct input_keymap_entry ke; 580 struct input_keymap_entry ke = {
582 581 .len = sizeof(unsigned int),
583 memset(&ke, 0, sizeof(ke)); 582 .flags = 0,
583 };
584 int __user *ip = (int __user *)p;
584 585
585 if (size == sizeof(unsigned int[2])) { 586 if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
586 /* legacy case */ 587 return -EFAULT;
587 int __user *ip = (int __user *)p;
588 588
589 if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) 589 if (get_user(ke.keycode, ip + 1))
590 return -EFAULT; 590 return -EFAULT;
591 591
592 if (get_user(ke.keycode, ip + 1)) 592 return input_set_keycode(dev, &ke);
593 return -EFAULT; 593}
594 594
595 ke.len = sizeof(unsigned int); 595static int evdev_handle_set_keycode_v2(struct input_dev *dev, void __user *p)
596 ke.flags = 0; 596{
597 struct input_keymap_entry ke;
597 598
598 } else { 599 if (copy_from_user(&ke, p, sizeof(ke)))
599 size = min(size, sizeof(ke)); 600 return -EFAULT;
600 601
601 if (copy_from_user(&ke, p, size)) 602 if (ke.len > sizeof(ke.scancode))
602 return -EFAULT; 603 return -EINVAL;
603
604 if (ke.len > sizeof(ke.scancode))
605 return -EINVAL;
606 }
607 604
608 return input_set_keycode(dev, &ke); 605 return input_set_keycode(dev, &ke);
609} 606}
@@ -669,6 +666,18 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
669 return evdev_grab(evdev, client); 666 return evdev_grab(evdev, client);
670 else 667 else
671 return evdev_ungrab(evdev, client); 668 return evdev_ungrab(evdev, client);
669
670 case EVIOCGKEYCODE:
671 return evdev_handle_get_keycode(dev, p);
672
673 case EVIOCSKEYCODE:
674 return evdev_handle_set_keycode(dev, p);
675
676 case EVIOCGKEYCODE_V2:
677 return evdev_handle_get_keycode_v2(dev, p);
678
679 case EVIOCSKEYCODE_V2:
680 return evdev_handle_set_keycode_v2(dev, p);
672 } 681 }
673 682
674 size = _IOC_SIZE(cmd); 683 size = _IOC_SIZE(cmd);
@@ -708,12 +717,6 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
708 return -EFAULT; 717 return -EFAULT;
709 718
710 return error; 719 return error;
711
712 case EVIOC_MASK_SIZE(EVIOCGKEYCODE):
713 return evdev_handle_get_keycode(dev, p, size);
714
715 case EVIOC_MASK_SIZE(EVIOCSKEYCODE):
716 return evdev_handle_set_keycode(dev, p, size);
717 } 720 }
718 721
719 /* Multi-number variable-length handlers */ 722 /* Multi-number variable-length handlers */
diff --git a/drivers/input/input.c b/drivers/input/input.c
index d092ef9291da..db409d6bd5d2 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -24,7 +24,6 @@
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/rcupdate.h> 26#include <linux/rcupdate.h>
27#include <linux/smp_lock.h>
28#include "input-compat.h" 27#include "input-compat.h"
29 28
30MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 29MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@ -74,6 +73,7 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz)
74 * dev->event_lock held and interrupts disabled. 73 * dev->event_lock held and interrupts disabled.
75 */ 74 */
76static void input_pass_event(struct input_dev *dev, 75static void input_pass_event(struct input_dev *dev,
76 struct input_handler *src_handler,
77 unsigned int type, unsigned int code, int value) 77 unsigned int type, unsigned int code, int value)
78{ 78{
79 struct input_handler *handler; 79 struct input_handler *handler;
@@ -92,6 +92,15 @@ static void input_pass_event(struct input_dev *dev,
92 continue; 92 continue;
93 93
94 handler = handle->handler; 94 handler = handle->handler;
95
96 /*
97 * If this is the handler that injected this
98 * particular event we want to skip it to avoid
99 * filters firing again and again.
100 */
101 if (handler == src_handler)
102 continue;
103
95 if (!handler->filter) { 104 if (!handler->filter) {
96 if (filtered) 105 if (filtered)
97 break; 106 break;
@@ -121,7 +130,7 @@ static void input_repeat_key(unsigned long data)
121 if (test_bit(dev->repeat_key, dev->key) && 130 if (test_bit(dev->repeat_key, dev->key) &&
122 is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) { 131 is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) {
123 132
124 input_pass_event(dev, EV_KEY, dev->repeat_key, 2); 133 input_pass_event(dev, NULL, EV_KEY, dev->repeat_key, 2);
125 134
126 if (dev->sync) { 135 if (dev->sync) {
127 /* 136 /*
@@ -130,7 +139,7 @@ static void input_repeat_key(unsigned long data)
130 * Otherwise assume that the driver will send 139 * Otherwise assume that the driver will send
131 * SYN_REPORT once it's done. 140 * SYN_REPORT once it's done.
132 */ 141 */
133 input_pass_event(dev, EV_SYN, SYN_REPORT, 1); 142 input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
134 } 143 }
135 144
136 if (dev->rep[REP_PERIOD]) 145 if (dev->rep[REP_PERIOD])
@@ -163,6 +172,7 @@ static void input_stop_autorepeat(struct input_dev *dev)
163#define INPUT_PASS_TO_ALL (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE) 172#define INPUT_PASS_TO_ALL (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE)
164 173
165static int input_handle_abs_event(struct input_dev *dev, 174static int input_handle_abs_event(struct input_dev *dev,
175 struct input_handler *src_handler,
166 unsigned int code, int *pval) 176 unsigned int code, int *pval)
167{ 177{
168 bool is_mt_event; 178 bool is_mt_event;
@@ -206,13 +216,15 @@ static int input_handle_abs_event(struct input_dev *dev,
206 /* Flush pending "slot" event */ 216 /* Flush pending "slot" event */
207 if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) { 217 if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) {
208 input_abs_set_val(dev, ABS_MT_SLOT, dev->slot); 218 input_abs_set_val(dev, ABS_MT_SLOT, dev->slot);
209 input_pass_event(dev, EV_ABS, ABS_MT_SLOT, dev->slot); 219 input_pass_event(dev, src_handler,
220 EV_ABS, ABS_MT_SLOT, dev->slot);
210 } 221 }
211 222
212 return INPUT_PASS_TO_HANDLERS; 223 return INPUT_PASS_TO_HANDLERS;
213} 224}
214 225
215static void input_handle_event(struct input_dev *dev, 226static void input_handle_event(struct input_dev *dev,
227 struct input_handler *src_handler,
216 unsigned int type, unsigned int code, int value) 228 unsigned int type, unsigned int code, int value)
217{ 229{
218 int disposition = INPUT_IGNORE_EVENT; 230 int disposition = INPUT_IGNORE_EVENT;
@@ -265,7 +277,8 @@ static void input_handle_event(struct input_dev *dev,
265 277
266 case EV_ABS: 278 case EV_ABS:
267 if (is_event_supported(code, dev->absbit, ABS_MAX)) 279 if (is_event_supported(code, dev->absbit, ABS_MAX))
268 disposition = input_handle_abs_event(dev, code, &value); 280 disposition = input_handle_abs_event(dev, src_handler,
281 code, &value);
269 282
270 break; 283 break;
271 284
@@ -323,7 +336,7 @@ static void input_handle_event(struct input_dev *dev,
323 dev->event(dev, type, code, value); 336 dev->event(dev, type, code, value);
324 337
325 if (disposition & INPUT_PASS_TO_HANDLERS) 338 if (disposition & INPUT_PASS_TO_HANDLERS)
326 input_pass_event(dev, type, code, value); 339 input_pass_event(dev, src_handler, type, code, value);
327} 340}
328 341
329/** 342/**
@@ -352,7 +365,7 @@ void input_event(struct input_dev *dev,
352 365
353 spin_lock_irqsave(&dev->event_lock, flags); 366 spin_lock_irqsave(&dev->event_lock, flags);
354 add_input_randomness(type, code, value); 367 add_input_randomness(type, code, value);
355 input_handle_event(dev, type, code, value); 368 input_handle_event(dev, NULL, type, code, value);
356 spin_unlock_irqrestore(&dev->event_lock, flags); 369 spin_unlock_irqrestore(&dev->event_lock, flags);
357 } 370 }
358} 371}
@@ -382,7 +395,8 @@ void input_inject_event(struct input_handle *handle,
382 rcu_read_lock(); 395 rcu_read_lock();
383 grab = rcu_dereference(dev->grab); 396 grab = rcu_dereference(dev->grab);
384 if (!grab || grab == handle) 397 if (!grab || grab == handle)
385 input_handle_event(dev, type, code, value); 398 input_handle_event(dev, handle->handler,
399 type, code, value);
386 rcu_read_unlock(); 400 rcu_read_unlock();
387 401
388 spin_unlock_irqrestore(&dev->event_lock, flags); 402 spin_unlock_irqrestore(&dev->event_lock, flags);
@@ -595,10 +609,10 @@ static void input_dev_release_keys(struct input_dev *dev)
595 for (code = 0; code <= KEY_MAX; code++) { 609 for (code = 0; code <= KEY_MAX; code++) {
596 if (is_event_supported(code, dev->keybit, KEY_MAX) && 610 if (is_event_supported(code, dev->keybit, KEY_MAX) &&
597 __test_and_clear_bit(code, dev->key)) { 611 __test_and_clear_bit(code, dev->key)) {
598 input_pass_event(dev, EV_KEY, code, 0); 612 input_pass_event(dev, NULL, EV_KEY, code, 0);
599 } 613 }
600 } 614 }
601 input_pass_event(dev, EV_SYN, SYN_REPORT, 1); 615 input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
602 } 616 }
603} 617}
604 618
@@ -738,7 +752,7 @@ static int input_default_setkeycode(struct input_dev *dev,
738 if (index >= dev->keycodemax) 752 if (index >= dev->keycodemax)
739 return -EINVAL; 753 return -EINVAL;
740 754
741 if (dev->keycodesize < sizeof(dev->keycode) && 755 if (dev->keycodesize < sizeof(ke->keycode) &&
742 (ke->keycode >> (dev->keycodesize * 8))) 756 (ke->keycode >> (dev->keycodesize * 8)))
743 return -EINVAL; 757 return -EINVAL;
744 758
@@ -873,9 +887,9 @@ int input_set_keycode(struct input_dev *dev,
873 !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && 887 !is_event_supported(old_keycode, dev->keybit, KEY_MAX) &&
874 __test_and_clear_bit(old_keycode, dev->key)) { 888 __test_and_clear_bit(old_keycode, dev->key)) {
875 889
876 input_pass_event(dev, EV_KEY, old_keycode, 0); 890 input_pass_event(dev, NULL, EV_KEY, old_keycode, 0);
877 if (dev->sync) 891 if (dev->sync)
878 input_pass_event(dev, EV_SYN, SYN_REPORT, 1); 892 input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
879 } 893 }
880 894
881 out: 895 out:
@@ -1565,8 +1579,7 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1565 } \ 1579 } \
1566 } while (0) 1580 } while (0)
1567 1581
1568#ifdef CONFIG_PM 1582static void input_dev_toggle(struct input_dev *dev, bool activate)
1569static void input_dev_reset(struct input_dev *dev, bool activate)
1570{ 1583{
1571 if (!dev->event) 1584 if (!dev->event)
1572 return; 1585 return;
@@ -1580,12 +1593,44 @@ static void input_dev_reset(struct input_dev *dev, bool activate)
1580 } 1593 }
1581} 1594}
1582 1595
1596/**
1597 * input_reset_device() - reset/restore the state of input device
1598 * @dev: input device whose state needs to be reset
1599 *
1600 * This function tries to reset the state of an opened input device and
1601 * bring internal state and state if the hardware in sync with each other.
1602 * We mark all keys as released, restore LED state, repeat rate, etc.
1603 */
1604void input_reset_device(struct input_dev *dev)
1605{
1606 mutex_lock(&dev->mutex);
1607
1608 if (dev->users) {
1609 input_dev_toggle(dev, true);
1610
1611 /*
1612 * Keys that have been pressed at suspend time are unlikely
1613 * to be still pressed when we resume.
1614 */
1615 spin_lock_irq(&dev->event_lock);
1616 input_dev_release_keys(dev);
1617 spin_unlock_irq(&dev->event_lock);
1618 }
1619
1620 mutex_unlock(&dev->mutex);
1621}
1622EXPORT_SYMBOL(input_reset_device);
1623
1624#ifdef CONFIG_PM
1583static int input_dev_suspend(struct device *dev) 1625static int input_dev_suspend(struct device *dev)
1584{ 1626{
1585 struct input_dev *input_dev = to_input_dev(dev); 1627 struct input_dev *input_dev = to_input_dev(dev);
1586 1628
1587 mutex_lock(&input_dev->mutex); 1629 mutex_lock(&input_dev->mutex);
1588 input_dev_reset(input_dev, false); 1630
1631 if (input_dev->users)
1632 input_dev_toggle(input_dev, false);
1633
1589 mutex_unlock(&input_dev->mutex); 1634 mutex_unlock(&input_dev->mutex);
1590 1635
1591 return 0; 1636 return 0;
@@ -1595,18 +1640,7 @@ static int input_dev_resume(struct device *dev)
1595{ 1640{
1596 struct input_dev *input_dev = to_input_dev(dev); 1641 struct input_dev *input_dev = to_input_dev(dev);
1597 1642
1598 mutex_lock(&input_dev->mutex); 1643 input_reset_device(input_dev);
1599 input_dev_reset(input_dev, true);
1600
1601 /*
1602 * Keys that have been pressed at suspend time are unlikely
1603 * to be still pressed when we resume.
1604 */
1605 spin_lock_irq(&input_dev->event_lock);
1606 input_dev_release_keys(input_dev);
1607 spin_unlock_irq(&input_dev->event_lock);
1608
1609 mutex_unlock(&input_dev->mutex);
1610 1644
1611 return 0; 1645 return 0;
1612} 1646}
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index d53b9e900234..27b6a3ce18ca 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -245,6 +245,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
245 goto err_free_tgfx; 245 goto err_free_tgfx;
246 } 246 }
247 247
248 parport_put_port(pp);
248 return tgfx; 249 return tgfx;
249 250
250 err_free_dev: 251 err_free_dev:
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index b8c51b9781db..3a87f3ba5f75 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -179,6 +179,22 @@ config KEYBOARD_GPIO
179 To compile this driver as a module, choose M here: the 179 To compile this driver as a module, choose M here: the
180 module will be called gpio_keys. 180 module will be called gpio_keys.
181 181
182config KEYBOARD_GPIO_POLLED
183 tristate "Polled GPIO buttons"
184 depends on GENERIC_GPIO
185 select INPUT_POLLDEV
186 help
187 This driver implements support for buttons connected
188 to GPIO pins that are not capable of generating interrupts.
189
190 Say Y here if your device has buttons connected
191 directly to such GPIO pins. Your board-specific
192 setup logic must also provide a platform device,
193 with configuration data saying which GPIOs are used.
194
195 To compile this driver as a module, choose M here: the
196 module will be called gpio_keys_polled.
197
182config KEYBOARD_TCA6416 198config KEYBOARD_TCA6416
183 tristate "TCA6416 Keypad Support" 199 tristate "TCA6416 Keypad Support"
184 depends on I2C 200 depends on I2C
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index a34452e8ebe2..622de73a445d 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
14obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o 14obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o
15obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o 15obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
16obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 16obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
17obj-$(CONFIG_KEYBOARD_GPIO_POLLED) += gpio_keys_polled.o
17obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o 18obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o
18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 19obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 20obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index b92d1cd5cba1..af45d275f686 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -4,7 +4,7 @@
4 * I2C QWERTY Keypad and IO Expander 4 * I2C QWERTY Keypad and IO Expander
5 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/
6 * 6 *
7 * Copyright (C) 2008-2009 Analog Devices Inc. 7 * Copyright (C) 2008-2010 Analog Devices Inc.
8 * Licensed under the GPL-2 or later. 8 * Licensed under the GPL-2 or later.
9 */ 9 */
10 10
@@ -24,29 +24,6 @@
24 24
25#include <linux/i2c/adp5588.h> 25#include <linux/i2c/adp5588.h>
26 26
27 /* Configuration Register1 */
28#define AUTO_INC (1 << 7)
29#define GPIEM_CFG (1 << 6)
30#define OVR_FLOW_M (1 << 5)
31#define INT_CFG (1 << 4)
32#define OVR_FLOW_IEN (1 << 3)
33#define K_LCK_IM (1 << 2)
34#define GPI_IEN (1 << 1)
35#define KE_IEN (1 << 0)
36
37/* Interrupt Status Register */
38#define CMP2_INT (1 << 5)
39#define CMP1_INT (1 << 4)
40#define OVR_FLOW_INT (1 << 3)
41#define K_LCK_INT (1 << 2)
42#define GPI_INT (1 << 1)
43#define KE_INT (1 << 0)
44
45/* Key Lock and Event Counter Register */
46#define K_LCK_EN (1 << 6)
47#define LCK21 0x30
48#define KEC 0xF
49
50/* Key Event Register xy */ 27/* Key Event Register xy */
51#define KEY_EV_PRESSED (1 << 7) 28#define KEY_EV_PRESSED (1 << 7)
52#define KEY_EV_MASK (0x7F) 29#define KEY_EV_MASK (0x7F)
@@ -55,10 +32,6 @@
55 32
56#define KEYP_MAX_EVENT 10 33#define KEYP_MAX_EVENT 10
57 34
58#define MAXGPIO 18
59#define ADP_BANK(offs) ((offs) >> 3)
60#define ADP_BIT(offs) (1u << ((offs) & 0x7))
61
62/* 35/*
63 * Early pre 4.0 Silicon required to delay readout by at least 25ms, 36 * Early pre 4.0 Silicon required to delay readout by at least 25ms,
64 * since the Event Counter Register updated 25ms after the interrupt 37 * since the Event Counter Register updated 25ms after the interrupt
@@ -75,7 +48,7 @@ struct adp5588_kpad {
75 const struct adp5588_gpi_map *gpimap; 48 const struct adp5588_gpi_map *gpimap;
76 unsigned short gpimapsize; 49 unsigned short gpimapsize;
77#ifdef CONFIG_GPIOLIB 50#ifdef CONFIG_GPIOLIB
78 unsigned char gpiomap[MAXGPIO]; 51 unsigned char gpiomap[ADP5588_MAXGPIO];
79 bool export_gpio; 52 bool export_gpio;
80 struct gpio_chip gc; 53 struct gpio_chip gc;
81 struct mutex gpio_lock; /* Protect cached dir, dat_out */ 54 struct mutex gpio_lock; /* Protect cached dir, dat_out */
@@ -103,8 +76,8 @@ static int adp5588_write(struct i2c_client *client, u8 reg, u8 val)
103static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 76static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
104{ 77{
105 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 78 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
106 unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 79 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
107 unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 80 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
108 81
109 return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); 82 return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit);
110} 83}
@@ -113,8 +86,8 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
113 unsigned off, int val) 86 unsigned off, int val)
114{ 87{
115 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 88 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
116 unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 89 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
117 unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 90 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
118 91
119 mutex_lock(&kpad->gpio_lock); 92 mutex_lock(&kpad->gpio_lock);
120 93
@@ -132,8 +105,8 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
132static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 105static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off)
133{ 106{
134 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 107 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
135 unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 108 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
136 unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 109 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
137 int ret; 110 int ret;
138 111
139 mutex_lock(&kpad->gpio_lock); 112 mutex_lock(&kpad->gpio_lock);
@@ -150,8 +123,8 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
150 unsigned off, int val) 123 unsigned off, int val)
151{ 124{
152 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 125 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc);
153 unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 126 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
154 unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 127 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
155 int ret; 128 int ret;
156 129
157 mutex_lock(&kpad->gpio_lock); 130 mutex_lock(&kpad->gpio_lock);
@@ -176,7 +149,7 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
176static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, 149static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad,
177 const struct adp5588_kpad_platform_data *pdata) 150 const struct adp5588_kpad_platform_data *pdata)
178{ 151{
179 bool pin_used[MAXGPIO]; 152 bool pin_used[ADP5588_MAXGPIO];
180 int n_unused = 0; 153 int n_unused = 0;
181 int i; 154 int i;
182 155
@@ -191,7 +164,7 @@ static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad,
191 for (i = 0; i < kpad->gpimapsize; i++) 164 for (i = 0; i < kpad->gpimapsize; i++)
192 pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; 165 pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true;
193 166
194 for (i = 0; i < MAXGPIO; i++) 167 for (i = 0; i < ADP5588_MAXGPIO; i++)
195 if (!pin_used[i]) 168 if (!pin_used[i])
196 kpad->gpiomap[n_unused++] = i; 169 kpad->gpiomap[n_unused++] = i;
197 170
@@ -234,7 +207,7 @@ static int __devinit adp5588_gpio_add(struct adp5588_kpad *kpad)
234 return error; 207 return error;
235 } 208 }
236 209
237 for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 210 for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) {
238 kpad->dat_out[i] = adp5588_read(kpad->client, 211 kpad->dat_out[i] = adp5588_read(kpad->client,
239 GPIO_DAT_OUT1 + i); 212 GPIO_DAT_OUT1 + i);
240 kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); 213 kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i);
@@ -318,11 +291,11 @@ static void adp5588_work(struct work_struct *work)
318 291
319 status = adp5588_read(client, INT_STAT); 292 status = adp5588_read(client, INT_STAT);
320 293
321 if (status & OVR_FLOW_INT) /* Unlikely and should never happen */ 294 if (status & ADP5588_OVR_FLOW_INT) /* Unlikely and should never happen */
322 dev_err(&client->dev, "Event Overflow Error\n"); 295 dev_err(&client->dev, "Event Overflow Error\n");
323 296
324 if (status & KE_INT) { 297 if (status & ADP5588_KE_INT) {
325 ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & KEC; 298 ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & ADP5588_KEC;
326 if (ev_cnt) { 299 if (ev_cnt) {
327 adp5588_report_events(kpad, ev_cnt); 300 adp5588_report_events(kpad, ev_cnt);
328 input_sync(kpad->input); 301 input_sync(kpad->input);
@@ -360,7 +333,7 @@ static int __devinit adp5588_setup(struct i2c_client *client)
360 if (pdata->en_keylock) { 333 if (pdata->en_keylock) {
361 ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); 334 ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1);
362 ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); 335 ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2);
363 ret |= adp5588_write(client, KEY_LCK_EC_STAT, K_LCK_EN); 336 ret |= adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN);
364 } 337 }
365 338
366 for (i = 0; i < KEYP_MAX_EVENT; i++) 339 for (i = 0; i < KEYP_MAX_EVENT; i++)
@@ -384,7 +357,7 @@ static int __devinit adp5588_setup(struct i2c_client *client)
384 } 357 }
385 358
386 if (gpio_data) { 359 if (gpio_data) {
387 for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 360 for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) {
388 int pull_mask = gpio_data->pullup_dis_mask; 361 int pull_mask = gpio_data->pullup_dis_mask;
389 362
390 ret |= adp5588_write(client, GPIO_PULL1 + i, 363 ret |= adp5588_write(client, GPIO_PULL1 + i,
@@ -392,11 +365,14 @@ static int __devinit adp5588_setup(struct i2c_client *client)
392 } 365 }
393 } 366 }
394 367
395 ret |= adp5588_write(client, INT_STAT, CMP2_INT | CMP1_INT | 368 ret |= adp5588_write(client, INT_STAT,
396 OVR_FLOW_INT | K_LCK_INT | 369 ADP5588_CMP2_INT | ADP5588_CMP1_INT |
397 GPI_INT | KE_INT); /* Status is W1C */ 370 ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT |
371 ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */
398 372
399 ret |= adp5588_write(client, CFG, INT_CFG | OVR_FLOW_IEN | KE_IEN); 373 ret |= adp5588_write(client, CFG, ADP5588_INT_CFG |
374 ADP5588_OVR_FLOW_IEN |
375 ADP5588_KE_IEN);
400 376
401 if (ret < 0) { 377 if (ret < 0) {
402 dev_err(&client->dev, "Write Error\n"); 378 dev_err(&client->dev, "Write Error\n");
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index d358ef8623f4..11478eb2c27d 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -63,6 +63,10 @@ static bool atkbd_extra;
63module_param_named(extra, atkbd_extra, bool, 0); 63module_param_named(extra, atkbd_extra, bool, 0);
64MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); 64MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards");
65 65
66static bool atkbd_terminal;
67module_param_named(terminal, atkbd_terminal, bool, 0);
68MODULE_PARM_DESC(terminal, "Enable break codes on an IBM Terminal keyboard connected via AT/PS2");
69
66/* 70/*
67 * Scancode to keycode tables. These are just the default setting, and 71 * Scancode to keycode tables. These are just the default setting, and
68 * are loadable via a userland utility. 72 * are loadable via a userland utility.
@@ -136,7 +140,8 @@ static const unsigned short atkbd_unxlate_table[128] = {
136#define ATKBD_CMD_ENABLE 0x00f4 140#define ATKBD_CMD_ENABLE 0x00f4
137#define ATKBD_CMD_RESET_DIS 0x00f5 /* Reset to defaults and disable */ 141#define ATKBD_CMD_RESET_DIS 0x00f5 /* Reset to defaults and disable */
138#define ATKBD_CMD_RESET_DEF 0x00f6 /* Reset to defaults */ 142#define ATKBD_CMD_RESET_DEF 0x00f6 /* Reset to defaults */
139#define ATKBD_CMD_SETALL_MBR 0x00fa 143#define ATKBD_CMD_SETALL_MB 0x00f8 /* Set all keys to give break codes */
144#define ATKBD_CMD_SETALL_MBR 0x00fa /* ... and repeat */
140#define ATKBD_CMD_RESET_BAT 0x02ff 145#define ATKBD_CMD_RESET_BAT 0x02ff
141#define ATKBD_CMD_RESEND 0x00fe 146#define ATKBD_CMD_RESEND 0x00fe
142#define ATKBD_CMD_EX_ENABLE 0x10ea 147#define ATKBD_CMD_EX_ENABLE 0x10ea
@@ -764,6 +769,11 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
764 } 769 }
765 } 770 }
766 771
772 if (atkbd_terminal) {
773 ps2_command(ps2dev, param, ATKBD_CMD_SETALL_MB);
774 return 3;
775 }
776
767 if (target_set != 3) 777 if (target_set != 3)
768 return 2; 778 return 2;
769 779
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
new file mode 100644
index 000000000000..4c17aff20657
--- /dev/null
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -0,0 +1,261 @@
1/*
2 * Driver for buttons on GPIO lines not capable of generating interrupts
3 *
4 * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2010 Nuno Goncalves <nunojpg@gmail.com>
6 *
7 * This file was based on: /drivers/input/misc/cobalt_btns.c
8 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
9 *
10 * also was based on: /drivers/input/keyboard/gpio_keys.c
11 * Copyright 2005 Phil Blundell
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/slab.h>
22#include <linux/input.h>
23#include <linux/input-polldev.h>
24#include <linux/ioport.h>
25#include <linux/platform_device.h>
26#include <linux/gpio.h>
27#include <linux/gpio_keys.h>
28
29#define DRV_NAME "gpio-keys-polled"
30
31struct gpio_keys_button_data {
32 int last_state;
33 int count;
34 int threshold;
35 int can_sleep;
36};
37
38struct gpio_keys_polled_dev {
39 struct input_polled_dev *poll_dev;
40 struct device *dev;
41 struct gpio_keys_platform_data *pdata;
42 struct gpio_keys_button_data data[0];
43};
44
45static void gpio_keys_polled_check_state(struct input_dev *input,
46 struct gpio_keys_button *button,
47 struct gpio_keys_button_data *bdata)
48{
49 int state;
50
51 if (bdata->can_sleep)
52 state = !!gpio_get_value_cansleep(button->gpio);
53 else
54 state = !!gpio_get_value(button->gpio);
55
56 if (state != bdata->last_state) {
57 unsigned int type = button->type ?: EV_KEY;
58
59 input_event(input, type, button->code,
60 !!(state ^ button->active_low));
61 input_sync(input);
62 bdata->count = 0;
63 bdata->last_state = state;
64 }
65}
66
67static void gpio_keys_polled_poll(struct input_polled_dev *dev)
68{
69 struct gpio_keys_polled_dev *bdev = dev->private;
70 struct gpio_keys_platform_data *pdata = bdev->pdata;
71 struct input_dev *input = dev->input;
72 int i;
73
74 for (i = 0; i < bdev->pdata->nbuttons; i++) {
75 struct gpio_keys_button_data *bdata = &bdev->data[i];
76
77 if (bdata->count < bdata->threshold)
78 bdata->count++;
79 else
80 gpio_keys_polled_check_state(input, &pdata->buttons[i],
81 bdata);
82 }
83}
84
85static void gpio_keys_polled_open(struct input_polled_dev *dev)
86{
87 struct gpio_keys_polled_dev *bdev = dev->private;
88 struct gpio_keys_platform_data *pdata = bdev->pdata;
89
90 if (pdata->enable)
91 pdata->enable(bdev->dev);
92}
93
94static void gpio_keys_polled_close(struct input_polled_dev *dev)
95{
96 struct gpio_keys_polled_dev *bdev = dev->private;
97 struct gpio_keys_platform_data *pdata = bdev->pdata;
98
99 if (pdata->disable)
100 pdata->disable(bdev->dev);
101}
102
103static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
104{
105 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
106 struct device *dev = &pdev->dev;
107 struct gpio_keys_polled_dev *bdev;
108 struct input_polled_dev *poll_dev;
109 struct input_dev *input;
110 int error;
111 int i;
112
113 if (!pdata || !pdata->poll_interval)
114 return -EINVAL;
115
116 bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
117 pdata->nbuttons * sizeof(struct gpio_keys_button_data),
118 GFP_KERNEL);
119 if (!bdev) {
120 dev_err(dev, "no memory for private data\n");
121 return -ENOMEM;
122 }
123
124 poll_dev = input_allocate_polled_device();
125 if (!poll_dev) {
126 dev_err(dev, "no memory for polled device\n");
127 error = -ENOMEM;
128 goto err_free_bdev;
129 }
130
131 poll_dev->private = bdev;
132 poll_dev->poll = gpio_keys_polled_poll;
133 poll_dev->poll_interval = pdata->poll_interval;
134 poll_dev->open = gpio_keys_polled_open;
135 poll_dev->close = gpio_keys_polled_close;
136
137 input = poll_dev->input;
138
139 input->evbit[0] = BIT(EV_KEY);
140 input->name = pdev->name;
141 input->phys = DRV_NAME"/input0";
142 input->dev.parent = &pdev->dev;
143
144 input->id.bustype = BUS_HOST;
145 input->id.vendor = 0x0001;
146 input->id.product = 0x0001;
147 input->id.version = 0x0100;
148
149 for (i = 0; i < pdata->nbuttons; i++) {
150 struct gpio_keys_button *button = &pdata->buttons[i];
151 struct gpio_keys_button_data *bdata = &bdev->data[i];
152 unsigned int gpio = button->gpio;
153 unsigned int type = button->type ?: EV_KEY;
154
155 if (button->wakeup) {
156 dev_err(dev, DRV_NAME " does not support wakeup\n");
157 error = -EINVAL;
158 goto err_free_gpio;
159 }
160
161 error = gpio_request(gpio,
162 button->desc ? button->desc : DRV_NAME);
163 if (error) {
164 dev_err(dev, "unable to claim gpio %u, err=%d\n",
165 gpio, error);
166 goto err_free_gpio;
167 }
168
169 error = gpio_direction_input(gpio);
170 if (error) {
171 dev_err(dev,
172 "unable to set direction on gpio %u, err=%d\n",
173 gpio, error);
174 goto err_free_gpio;
175 }
176
177 bdata->can_sleep = gpio_cansleep(gpio);
178 bdata->last_state = -1;
179 bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
180 pdata->poll_interval);
181
182 input_set_capability(input, type, button->code);
183 }
184
185 bdev->poll_dev = poll_dev;
186 bdev->dev = dev;
187 bdev->pdata = pdata;
188 platform_set_drvdata(pdev, bdev);
189
190 error = input_register_polled_device(poll_dev);
191 if (error) {
192 dev_err(dev, "unable to register polled device, err=%d\n",
193 error);
194 goto err_free_gpio;
195 }
196
197 /* report initial state of the buttons */
198 for (i = 0; i < pdata->nbuttons; i++)
199 gpio_keys_polled_check_state(input, &pdata->buttons[i],
200 &bdev->data[i]);
201
202 return 0;
203
204err_free_gpio:
205 while (--i >= 0)
206 gpio_free(pdata->buttons[i].gpio);
207
208 input_free_polled_device(poll_dev);
209
210err_free_bdev:
211 kfree(bdev);
212
213 platform_set_drvdata(pdev, NULL);
214 return error;
215}
216
217static int __devexit gpio_keys_polled_remove(struct platform_device *pdev)
218{
219 struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
220 struct gpio_keys_platform_data *pdata = bdev->pdata;
221 int i;
222
223 input_unregister_polled_device(bdev->poll_dev);
224
225 for (i = 0; i < pdata->nbuttons; i++)
226 gpio_free(pdata->buttons[i].gpio);
227
228 input_free_polled_device(bdev->poll_dev);
229
230 kfree(bdev);
231 platform_set_drvdata(pdev, NULL);
232
233 return 0;
234}
235
236static struct platform_driver gpio_keys_polled_driver = {
237 .probe = gpio_keys_polled_probe,
238 .remove = __devexit_p(gpio_keys_polled_remove),
239 .driver = {
240 .name = DRV_NAME,
241 .owner = THIS_MODULE,
242 },
243};
244
245static int __init gpio_keys_polled_init(void)
246{
247 return platform_driver_register(&gpio_keys_polled_driver);
248}
249
250static void __exit gpio_keys_polled_exit(void)
251{
252 platform_driver_unregister(&gpio_keys_polled_driver);
253}
254
255module_init(gpio_keys_polled_init);
256module_exit(gpio_keys_polled_exit);
257
258MODULE_LICENSE("GPL v2");
259MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
260MODULE_DESCRIPTION("Polled GPIO Buttons driver");
261MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c
index 4b42ffc0532a..d1583aea1721 100644
--- a/drivers/input/misc/pcf8574_keypad.c
+++ b/drivers/input/misc/pcf8574_keypad.c
@@ -127,14 +127,6 @@ static int __devinit pcf8574_kp_probe(struct i2c_client *client, const struct i2
127 idev->id.product = 0x0001; 127 idev->id.product = 0x0001;
128 idev->id.version = 0x0100; 128 idev->id.version = 0x0100;
129 129
130 input_set_drvdata(idev, lp);
131
132 ret = input_register_device(idev);
133 if (ret) {
134 dev_err(&client->dev, "input_register_device() failed\n");
135 goto fail_register;
136 }
137
138 lp->laststate = read_state(lp); 130 lp->laststate = read_state(lp);
139 131
140 ret = request_threaded_irq(client->irq, NULL, pcf8574_kp_irq_handler, 132 ret = request_threaded_irq(client->irq, NULL, pcf8574_kp_irq_handler,
@@ -142,16 +134,21 @@ static int __devinit pcf8574_kp_probe(struct i2c_client *client, const struct i2
142 DRV_NAME, lp); 134 DRV_NAME, lp);
143 if (ret) { 135 if (ret) {
144 dev_err(&client->dev, "IRQ %d is not free\n", client->irq); 136 dev_err(&client->dev, "IRQ %d is not free\n", client->irq);
145 goto fail_irq; 137 goto fail_free_device;
138 }
139
140 ret = input_register_device(idev);
141 if (ret) {
142 dev_err(&client->dev, "input_register_device() failed\n");
143 goto fail_free_irq;
146 } 144 }
147 145
148 i2c_set_clientdata(client, lp); 146 i2c_set_clientdata(client, lp);
149 return 0; 147 return 0;
150 148
151 fail_irq: 149 fail_free_irq:
152 input_unregister_device(idev); 150 free_irq(client->irq, lp);
153 fail_register: 151 fail_free_device:
154 input_set_drvdata(idev, NULL);
155 input_free_device(idev); 152 input_free_device(idev);
156 fail_allocate: 153 fail_allocate:
157 kfree(lp); 154 kfree(lp);
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index a9cf76831634..b77f9991278e 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -630,7 +630,7 @@ static void atp_complete_geyser_3_4(struct urb *urb)
630 /* Just update the base values (i.e. touchpad in untouched state) */ 630 /* Just update the base values (i.e. touchpad in untouched state) */
631 if (dev->data[dev->info->datalen - 1] & ATP_STATUS_BASE_UPDATE) { 631 if (dev->data[dev->info->datalen - 1] & ATP_STATUS_BASE_UPDATE) {
632 632
633 dprintk(KERN_DEBUG "appletouch: updated base values\n"); 633 dprintk("appletouch: updated base values\n");
634 634
635 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); 635 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
636 goto exit; 636 goto exit;
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 613a3652f98f..0aefaa885871 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -51,7 +51,8 @@
51#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) 51#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
52#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) 52#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) 53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
54#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100) 54#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000) /* 1-button ClickPad */
55#define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100) /* 2-button ClickPad */
55#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) 56#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000)
56 57
57/* synaptics modes query bits */ 58/* synaptics modes query bits */
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
index 3c287dd879d3..4225f5d6b15f 100644
--- a/drivers/input/serio/gscps2.c
+++ b/drivers/input/serio/gscps2.c
@@ -358,7 +358,7 @@ static int __devinit gscps2_probe(struct parisc_device *dev)
358 gscps2_reset(ps2port); 358 gscps2_reset(ps2port);
359 ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f; 359 ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f;
360 360
361 snprintf(serio->name, sizeof(serio->name), "GSC PS/2 %s", 361 snprintf(serio->name, sizeof(serio->name), "gsc-ps2-%s",
362 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse"); 362 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse");
363 strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 363 strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys));
364 serio->id.type = SERIO_8042; 364 serio->id.type = SERIO_8042;
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index ed7ad7416b24..a5475b577086 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -351,6 +351,17 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
351 }, 351 },
352 }, 352 },
353 { 353 {
354 /*
355 * Most (all?) VAIOs do not have external PS/2 ports nor
356 * they implement active multiplexing properly, and
357 * MUX discovery usually messes up keyboard/touchpad.
358 */
359 .matches = {
360 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
361 DMI_MATCH(DMI_BOARD_NAME, "VAIO"),
362 },
363 },
364 {
354 /* Amoi M636/A737 */ 365 /* Amoi M636/A737 */
355 .matches = { 366 .matches = {
356 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."), 367 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index cd82bb125915..b7ba4597f7f0 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/smp_lock.h>
15#include <linux/poll.h> 14#include <linux/poll.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/serio.h> 16#include <linux/serio.h>
diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c
index aea9a9399a36..d94f7e9aa997 100644
--- a/drivers/input/tablet/acecad.c
+++ b/drivers/input/tablet/acecad.c
@@ -229,12 +229,13 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
229 229
230 err = input_register_device(acecad->input); 230 err = input_register_device(acecad->input);
231 if (err) 231 if (err)
232 goto fail2; 232 goto fail3;
233 233
234 usb_set_intfdata(intf, acecad); 234 usb_set_intfdata(intf, acecad);
235 235
236 return 0; 236 return 0;
237 237
238 fail3: usb_free_urb(acecad->irq);
238 fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma); 239 fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma);
239 fail1: input_free_device(input_dev); 240 fail1: input_free_device(input_dev);
240 kfree(acecad); 241 kfree(acecad);
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 57b25b84d1fc..0a619c558bfb 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1097,7 +1097,7 @@ store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const
1097} 1097}
1098 1098
1099static DEVICE_ATTR(pointer_mode, 1099static DEVICE_ATTR(pointer_mode,
1100 S_IRUGO | S_IWUGO, 1100 S_IRUGO | S_IWUSR,
1101 show_tabletPointerMode, store_tabletPointerMode); 1101 show_tabletPointerMode, store_tabletPointerMode);
1102 1102
1103/*********************************************************************** 1103/***********************************************************************
@@ -1134,7 +1134,7 @@ store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, co
1134} 1134}
1135 1135
1136static DEVICE_ATTR(coordinate_mode, 1136static DEVICE_ATTR(coordinate_mode,
1137 S_IRUGO | S_IWUGO, 1137 S_IRUGO | S_IWUSR,
1138 show_tabletCoordinateMode, store_tabletCoordinateMode); 1138 show_tabletCoordinateMode, store_tabletCoordinateMode);
1139 1139
1140/*********************************************************************** 1140/***********************************************************************
@@ -1176,7 +1176,7 @@ store_tabletToolMode(struct device *dev, struct device_attribute *attr, const ch
1176} 1176}
1177 1177
1178static DEVICE_ATTR(tool_mode, 1178static DEVICE_ATTR(tool_mode,
1179 S_IRUGO | S_IWUGO, 1179 S_IRUGO | S_IWUSR,
1180 show_tabletToolMode, store_tabletToolMode); 1180 show_tabletToolMode, store_tabletToolMode);
1181 1181
1182/*********************************************************************** 1182/***********************************************************************
@@ -1219,7 +1219,7 @@ store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char
1219} 1219}
1220 1220
1221static DEVICE_ATTR(xtilt, 1221static DEVICE_ATTR(xtilt,
1222 S_IRUGO | S_IWUGO, show_tabletXtilt, store_tabletXtilt); 1222 S_IRUGO | S_IWUSR, show_tabletXtilt, store_tabletXtilt);
1223 1223
1224/*********************************************************************** 1224/***********************************************************************
1225 * support routines for the 'ytilt' file. Note that this file 1225 * support routines for the 'ytilt' file. Note that this file
@@ -1261,7 +1261,7 @@ store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char
1261} 1261}
1262 1262
1263static DEVICE_ATTR(ytilt, 1263static DEVICE_ATTR(ytilt,
1264 S_IRUGO | S_IWUGO, show_tabletYtilt, store_tabletYtilt); 1264 S_IRUGO | S_IWUSR, show_tabletYtilt, store_tabletYtilt);
1265 1265
1266/*********************************************************************** 1266/***********************************************************************
1267 * support routines for the 'jitter' file. Note that this file 1267 * support routines for the 'jitter' file. Note that this file
@@ -1288,7 +1288,7 @@ store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const
1288} 1288}
1289 1289
1290static DEVICE_ATTR(jitter, 1290static DEVICE_ATTR(jitter,
1291 S_IRUGO | S_IWUGO, 1291 S_IRUGO | S_IWUSR,
1292 show_tabletJitterDelay, store_tabletJitterDelay); 1292 show_tabletJitterDelay, store_tabletJitterDelay);
1293 1293
1294/*********************************************************************** 1294/***********************************************************************
@@ -1317,7 +1317,7 @@ store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr,
1317} 1317}
1318 1318
1319static DEVICE_ATTR(delay, 1319static DEVICE_ATTR(delay,
1320 S_IRUGO | S_IWUGO, 1320 S_IRUGO | S_IWUSR,
1321 show_tabletProgrammableDelay, store_tabletProgrammableDelay); 1321 show_tabletProgrammableDelay, store_tabletProgrammableDelay);
1322 1322
1323/*********************************************************************** 1323/***********************************************************************
@@ -1406,7 +1406,7 @@ store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const
1406} 1406}
1407 1407
1408static DEVICE_ATTR(stylus_upper, 1408static DEVICE_ATTR(stylus_upper,
1409 S_IRUGO | S_IWUGO, 1409 S_IRUGO | S_IWUSR,
1410 show_tabletStylusUpper, store_tabletStylusUpper); 1410 show_tabletStylusUpper, store_tabletStylusUpper);
1411 1411
1412/*********************************************************************** 1412/***********************************************************************
@@ -1437,7 +1437,7 @@ store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const
1437} 1437}
1438 1438
1439static DEVICE_ATTR(stylus_lower, 1439static DEVICE_ATTR(stylus_lower,
1440 S_IRUGO | S_IWUGO, 1440 S_IRUGO | S_IWUSR,
1441 show_tabletStylusLower, store_tabletStylusLower); 1441 show_tabletStylusLower, store_tabletStylusLower);
1442 1442
1443/*********************************************************************** 1443/***********************************************************************
@@ -1475,7 +1475,7 @@ store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const c
1475} 1475}
1476 1476
1477static DEVICE_ATTR(mouse_left, 1477static DEVICE_ATTR(mouse_left,
1478 S_IRUGO | S_IWUGO, 1478 S_IRUGO | S_IWUSR,
1479 show_tabletMouseLeft, store_tabletMouseLeft); 1479 show_tabletMouseLeft, store_tabletMouseLeft);
1480 1480
1481/*********************************************************************** 1481/***********************************************************************
@@ -1505,7 +1505,7 @@ store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const
1505} 1505}
1506 1506
1507static DEVICE_ATTR(mouse_middle, 1507static DEVICE_ATTR(mouse_middle,
1508 S_IRUGO | S_IWUGO, 1508 S_IRUGO | S_IWUSR,
1509 show_tabletMouseMiddle, store_tabletMouseMiddle); 1509 show_tabletMouseMiddle, store_tabletMouseMiddle);
1510 1510
1511/*********************************************************************** 1511/***********************************************************************
@@ -1535,7 +1535,7 @@ store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const
1535} 1535}
1536 1536
1537static DEVICE_ATTR(mouse_right, 1537static DEVICE_ATTR(mouse_right,
1538 S_IRUGO | S_IWUGO, 1538 S_IRUGO | S_IWUSR,
1539 show_tabletMouseRight, store_tabletMouseRight); 1539 show_tabletMouseRight, store_tabletMouseRight);
1540 1540
1541/*********************************************************************** 1541/***********************************************************************
@@ -1567,7 +1567,7 @@ store_tabletWheel(struct device *dev, struct device_attribute *attr, const char
1567} 1567}
1568 1568
1569static DEVICE_ATTR(wheel, 1569static DEVICE_ATTR(wheel,
1570 S_IRUGO | S_IWUGO, show_tabletWheel, store_tabletWheel); 1570 S_IRUGO | S_IWUSR, show_tabletWheel, store_tabletWheel);
1571 1571
1572/*********************************************************************** 1572/***********************************************************************
1573 * support routines for the 'execute' file. Note that this file 1573 * support routines for the 'execute' file. Note that this file
@@ -1600,7 +1600,7 @@ store_tabletExecute(struct device *dev, struct device_attribute *attr, const cha
1600} 1600}
1601 1601
1602static DEVICE_ATTR(execute, 1602static DEVICE_ATTR(execute,
1603 S_IRUGO | S_IWUGO, show_tabletExecute, store_tabletExecute); 1603 S_IRUGO | S_IWUSR, show_tabletExecute, store_tabletExecute);
1604 1604
1605/*********************************************************************** 1605/***********************************************************************
1606 * support routines for the 'odm_code' file. Note that this file 1606 * support routines for the 'odm_code' file. Note that this file
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index b3252ef1e279..435b0af401e4 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1436,6 +1436,14 @@ static struct wacom_features wacom_features_0xD2 =
1436 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1436 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1437static struct wacom_features wacom_features_0xD3 = 1437static struct wacom_features wacom_features_0xD3 =
1438 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1438 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1439static const struct wacom_features wacom_features_0xD4 =
1440 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT };
1441static struct wacom_features wacom_features_0xD8 =
1442 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1443static struct wacom_features wacom_features_0xDA =
1444 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1445static struct wacom_features wacom_features_0xDB =
1446 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1439 1447
1440#define USB_DEVICE_WACOM(prod) \ 1448#define USB_DEVICE_WACOM(prod) \
1441 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 1449 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
@@ -1504,6 +1512,10 @@ const struct usb_device_id wacom_ids[] = {
1504 { USB_DEVICE_WACOM(0xD1) }, 1512 { USB_DEVICE_WACOM(0xD1) },
1505 { USB_DEVICE_WACOM(0xD2) }, 1513 { USB_DEVICE_WACOM(0xD2) },
1506 { USB_DEVICE_WACOM(0xD3) }, 1514 { USB_DEVICE_WACOM(0xD3) },
1515 { USB_DEVICE_WACOM(0xD4) },
1516 { USB_DEVICE_WACOM(0xD8) },
1517 { USB_DEVICE_WACOM(0xDA) },
1518 { USB_DEVICE_WACOM(0xDB) },
1507 { USB_DEVICE_WACOM(0xF0) }, 1519 { USB_DEVICE_WACOM(0xF0) },
1508 { USB_DEVICE_WACOM(0xCC) }, 1520 { USB_DEVICE_WACOM(0xCC) },
1509 { USB_DEVICE_WACOM(0x90) }, 1521 { USB_DEVICE_WACOM(0x90) },
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index ba6f0bd1e762..bc3b5187f3a3 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -129,6 +129,9 @@ struct ad7879 {
129 u16 cmd_crtl1; 129 u16 cmd_crtl1;
130 u16 cmd_crtl2; 130 u16 cmd_crtl2;
131 u16 cmd_crtl3; 131 u16 cmd_crtl3;
132 int x;
133 int y;
134 int Rt;
132}; 135};
133 136
134static int ad7879_read(struct ad7879 *ts, u8 reg) 137static int ad7879_read(struct ad7879 *ts, u8 reg)
@@ -175,13 +178,32 @@ static int ad7879_report(struct ad7879 *ts)
175 Rt /= z1; 178 Rt /= z1;
176 Rt = (Rt + 2047) >> 12; 179 Rt = (Rt + 2047) >> 12;
177 180
178 if (!timer_pending(&ts->timer)) 181 /*
182 * Sample found inconsistent, pressure is beyond
183 * the maximum. Don't report it to user space.
184 */
185 if (Rt > ts->pressure_max)
186 return -EINVAL;
187
188 /*
189 * Note that we delay reporting events by one sample.
190 * This is done to avoid reporting last sample of the
191 * touch sequence, which may be incomplete if finger
192 * leaves the surface before last reading is taken.
193 */
194 if (timer_pending(&ts->timer)) {
195 /* Touch continues */
179 input_report_key(input_dev, BTN_TOUCH, 1); 196 input_report_key(input_dev, BTN_TOUCH, 1);
197 input_report_abs(input_dev, ABS_X, ts->x);
198 input_report_abs(input_dev, ABS_Y, ts->y);
199 input_report_abs(input_dev, ABS_PRESSURE, ts->Rt);
200 input_sync(input_dev);
201 }
202
203 ts->x = x;
204 ts->y = y;
205 ts->Rt = Rt;
180 206
181 input_report_abs(input_dev, ABS_X, x);
182 input_report_abs(input_dev, ABS_Y, y);
183 input_report_abs(input_dev, ABS_PRESSURE, Rt);
184 input_sync(input_dev);
185 return 0; 207 return 0;
186 } 208 }
187 209
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index ccde58602563..2ca9e5d66460 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -514,7 +514,7 @@ err_free_irq:
514err_cs_disable: 514err_cs_disable:
515 pdata->cs_dis(pdata->cs_pin); 515 pdata->cs_dis(pdata->cs_pin);
516err_free_mem: 516err_free_mem:
517 input_free_device(bu21013_data->in_dev); 517 input_free_device(in_dev);
518 kfree(bu21013_data); 518 kfree(bu21013_data);
519 519
520 return error; 520 return error;
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index f45f80f6d336..73fd6642b681 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -178,6 +178,7 @@ static const struct usb_device_id usbtouch_devices[] = {
178 178
179#ifdef CONFIG_TOUCHSCREEN_USB_ITM 179#ifdef CONFIG_TOUCHSCREEN_USB_ITM
180 {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM}, 180 {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM},
181 {USB_DEVICE(0x16e3, 0xf9e9), .driver_info = DEVTYPE_ITM},
181#endif 182#endif
182 183
183#ifdef CONFIG_TOUCHSCREEN_USB_ETURBO 184#ifdef CONFIG_TOUCHSCREEN_USB_ETURBO