aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/hid-input.c24
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/input/input.c38
-rw-r--r--drivers/input/joystick/gamecon.c2
-rw-r--r--drivers/input/keyboard/bf54x-keys.c2
-rw-r--r--drivers/input/misc/Kconfig11
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ati_remote2.c14
-rw-r--r--drivers/input/misc/twl4030-vibra.c297
-rw-r--r--drivers/input/misc/winbond-cir.c12
-rw-r--r--drivers/input/misc/wm831x-on.c9
-rw-r--r--drivers/input/mouse/alps.c49
-rw-r--r--drivers/input/mouse/appletouch.c6
-rw-r--r--drivers/input/mousedev.c6
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h10
-rw-r--r--drivers/input/serio/i8042.c24
-rw-r--r--drivers/input/serio/serio_raw.c11
-rw-r--r--drivers/input/sparse-keymap.c6
-rw-r--r--drivers/input/tablet/wacom_sys.c4
-rw-r--r--drivers/input/tablet/wacom_wac.c165
-rw-r--r--drivers/input/tablet/wacom_wac.h1
-rw-r--r--drivers/input/touchscreen/Kconfig9
-rw-r--r--drivers/input/touchscreen/ad7877.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c20
-rw-r--r--drivers/media/IR/ir-keytable.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c4
-rw-r--r--drivers/platform/x86/dell-wmi.c16
-rw-r--r--drivers/platform/x86/hp-wmi.c15
-rw-r--r--drivers/platform/x86/panasonic-laptop.c15
-rw-r--r--drivers/platform/x86/topstar-laptop.c13
-rw-r--r--drivers/platform/x86/toshiba_acpi.c17
31 files changed, 535 insertions, 274 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 79d9edd0bdfa..7a0d2e4661a1 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -68,22 +68,25 @@ static const struct {
68#define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \ 68#define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
69 &max, EV_KEY, (c)) 69 &max, EV_KEY, (c))
70 70
71static inline int match_scancode(int code, int scancode) 71static inline int match_scancode(unsigned int code, unsigned int scancode)
72{ 72{
73 if (scancode == 0) 73 if (scancode == 0)
74 return 1; 74 return 1;
75 return ((code & (HID_USAGE_PAGE | HID_USAGE)) == scancode); 75
76 return (code & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
76} 77}
77 78
78static inline int match_keycode(int code, int keycode) 79static inline int match_keycode(unsigned int code, unsigned int keycode)
79{ 80{
80 if (keycode == 0) 81 if (keycode == 0)
81 return 1; 82 return 1;
82 return (code == keycode); 83
84 return code == keycode;
83} 85}
84 86
85static struct hid_usage *hidinput_find_key(struct hid_device *hid, 87static struct hid_usage *hidinput_find_key(struct hid_device *hid,
86 int scancode, int keycode) 88 unsigned int scancode,
89 unsigned int keycode)
87{ 90{
88 int i, j, k; 91 int i, j, k;
89 struct hid_report *report; 92 struct hid_report *report;
@@ -105,8 +108,8 @@ static struct hid_usage *hidinput_find_key(struct hid_device *hid,
105 return NULL; 108 return NULL;
106} 109}
107 110
108static int hidinput_getkeycode(struct input_dev *dev, int scancode, 111static int hidinput_getkeycode(struct input_dev *dev,
109 int *keycode) 112 unsigned int scancode, unsigned int *keycode)
110{ 113{
111 struct hid_device *hid = input_get_drvdata(dev); 114 struct hid_device *hid = input_get_drvdata(dev);
112 struct hid_usage *usage; 115 struct hid_usage *usage;
@@ -119,16 +122,13 @@ static int hidinput_getkeycode(struct input_dev *dev, int scancode,
119 return -EINVAL; 122 return -EINVAL;
120} 123}
121 124
122static int hidinput_setkeycode(struct input_dev *dev, int scancode, 125static int hidinput_setkeycode(struct input_dev *dev,
123 int keycode) 126 unsigned int scancode, unsigned int keycode)
124{ 127{
125 struct hid_device *hid = input_get_drvdata(dev); 128 struct hid_device *hid = input_get_drvdata(dev);
126 struct hid_usage *usage; 129 struct hid_usage *usage;
127 int old_keycode; 130 int old_keycode;
128 131
129 if (keycode < 0 || keycode > KEY_MAX)
130 return -EINVAL;
131
132 usage = hidinput_find_key(hid, scancode, 0); 132 usage = hidinput_find_key(hid, scancode, 0);
133 if (usage) { 133 if (usage) {
134 old_keycode = usage->code; 134 old_keycode = usage->code;
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 9f9816baeb97..2ee6c7a68bdc 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -515,7 +515,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
515 struct input_absinfo abs; 515 struct input_absinfo abs;
516 struct ff_effect effect; 516 struct ff_effect effect;
517 int __user *ip = (int __user *)p; 517 int __user *ip = (int __user *)p;
518 int i, t, u, v; 518 unsigned int i, t, u, v;
519 int error; 519 int error;
520 520
521 switch (cmd) { 521 switch (cmd) {
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 41168d5f8c17..e2aad0a51826 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -582,7 +582,8 @@ static int input_fetch_keycode(struct input_dev *dev, int scancode)
582} 582}
583 583
584static int input_default_getkeycode(struct input_dev *dev, 584static int input_default_getkeycode(struct input_dev *dev,
585 int scancode, int *keycode) 585 unsigned int scancode,
586 unsigned int *keycode)
586{ 587{
587 if (!dev->keycodesize) 588 if (!dev->keycodesize)
588 return -EINVAL; 589 return -EINVAL;
@@ -596,7 +597,8 @@ static int input_default_getkeycode(struct input_dev *dev,
596} 597}
597 598
598static int input_default_setkeycode(struct input_dev *dev, 599static int input_default_setkeycode(struct input_dev *dev,
599 int scancode, int keycode) 600 unsigned int scancode,
601 unsigned int keycode)
600{ 602{
601 int old_keycode; 603 int old_keycode;
602 int i; 604 int i;
@@ -654,11 +656,9 @@ static int input_default_setkeycode(struct input_dev *dev,
654 * This function should be called by anyone interested in retrieving current 656 * This function should be called by anyone interested in retrieving current
655 * keymap. Presently keyboard and evdev handlers use it. 657 * keymap. Presently keyboard and evdev handlers use it.
656 */ 658 */
657int input_get_keycode(struct input_dev *dev, int scancode, int *keycode) 659int input_get_keycode(struct input_dev *dev,
660 unsigned int scancode, unsigned int *keycode)
658{ 661{
659 if (scancode < 0)
660 return -EINVAL;
661
662 return dev->getkeycode(dev, scancode, keycode); 662 return dev->getkeycode(dev, scancode, keycode);
663} 663}
664EXPORT_SYMBOL(input_get_keycode); 664EXPORT_SYMBOL(input_get_keycode);
@@ -672,16 +672,14 @@ EXPORT_SYMBOL(input_get_keycode);
672 * This function should be called by anyone needing to update current 672 * This function should be called by anyone needing to update current
673 * keymap. Presently keyboard and evdev handlers use it. 673 * keymap. Presently keyboard and evdev handlers use it.
674 */ 674 */
675int input_set_keycode(struct input_dev *dev, int scancode, int keycode) 675int input_set_keycode(struct input_dev *dev,
676 unsigned int scancode, unsigned int keycode)
676{ 677{
677 unsigned long flags; 678 unsigned long flags;
678 int old_keycode; 679 int old_keycode;
679 int retval; 680 int retval;
680 681
681 if (scancode < 0) 682 if (keycode > KEY_MAX)
682 return -EINVAL;
683
684 if (keycode < 0 || keycode > KEY_MAX)
685 return -EINVAL; 683 return -EINVAL;
686 684
687 spin_lock_irqsave(&dev->event_lock, flags); 685 spin_lock_irqsave(&dev->event_lock, flags);
@@ -1881,35 +1879,37 @@ static int input_open_file(struct inode *inode, struct file *file)
1881 const struct file_operations *old_fops, *new_fops = NULL; 1879 const struct file_operations *old_fops, *new_fops = NULL;
1882 int err; 1880 int err;
1883 1881
1884 lock_kernel(); 1882 err = mutex_lock_interruptible(&input_mutex);
1883 if (err)
1884 return err;
1885
1885 /* No load-on-demand here? */ 1886 /* No load-on-demand here? */
1886 handler = input_table[iminor(inode) >> 5]; 1887 handler = input_table[iminor(inode) >> 5];
1887 if (!handler || !(new_fops = fops_get(handler->fops))) { 1888 if (handler)
1888 err = -ENODEV; 1889 new_fops = fops_get(handler->fops);
1889 goto out; 1890
1890 } 1891 mutex_unlock(&input_mutex);
1891 1892
1892 /* 1893 /*
1893 * That's _really_ odd. Usually NULL ->open means "nothing special", 1894 * That's _really_ odd. Usually NULL ->open means "nothing special",
1894 * not "no device". Oh, well... 1895 * not "no device". Oh, well...
1895 */ 1896 */
1896 if (!new_fops->open) { 1897 if (!new_fops || !new_fops->open) {
1897 fops_put(new_fops); 1898 fops_put(new_fops);
1898 err = -ENODEV; 1899 err = -ENODEV;
1899 goto out; 1900 goto out;
1900 } 1901 }
1902
1901 old_fops = file->f_op; 1903 old_fops = file->f_op;
1902 file->f_op = new_fops; 1904 file->f_op = new_fops;
1903 1905
1904 err = new_fops->open(inode, file); 1906 err = new_fops->open(inode, file);
1905
1906 if (err) { 1907 if (err) {
1907 fops_put(file->f_op); 1908 fops_put(file->f_op);
1908 file->f_op = fops_get(old_fops); 1909 file->f_op = fops_get(old_fops);
1909 } 1910 }
1910 fops_put(old_fops); 1911 fops_put(old_fops);
1911out: 1912out:
1912 unlock_kernel();
1913 return err; 1913 return err;
1914} 1914}
1915 1915
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index ae998d99a5ae..7a55714a1486 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -819,7 +819,7 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
819 int i; 819 int i;
820 int err; 820 int err;
821 821
822 if (pad_type < 1 || pad_type > GC_MAX) { 822 if (pad_type < 1 || pad_type >= GC_MAX) {
823 pr_err("Pad type %d unknown\n", pad_type); 823 pr_err("Pad type %d unknown\n", pad_type);
824 return -EINVAL; 824 return -EINVAL;
825 } 825 }
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index fe376a27fe57..593c052416b9 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -162,7 +162,7 @@ static irqreturn_t bfin_kpad_isr(int irq, void *dev_id)
162 input_sync(input); 162 input_sync(input);
163 163
164 if (bfin_kpad_get_keypressed(bf54x_kpad)) { 164 if (bfin_kpad_get_keypressed(bf54x_kpad)) {
165 disable_irq(bf54x_kpad->irq); 165 disable_irq_nosync(bf54x_kpad->irq);
166 bf54x_kpad->lastkey = key; 166 bf54x_kpad->lastkey = key;
167 mod_timer(&bf54x_kpad->timer, 167 mod_timer(&bf54x_kpad->timer,
168 jiffies + bf54x_kpad->keyup_test_jiffies); 168 jiffies + bf54x_kpad->keyup_test_jiffies);
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7097bfe581d7..23140a3bb8e0 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -214,6 +214,17 @@ config INPUT_TWL4030_PWRBUTTON
214 To compile this driver as a module, choose M here. The module will 214 To compile this driver as a module, choose M here. The module will
215 be called twl4030_pwrbutton. 215 be called twl4030_pwrbutton.
216 216
217config INPUT_TWL4030_VIBRA
218 tristate "Support for TWL4030 Vibrator"
219 depends on TWL4030_CORE
220 select TWL4030_CODEC
221 select INPUT_FF_MEMLESS
222 help
223 This option enables support for TWL4030 Vibrator Driver.
224
225 To compile this driver as a module, choose M here. The module will
226 be called twl4030_vibra.
227
217config INPUT_UINPUT 228config INPUT_UINPUT
218 tristate "User level driver support" 229 tristate "User level driver support"
219 help 230 help
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b611615e24ad..7e95a5d474dc 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
26obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 26obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
27obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o 27obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o
28obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o 28obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o
29obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o
29obj-$(CONFIG_INPUT_UINPUT) += uinput.o 30obj-$(CONFIG_INPUT_UINPUT) += uinput.o
30obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o 31obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o
31obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o 32obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 0501f0e65157..15be5430bc6d 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -474,10 +474,11 @@ static void ati_remote2_complete_key(struct urb *urb)
474} 474}
475 475
476static int ati_remote2_getkeycode(struct input_dev *idev, 476static int ati_remote2_getkeycode(struct input_dev *idev,
477 int scancode, int *keycode) 477 unsigned int scancode, unsigned int *keycode)
478{ 478{
479 struct ati_remote2 *ar2 = input_get_drvdata(idev); 479 struct ati_remote2 *ar2 = input_get_drvdata(idev);
480 int index, mode; 480 unsigned int mode;
481 int index;
481 482
482 mode = scancode >> 8; 483 mode = scancode >> 8;
483 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask)) 484 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
@@ -491,10 +492,12 @@ static int ati_remote2_getkeycode(struct input_dev *idev,
491 return 0; 492 return 0;
492} 493}
493 494
494static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keycode) 495static int ati_remote2_setkeycode(struct input_dev *idev,
496 unsigned int scancode, unsigned int keycode)
495{ 497{
496 struct ati_remote2 *ar2 = input_get_drvdata(idev); 498 struct ati_remote2 *ar2 = input_get_drvdata(idev);
497 int index, mode, old_keycode; 499 unsigned int mode, old_keycode;
500 int index;
498 501
499 mode = scancode >> 8; 502 mode = scancode >> 8;
500 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask)) 503 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
@@ -504,9 +507,6 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc
504 if (index < 0) 507 if (index < 0)
505 return -EINVAL; 508 return -EINVAL;
506 509
507 if (keycode < KEY_RESERVED || keycode > KEY_MAX)
508 return -EINVAL;
509
510 old_keycode = ar2->keycode[mode][index]; 510 old_keycode = ar2->keycode[mode][index];
511 ar2->keycode[mode][index] = keycode; 511 ar2->keycode[mode][index] = keycode;
512 __set_bit(keycode, idev->keybit); 512 __set_bit(keycode, idev->keybit);
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
new file mode 100644
index 000000000000..2fb79e064da3
--- /dev/null
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -0,0 +1,297 @@
1/*
2 * twl4030-vibra.c - TWL4030 Vibrator driver
3 *
4 * Copyright (C) 2008-2010 Nokia Corporation
5 *
6 * Written by Henrik Saari <henrik.saari@nokia.com>
7 * Updates by Felipe Balbi <felipe.balbi@nokia.com>
8 * Input by Jari Vanhala <ext-jari.vanhala@nokia.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 *
24 */
25
26#include <linux/module.h>
27#include <linux/jiffies.h>
28#include <linux/platform_device.h>
29#include <linux/workqueue.h>
30#include <linux/i2c/twl.h>
31#include <linux/mfd/twl4030-codec.h>
32#include <linux/input.h>
33
34/* MODULE ID2 */
35#define LEDEN 0x00
36
37/* ForceFeedback */
38#define EFFECT_DIR_180_DEG 0x8000 /* range is 0 - 0xFFFF */
39
40struct vibra_info {
41 struct device *dev;
42 struct input_dev *input_dev;
43
44 struct workqueue_struct *workqueue;
45 struct work_struct play_work;
46
47 bool enabled;
48 int speed;
49 int direction;
50
51 bool coexist;
52};
53
54static void vibra_disable_leds(void)
55{
56 u8 reg;
57
58 /* Disable LEDA & LEDB, cannot be used with vibra (PWM) */
59 twl_i2c_read_u8(TWL4030_MODULE_LED, &reg, LEDEN);
60 reg &= ~0x03;
61 twl_i2c_write_u8(TWL4030_MODULE_LED, LEDEN, reg);
62}
63
64/* Powers H-Bridge and enables audio clk */
65static void vibra_enable(struct vibra_info *info)
66{
67 u8 reg;
68
69 twl4030_codec_enable_resource(TWL4030_CODEC_RES_POWER);
70
71 /* turn H-Bridge on */
72 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
73 &reg, TWL4030_REG_VIBRA_CTL);
74 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
75 (reg | TWL4030_VIBRA_EN), TWL4030_REG_VIBRA_CTL);
76
77 twl4030_codec_enable_resource(TWL4030_CODEC_RES_APLL);
78
79 info->enabled = true;
80}
81
82static void vibra_disable(struct vibra_info *info)
83{
84 u8 reg;
85
86 /* Power down H-Bridge */
87 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
88 &reg, TWL4030_REG_VIBRA_CTL);
89 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
90 (reg & ~TWL4030_VIBRA_EN), TWL4030_REG_VIBRA_CTL);
91
92 twl4030_codec_disable_resource(TWL4030_CODEC_RES_POWER);
93 twl4030_codec_disable_resource(TWL4030_CODEC_RES_APLL);
94
95 info->enabled = false;
96}
97
98static void vibra_play_work(struct work_struct *work)
99{
100 struct vibra_info *info = container_of(work,
101 struct vibra_info, play_work);
102 int dir;
103 int pwm;
104 u8 reg;
105
106 dir = info->direction;
107 pwm = info->speed;
108
109 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
110 &reg, TWL4030_REG_VIBRA_CTL);
111 if (pwm && (!info->coexist || !(reg & TWL4030_VIBRA_SEL))) {
112
113 if (!info->enabled)
114 vibra_enable(info);
115
116 /* set vibra rotation direction */
117 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
118 &reg, TWL4030_REG_VIBRA_CTL);
119 reg = (dir) ? (reg | TWL4030_VIBRA_DIR) :
120 (reg & ~TWL4030_VIBRA_DIR);
121 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
122 reg, TWL4030_REG_VIBRA_CTL);
123
124 /* set PWM, 1 = max, 255 = min */
125 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
126 256 - pwm, TWL4030_REG_VIBRA_SET);
127 } else {
128 if (info->enabled)
129 vibra_disable(info);
130 }
131}
132
133/*** Input/ForceFeedback ***/
134
135static int vibra_play(struct input_dev *input, void *data,
136 struct ff_effect *effect)
137{
138 struct vibra_info *info = input_get_drvdata(input);
139
140 info->speed = effect->u.rumble.strong_magnitude >> 8;
141 if (!info->speed)
142 info->speed = effect->u.rumble.weak_magnitude >> 9;
143 info->direction = effect->direction < EFFECT_DIR_180_DEG ? 0 : 1;
144 queue_work(info->workqueue, &info->play_work);
145 return 0;
146}
147
148static int twl4030_vibra_open(struct input_dev *input)
149{
150 struct vibra_info *info = input_get_drvdata(input);
151
152 info->workqueue = create_singlethread_workqueue("vibra");
153 if (info->workqueue == NULL) {
154 dev_err(&input->dev, "couldn't create workqueue\n");
155 return -ENOMEM;
156 }
157 return 0;
158}
159
160static void twl4030_vibra_close(struct input_dev *input)
161{
162 struct vibra_info *info = input_get_drvdata(input);
163
164 cancel_work_sync(&info->play_work);
165 INIT_WORK(&info->play_work, vibra_play_work); /* cleanup */
166 destroy_workqueue(info->workqueue);
167 info->workqueue = NULL;
168
169 if (info->enabled)
170 vibra_disable(info);
171}
172
173/*** Module ***/
174#if CONFIG_PM
175static int twl4030_vibra_suspend(struct device *dev)
176{
177 struct platform_device *pdev = to_platform_device(dev);
178 struct vibra_info *info = platform_get_drvdata(pdev);
179
180 if (info->enabled)
181 vibra_disable(info);
182
183 return 0;
184}
185
186static int twl4030_vibra_resume(struct device *dev)
187{
188 vibra_disable_leds();
189 return 0;
190}
191
192static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops,
193 twl4030_vibra_suspend, twl4030_vibra_resume);
194#endif
195
196static int __devinit twl4030_vibra_probe(struct platform_device *pdev)
197{
198 struct twl4030_codec_vibra_data *pdata = pdev->dev.platform_data;
199 struct vibra_info *info;
200 int ret;
201
202 if (!pdata) {
203 dev_dbg(&pdev->dev, "platform_data not available\n");
204 return -EINVAL;
205 }
206
207 info = kzalloc(sizeof(*info), GFP_KERNEL);
208 if (!info)
209 return -ENOMEM;
210
211 info->dev = &pdev->dev;
212 info->coexist = pdata->coexist;
213 INIT_WORK(&info->play_work, vibra_play_work);
214
215 info->input_dev = input_allocate_device();
216 if (info->input_dev == NULL) {
217 dev_err(&pdev->dev, "couldn't allocate input device\n");
218 ret = -ENOMEM;
219 goto err_kzalloc;
220 }
221
222 input_set_drvdata(info->input_dev, info);
223
224 info->input_dev->name = "twl4030:vibrator";
225 info->input_dev->id.version = 1;
226 info->input_dev->dev.parent = pdev->dev.parent;
227 info->input_dev->open = twl4030_vibra_open;
228 info->input_dev->close = twl4030_vibra_close;
229 __set_bit(FF_RUMBLE, info->input_dev->ffbit);
230
231 ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
232 if (ret < 0) {
233 dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n");
234 goto err_ialloc;
235 }
236
237 ret = input_register_device(info->input_dev);
238 if (ret < 0) {
239 dev_dbg(&pdev->dev, "couldn't register input device\n");
240 goto err_iff;
241 }
242
243 vibra_disable_leds();
244
245 platform_set_drvdata(pdev, info);
246 return 0;
247
248err_iff:
249 input_ff_destroy(info->input_dev);
250err_ialloc:
251 input_free_device(info->input_dev);
252err_kzalloc:
253 kfree(info);
254 return ret;
255}
256
257static int __devexit twl4030_vibra_remove(struct platform_device *pdev)
258{
259 struct vibra_info *info = platform_get_drvdata(pdev);
260
261 /* this also free ff-memless and calls close if needed */
262 input_unregister_device(info->input_dev);
263 kfree(info);
264 platform_set_drvdata(pdev, NULL);
265
266 return 0;
267}
268
269static struct platform_driver twl4030_vibra_driver = {
270 .probe = twl4030_vibra_probe,
271 .remove = __devexit_p(twl4030_vibra_remove),
272 .driver = {
273 .name = "twl4030_codec_vibra",
274 .owner = THIS_MODULE,
275#ifdef CONFIG_PM
276 .pm = &twl4030_vibra_pm_ops,
277#endif
278 },
279};
280
281static int __init twl4030_vibra_init(void)
282{
283 return platform_driver_register(&twl4030_vibra_driver);
284}
285module_init(twl4030_vibra_init);
286
287static void __exit twl4030_vibra_exit(void)
288{
289 platform_driver_unregister(&twl4030_vibra_driver);
290}
291module_exit(twl4030_vibra_exit);
292
293MODULE_ALIAS("platform:twl4030_codec_vibra");
294
295MODULE_DESCRIPTION("TWL4030 Vibra driver");
296MODULE_LICENSE("GPL");
297MODULE_AUTHOR("Nokia Corporation");
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index cbec3dfdd42b..9c155a43abc2 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -385,26 +385,24 @@ wbcir_do_getkeycode(struct wbcir_data *data, u32 scancode)
385} 385}
386 386
387static int 387static int
388wbcir_getkeycode(struct input_dev *dev, int scancode, int *keycode) 388wbcir_getkeycode(struct input_dev *dev,
389 unsigned int scancode, unsigned int *keycode)
389{ 390{
390 struct wbcir_data *data = input_get_drvdata(dev); 391 struct wbcir_data *data = input_get_drvdata(dev);
391 392
392 *keycode = (int)wbcir_do_getkeycode(data, (u32)scancode); 393 *keycode = wbcir_do_getkeycode(data, scancode);
393 return 0; 394 return 0;
394} 395}
395 396
396static int 397static int
397wbcir_setkeycode(struct input_dev *dev, int sscancode, int keycode) 398wbcir_setkeycode(struct input_dev *dev,
399 unsigned int scancode, unsigned int keycode)
398{ 400{
399 struct wbcir_data *data = input_get_drvdata(dev); 401 struct wbcir_data *data = input_get_drvdata(dev);
400 struct wbcir_keyentry *keyentry; 402 struct wbcir_keyentry *keyentry;
401 struct wbcir_keyentry *new_keyentry; 403 struct wbcir_keyentry *new_keyentry;
402 unsigned long flags; 404 unsigned long flags;
403 unsigned int old_keycode = KEY_RESERVED; 405 unsigned int old_keycode = KEY_RESERVED;
404 u32 scancode = (u32)sscancode;
405
406 if (keycode < 0 || keycode > KEY_MAX)
407 return -EINVAL;
408 406
409 new_keyentry = kmalloc(sizeof(*new_keyentry), GFP_KERNEL); 407 new_keyentry = kmalloc(sizeof(*new_keyentry), GFP_KERNEL);
410 if (!new_keyentry) 408 if (!new_keyentry)
diff --git a/drivers/input/misc/wm831x-on.c b/drivers/input/misc/wm831x-on.c
index ba4f5dd7c60e..1e54bce72db5 100644
--- a/drivers/input/misc/wm831x-on.c
+++ b/drivers/input/misc/wm831x-on.c
@@ -97,8 +97,9 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)
97 wm831x_on->dev->phys = "wm831x_on/input0"; 97 wm831x_on->dev->phys = "wm831x_on/input0";
98 wm831x_on->dev->dev.parent = &pdev->dev; 98 wm831x_on->dev->dev.parent = &pdev->dev;
99 99
100 ret = wm831x_request_irq(wm831x, irq, wm831x_on_irq, 100 ret = request_threaded_irq(irq, NULL, wm831x_on_irq,
101 IRQF_TRIGGER_RISING, "wm831x_on", wm831x_on); 101 IRQF_TRIGGER_RISING, "wm831x_on",
102 wm831x_on);
102 if (ret < 0) { 103 if (ret < 0) {
103 dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret); 104 dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret);
104 goto err_input_dev; 105 goto err_input_dev;
@@ -114,7 +115,7 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)
114 return 0; 115 return 0;
115 116
116err_irq: 117err_irq:
117 wm831x_free_irq(wm831x, irq, NULL); 118 free_irq(irq, wm831x_on);
118err_input_dev: 119err_input_dev:
119 input_free_device(wm831x_on->dev); 120 input_free_device(wm831x_on->dev);
120err: 121err:
@@ -127,7 +128,7 @@ static int __devexit wm831x_on_remove(struct platform_device *pdev)
127 struct wm831x_on *wm831x_on = platform_get_drvdata(pdev); 128 struct wm831x_on *wm831x_on = platform_get_drvdata(pdev);
128 int irq = platform_get_irq(pdev, 0); 129 int irq = platform_get_irq(pdev, 0);
129 130
130 wm831x_free_irq(wm831x_on->wm831x, irq, wm831x_on); 131 free_irq(irq, wm831x_on);
131 cancel_delayed_work_sync(&wm831x_on->work); 132 cancel_delayed_work_sync(&wm831x_on->work);
132 input_unregister_device(wm831x_on->dev); 133 input_unregister_device(wm831x_on->dev);
133 kfree(wm831x_on); 134 kfree(wm831x_on);
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index f93c2c0daf1f..7490f1da4a53 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -63,6 +63,8 @@ static const struct alps_model_info alps_model_data[] = {
63 { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, 63 { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf,
64 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, 64 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED },
65 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ 65 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
66 { { 0x52, 0x01, 0x14 }, 0xff, 0xff,
67 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */
66}; 68};
67 69
68/* 70/*
@@ -118,40 +120,27 @@ static void alps_report_buttons(struct psmouse *psmouse,
118 struct input_dev *dev1, struct input_dev *dev2, 120 struct input_dev *dev1, struct input_dev *dev2,
119 int left, int right, int middle) 121 int left, int right, int middle)
120{ 122{
121 struct alps_data *priv = psmouse->private; 123 struct input_dev *dev;
122 const struct alps_model_info *model = priv->i;
123
124 if (model->flags & ALPS_PS2_INTERLEAVED) {
125 struct input_dev *dev;
126 124
127 /* 125 /*
128 * If shared button has already been reported on the 126 * If shared button has already been reported on the
129 * other device (dev2) then this event should be also 127 * other device (dev2) then this event should be also
130 * sent through that device. 128 * sent through that device.
131 */ 129 */
132 dev = test_bit(BTN_LEFT, dev2->key) ? dev2 : dev1; 130 dev = test_bit(BTN_LEFT, dev2->key) ? dev2 : dev1;
133 input_report_key(dev, BTN_LEFT, left); 131 input_report_key(dev, BTN_LEFT, left);
134 132
135 dev = test_bit(BTN_RIGHT, dev2->key) ? dev2 : dev1; 133 dev = test_bit(BTN_RIGHT, dev2->key) ? dev2 : dev1;
136 input_report_key(dev, BTN_RIGHT, right); 134 input_report_key(dev, BTN_RIGHT, right);
137 135
138 dev = test_bit(BTN_MIDDLE, dev2->key) ? dev2 : dev1; 136 dev = test_bit(BTN_MIDDLE, dev2->key) ? dev2 : dev1;
139 input_report_key(dev, BTN_MIDDLE, middle); 137 input_report_key(dev, BTN_MIDDLE, middle);
140 138
141 /* 139 /*
142 * Sync the _other_ device now, we'll do the first 140 * Sync the _other_ device now, we'll do the first
143 * device later once we report the rest of the events. 141 * device later once we report the rest of the events.
144 */ 142 */
145 input_sync(dev2); 143 input_sync(dev2);
146 } else {
147 /*
148 * For devices with non-interleaved packets we know what
149 * device buttons belong to so we can simply report them.
150 */
151 input_report_key(dev1, BTN_LEFT, left);
152 input_report_key(dev1, BTN_RIGHT, right);
153 input_report_key(dev1, BTN_MIDDLE, middle);
154 }
155} 144}
156 145
157static void alps_process_packet(struct psmouse *psmouse) 146static void alps_process_packet(struct psmouse *psmouse)
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index 908b5b44052f..53ec7ddd1826 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -205,8 +205,8 @@ struct atp {
205 bool overflow_warned; 205 bool overflow_warned;
206 int x_old; /* last reported x/y, */ 206 int x_old; /* last reported x/y, */
207 int y_old; /* used for smoothing */ 207 int y_old; /* used for smoothing */
208 signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; 208 u8 xy_cur[ATP_XSENSORS + ATP_YSENSORS];
209 signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; 209 u8 xy_old[ATP_XSENSORS + ATP_YSENSORS];
210 int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; 210 int xy_acc[ATP_XSENSORS + ATP_YSENSORS];
211 int idlecount; /* number of empty packets */ 211 int idlecount; /* number of empty packets */
212 struct work_struct work; 212 struct work_struct work;
@@ -531,7 +531,7 @@ static void atp_complete_geyser_1_2(struct urb *urb)
531 531
532 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { 532 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
533 /* accumulate the change */ 533 /* accumulate the change */
534 signed char change = dev->xy_old[i] - dev->xy_cur[i]; 534 int change = dev->xy_old[i] - dev->xy_cur[i];
535 dev->xy_acc[i] -= change; 535 dev->xy_acc[i] -= change;
536 536
537 /* prevent down drifting */ 537 /* prevent down drifting */
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index a13d80f7da17..f34b22bce4ff 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -15,7 +15,6 @@
15 15
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/smp_lock.h>
19#include <linux/poll.h> 18#include <linux/poll.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/init.h> 20#include <linux/init.h>
@@ -542,10 +541,8 @@ static int mousedev_open(struct inode *inode, struct file *file)
542 if (i >= MOUSEDEV_MINORS) 541 if (i >= MOUSEDEV_MINORS)
543 return -ENODEV; 542 return -ENODEV;
544 543
545 lock_kernel();
546 error = mutex_lock_interruptible(&mousedev_table_mutex); 544 error = mutex_lock_interruptible(&mousedev_table_mutex);
547 if (error) { 545 if (error) {
548 unlock_kernel();
549 return error; 546 return error;
550 } 547 }
551 mousedev = mousedev_table[i]; 548 mousedev = mousedev_table[i];
@@ -554,7 +551,6 @@ static int mousedev_open(struct inode *inode, struct file *file)
554 mutex_unlock(&mousedev_table_mutex); 551 mutex_unlock(&mousedev_table_mutex);
555 552
556 if (!mousedev) { 553 if (!mousedev) {
557 unlock_kernel();
558 return -ENODEV; 554 return -ENODEV;
559 } 555 }
560 556
@@ -575,7 +571,6 @@ static int mousedev_open(struct inode *inode, struct file *file)
575 goto err_free_client; 571 goto err_free_client;
576 572
577 file->private_data = client; 573 file->private_data = client;
578 unlock_kernel();
579 return 0; 574 return 0;
580 575
581 err_free_client: 576 err_free_client:
@@ -583,7 +578,6 @@ static int mousedev_open(struct inode *inode, struct file *file)
583 kfree(client); 578 kfree(client);
584 err_put_mousedev: 579 err_put_mousedev:
585 put_device(&mousedev->dev); 580 put_device(&mousedev->dev);
586 unlock_kernel();
587 return error; 581 return error;
588} 582}
589 583
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 2a5982e532f8..ead0494721d0 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -442,6 +442,13 @@ static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = {
442 }, 442 },
443 }, 443 },
444 { 444 {
445 /* Medion Akoya E1222 */
446 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
448 DMI_MATCH(DMI_PRODUCT_NAME, "E122X"),
449 },
450 },
451 {
445 /* Mivvy M310 */ 452 /* Mivvy M310 */
446 .matches = { 453 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"), 454 DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
@@ -624,6 +631,9 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *
624 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); 631 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
625 } 632 }
626 633
634 /* Keyboard ports are always supposed to be wakeup-enabled */
635 device_set_wakeup_enable(&dev->dev, true);
636
627 i8042_pnp_kbd_devices++; 637 i8042_pnp_kbd_devices++;
628 return 0; 638 return 0;
629} 639}
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index ff4d77c4de11..9302ba0e48f8 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1386,6 +1386,8 @@ static int __init i8042_probe(struct platform_device *dev)
1386{ 1386{
1387 int error; 1387 int error;
1388 1388
1389 i8042_platform_device = dev;
1390
1389 error = i8042_controller_selftest(); 1391 error = i8042_controller_selftest();
1390 if (error) 1392 if (error)
1391 return error; 1393 return error;
@@ -1421,6 +1423,7 @@ static int __init i8042_probe(struct platform_device *dev)
1421 i8042_free_aux_ports(); /* in case KBD failed but AUX not */ 1423 i8042_free_aux_ports(); /* in case KBD failed but AUX not */
1422 i8042_free_irqs(); 1424 i8042_free_irqs();
1423 i8042_controller_reset(); 1425 i8042_controller_reset();
1426 i8042_platform_device = NULL;
1424 1427
1425 return error; 1428 return error;
1426} 1429}
@@ -1430,6 +1433,7 @@ static int __devexit i8042_remove(struct platform_device *dev)
1430 i8042_unregister_ports(); 1433 i8042_unregister_ports();
1431 i8042_free_irqs(); 1434 i8042_free_irqs();
1432 i8042_controller_reset(); 1435 i8042_controller_reset();
1436 i8042_platform_device = NULL;
1433 1437
1434 return 0; 1438 return 0;
1435} 1439}
@@ -1448,6 +1452,7 @@ static struct platform_driver i8042_driver = {
1448 1452
1449static int __init i8042_init(void) 1453static int __init i8042_init(void)
1450{ 1454{
1455 struct platform_device *pdev;
1451 int err; 1456 int err;
1452 1457
1453 dbg_init(); 1458 dbg_init();
@@ -1460,31 +1465,18 @@ static int __init i8042_init(void)
1460 if (err) 1465 if (err)
1461 goto err_platform_exit; 1466 goto err_platform_exit;
1462 1467
1463 i8042_platform_device = platform_device_alloc("i8042", -1); 1468 pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
1464 if (!i8042_platform_device) { 1469 if (IS_ERR(pdev)) {
1465 err = -ENOMEM; 1470 err = PTR_ERR(pdev);
1466 goto err_platform_exit; 1471 goto err_platform_exit;
1467 } 1472 }
1468 1473
1469 err = platform_device_add(i8042_platform_device);
1470 if (err)
1471 goto err_free_device;
1472
1473 err = platform_driver_probe(&i8042_driver, i8042_probe);
1474 if (err)
1475 goto err_del_device;
1476
1477 panic_blink = i8042_panic_blink; 1474 panic_blink = i8042_panic_blink;
1478 1475
1479 return 0; 1476 return 0;
1480 1477
1481 err_del_device:
1482 platform_device_del(i8042_platform_device);
1483 err_free_device:
1484 platform_device_put(i8042_platform_device);
1485 err_platform_exit: 1478 err_platform_exit:
1486 i8042_platform_exit(); 1479 i8042_platform_exit();
1487
1488 return err; 1480 return err;
1489} 1481}
1490 1482
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 27fdaaffbb40..998664854440 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -81,12 +81,12 @@ static int serio_raw_open(struct inode *inode, struct file *file)
81 struct serio_raw_list *list; 81 struct serio_raw_list *list;
82 int retval = 0; 82 int retval = 0;
83 83
84 lock_kernel();
85 retval = mutex_lock_interruptible(&serio_raw_mutex); 84 retval = mutex_lock_interruptible(&serio_raw_mutex);
86 if (retval) 85 if (retval)
87 goto out_bkl; 86 return retval;
88 87
89 if (!(serio_raw = serio_raw_locate(iminor(inode)))) { 88 serio_raw = serio_raw_locate(iminor(inode));
89 if (!serio_raw) {
90 retval = -ENODEV; 90 retval = -ENODEV;
91 goto out; 91 goto out;
92 } 92 }
@@ -96,7 +96,8 @@ static int serio_raw_open(struct inode *inode, struct file *file)
96 goto out; 96 goto out;
97 } 97 }
98 98
99 if (!(list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) { 99 list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL);
100 if (!list) {
100 retval = -ENOMEM; 101 retval = -ENOMEM;
101 goto out; 102 goto out;
102 } 103 }
@@ -109,8 +110,6 @@ static int serio_raw_open(struct inode *inode, struct file *file)
109 110
110out: 111out:
111 mutex_unlock(&serio_raw_mutex); 112 mutex_unlock(&serio_raw_mutex);
112out_bkl:
113 unlock_kernel();
114 return retval; 113 return retval;
115} 114}
116 115
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index fbd3987af57f..e6bde55e5203 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -64,7 +64,8 @@ struct key_entry *sparse_keymap_entry_from_keycode(struct input_dev *dev,
64EXPORT_SYMBOL(sparse_keymap_entry_from_keycode); 64EXPORT_SYMBOL(sparse_keymap_entry_from_keycode);
65 65
66static int sparse_keymap_getkeycode(struct input_dev *dev, 66static int sparse_keymap_getkeycode(struct input_dev *dev,
67 int scancode, int *keycode) 67 unsigned int scancode,
68 unsigned int *keycode)
68{ 69{
69 const struct key_entry *key = 70 const struct key_entry *key =
70 sparse_keymap_entry_from_scancode(dev, scancode); 71 sparse_keymap_entry_from_scancode(dev, scancode);
@@ -78,7 +79,8 @@ static int sparse_keymap_getkeycode(struct input_dev *dev,
78} 79}
79 80
80static int sparse_keymap_setkeycode(struct input_dev *dev, 81static int sparse_keymap_setkeycode(struct input_dev *dev,
81 int scancode, int keycode) 82 unsigned int scancode,
83 unsigned int keycode)
82{ 84{
83 struct key_entry *key; 85 struct key_entry *key;
84 int old_keycode; 86 int old_keycode;
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index a1770e6feeec..8b5d2873f0c4 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -371,7 +371,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
371 } else if (pen) { 371 } else if (pen) {
372 /* penabled only accepts exact bytes of data */ 372 /* penabled only accepts exact bytes of data */
373 if (features->type == TABLETPC2FG) 373 if (features->type == TABLETPC2FG)
374 features->pktlen = WACOM_PKGLEN_PENABLED; 374 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
375 features->device_type = BTN_TOOL_PEN; 375 features->device_type = BTN_TOOL_PEN;
376 features->x_max = 376 features->x_max =
377 wacom_le16_to_cpu(&report[i + 3]); 377 wacom_le16_to_cpu(&report[i + 3]);
@@ -410,7 +410,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
410 } else if (pen) { 410 } else if (pen) {
411 /* penabled only accepts exact bytes of data */ 411 /* penabled only accepts exact bytes of data */
412 if (features->type == TABLETPC2FG) 412 if (features->type == TABLETPC2FG)
413 features->pktlen = WACOM_PKGLEN_PENABLED; 413 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
414 features->device_type = BTN_TOOL_PEN; 414 features->device_type = BTN_TOOL_PEN;
415 features->y_max = 415 features->y_max =
416 wacom_le16_to_cpu(&report[i + 3]); 416 wacom_le16_to_cpu(&report[i + 3]);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 3d81443e683a..b3ba3437a2eb 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -155,19 +155,19 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
155{ 155{
156 struct wacom_features *features = &wacom->features; 156 struct wacom_features *features = &wacom->features;
157 unsigned char *data = wacom->data; 157 unsigned char *data = wacom->data;
158 int x, y, rw; 158 int x, y, prox;
159 static int penData = 0; 159 int rw = 0;
160 int retval = 0;
160 161
161 if (data[0] != WACOM_REPORT_PENABLED) { 162 if (data[0] != WACOM_REPORT_PENABLED) {
162 dbg("wacom_graphire_irq: received unknown report #%d", data[0]); 163 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
163 return 0; 164 goto exit;
164 } 165 }
165 166
166 if (data[1] & 0x80) { 167 prox = data[1] & 0x80;
167 /* in prox and not a pad data */ 168 if (prox || wacom->id[0]) {
168 penData = 1; 169 if (prox) {
169 170 switch ((data[1] >> 5) & 3) {
170 switch ((data[1] >> 5) & 3) {
171 171
172 case 0: /* Pen */ 172 case 0: /* Pen */
173 wacom->tool[0] = BTN_TOOL_PEN; 173 wacom->tool[0] = BTN_TOOL_PEN;
@@ -181,23 +181,13 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
181 181
182 case 2: /* Mouse with wheel */ 182 case 2: /* Mouse with wheel */
183 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); 183 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
184 if (features->type == WACOM_G4 || features->type == WACOM_MO) {
185 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
186 wacom_report_rel(wcombo, REL_WHEEL, -rw);
187 } else
188 wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
189 /* fall through */ 184 /* fall through */
190 185
191 case 3: /* Mouse without wheel */ 186 case 3: /* Mouse without wheel */
192 wacom->tool[0] = BTN_TOOL_MOUSE; 187 wacom->tool[0] = BTN_TOOL_MOUSE;
193 wacom->id[0] = CURSOR_DEVICE_ID; 188 wacom->id[0] = CURSOR_DEVICE_ID;
194 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
195 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
196 if (features->type == WACOM_G4 || features->type == WACOM_MO)
197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
198 else
199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
200 break; 189 break;
190 }
201 } 191 }
202 x = wacom_le16_to_cpu(&data[2]); 192 x = wacom_le16_to_cpu(&data[2]);
203 y = wacom_le16_to_cpu(&data[4]); 193 y = wacom_le16_to_cpu(&data[4]);
@@ -208,36 +198,32 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
208 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); 198 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
209 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 199 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
210 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04); 200 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
211 }
212 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
213 wacom_report_key(wcombo, wacom->tool[0], 1);
214 } else if (wacom->id[0]) {
215 wacom_report_abs(wcombo, ABS_X, 0);
216 wacom_report_abs(wcombo, ABS_Y, 0);
217 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
218 wacom_report_key(wcombo, BTN_LEFT, 0);
219 wacom_report_key(wcombo, BTN_RIGHT, 0);
220 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
221 } else { 201 } else {
222 wacom_report_abs(wcombo, ABS_PRESSURE, 0); 202 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
223 wacom_report_key(wcombo, BTN_TOUCH, 0); 203 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
224 wacom_report_key(wcombo, BTN_STYLUS, 0); 204 if (features->type == WACOM_G4 ||
225 wacom_report_key(wcombo, BTN_STYLUS2, 0); 205 features->type == WACOM_MO) {
206 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
207 rw = (signed)(data[7] & 0x04) - (data[7] & 0x03);
208 } else {
209 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
210 rw = -(signed)data[6];
211 }
212 wacom_report_rel(wcombo, REL_WHEEL, rw);
226 } 213 }
227 wacom->id[0] = 0; 214
228 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 215 if (!prox)
229 wacom_report_key(wcombo, wacom->tool[0], 0); 216 wacom->id[0] = 0;
217 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
218 wacom_report_key(wcombo, wacom->tool[0], prox);
219 wacom_input_sync(wcombo); /* sync last event */
230 } 220 }
231 221
232 /* send pad data */ 222 /* send pad data */
233 switch (features->type) { 223 switch (features->type) {
234 case WACOM_G4: 224 case WACOM_G4:
235 if (data[7] & 0xf8) { 225 prox = data[7] & 0xf8;
236 if (penData) { 226 if (prox || wacom->id[1]) {
237 wacom_input_sync(wcombo); /* sync last event */
238 if (!wacom->id[0])
239 penData = 0;
240 }
241 wacom->id[1] = PAD_DEVICE_ID; 227 wacom->id[1] = PAD_DEVICE_ID;
242 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40)); 228 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
243 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80)); 229 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
@@ -245,29 +231,16 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
245 wacom_report_rel(wcombo, REL_WHEEL, rw); 231 wacom_report_rel(wcombo, REL_WHEEL, rw);
246 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 232 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
247 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 233 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
248 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 234 if (!prox)
249 } else if (wacom->id[1]) { 235 wacom->id[1] = 0;
250 if (penData) { 236 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
251 wacom_input_sync(wcombo); /* sync last event */
252 if (!wacom->id[0])
253 penData = 0;
254 }
255 wacom->id[1] = 0;
256 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
257 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
258 wacom_report_rel(wcombo, REL_WHEEL, 0);
259 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
260 wacom_report_abs(wcombo, ABS_MISC, 0);
261 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 237 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
262 } 238 }
239 retval = 1;
263 break; 240 break;
264 case WACOM_MO: 241 case WACOM_MO:
265 if ((data[7] & 0xf8) || (data[8] & 0xff)) { 242 prox = (data[7] & 0xf8) || data[8];
266 if (penData) { 243 if (prox || wacom->id[1]) {
267 wacom_input_sync(wcombo); /* sync last event */
268 if (!wacom->id[0])
269 penData = 0;
270 }
271 wacom->id[1] = PAD_DEVICE_ID; 244 wacom->id[1] = PAD_DEVICE_ID;
272 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08)); 245 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
273 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20)); 246 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
@@ -275,27 +248,16 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
275 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40)); 248 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
276 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f)); 249 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
277 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 250 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
251 if (!prox)
252 wacom->id[1] = 0;
278 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 253 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
279 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 254 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
280 } else if (wacom->id[1]) {
281 if (penData) {
282 wacom_input_sync(wcombo); /* sync last event */
283 if (!wacom->id[0])
284 penData = 0;
285 }
286 wacom->id[1] = 0;
287 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
288 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
289 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
290 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
291 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
292 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
293 wacom_report_abs(wcombo, ABS_MISC, 0);
294 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
295 } 255 }
256 retval = 1;
296 break; 257 break;
297 } 258 }
298 return 1; 259exit:
260 return retval;
299} 261}
300 262
301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo) 263static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
@@ -636,9 +598,9 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
636static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx) 598static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx)
637{ 599{
638 wacom_report_abs(wcombo, ABS_X, 600 wacom_report_abs(wcombo, ABS_X,
639 (data[2 + idx * 2] & 0xff) | ((data[3 + idx * 2] & 0x7f) << 8)); 601 data[2 + idx * 2] | ((data[3 + idx * 2] & 0x7f) << 8));
640 wacom_report_abs(wcombo, ABS_Y, 602 wacom_report_abs(wcombo, ABS_Y,
641 (data[6 + idx * 2] & 0xff) | ((data[7 + idx * 2] & 0x7f) << 8)); 603 data[6 + idx * 2] | ((data[7 + idx * 2] & 0x7f) << 8));
642 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); 604 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
643 wacom_report_key(wcombo, wacom->tool[idx], 1); 605 wacom_report_key(wcombo, wacom->tool[idx], 1);
644 if (idx) 606 if (idx)
@@ -782,31 +744,24 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
782 744
783 touchInProx = 0; 745 touchInProx = 0;
784 746
785 if (prox) { /* in prox */ 747 if (!wacom->id[0]) { /* first in prox */
786 if (!wacom->id[0]) { 748 /* Going into proximity select tool */
787 /* Going into proximity select tool */ 749 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
788 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 750 if (wacom->tool[0] == BTN_TOOL_PEN)
789 if (wacom->tool[0] == BTN_TOOL_PEN) 751 wacom->id[0] = STYLUS_DEVICE_ID;
790 wacom->id[0] = STYLUS_DEVICE_ID; 752 else
791 else 753 wacom->id[0] = ERASER_DEVICE_ID;
792 wacom->id[0] = ERASER_DEVICE_ID; 754 }
793 } 755 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
794 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 756 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
795 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); 757 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
796 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); 758 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
797 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 759 pressure = ((data[7] & 0x01) << 8) | data[6];
798 pressure = ((data[7] & 0x01) << 8) | data[6]; 760 if (pressure < 0)
799 if (pressure < 0) 761 pressure = features->pressure_max + pressure + 1;
800 pressure = features->pressure_max + pressure + 1; 762 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
801 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 763 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
802 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); 764 if (!prox) { /* out-prox */
803 } else {
804 wacom_report_abs(wcombo, ABS_X, 0);
805 wacom_report_abs(wcombo, ABS_Y, 0);
806 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
807 wacom_report_key(wcombo, BTN_STYLUS, 0);
808 wacom_report_key(wcombo, BTN_STYLUS2, 0);
809 wacom_report_key(wcombo, BTN_TOUCH, 0);
810 wacom->id[0] = 0; 765 wacom->id[0] = 0;
811 /* pen is out so touch can be enabled now */ 766 /* pen is out so touch can be enabled now */
812 touchInProx = 1; 767 touchInProx = 1;
@@ -1028,7 +983,7 @@ static const struct wacom_features wacom_features_0x93 =
1028static const struct wacom_features wacom_features_0x9A = 983static const struct wacom_features wacom_features_0x9A =
1029 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 984 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1030static const struct wacom_features wacom_features_0x9F = 985static const struct wacom_features wacom_features_0x9F =
1031 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC }; 986 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
1032static const struct wacom_features wacom_features_0xE2 = 987static const struct wacom_features wacom_features_0xE2 =
1033 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; 988 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
1034static const struct wacom_features wacom_features_0xE3 = 989static const struct wacom_features wacom_features_0xE3 =
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 8590b1e8ec37..b50cf04e61a8 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -17,7 +17,6 @@
17#define WACOM_PKGLEN_GRAPHIRE 8 17#define WACOM_PKGLEN_GRAPHIRE 8
18#define WACOM_PKGLEN_BBFUN 9 18#define WACOM_PKGLEN_BBFUN 9
19#define WACOM_PKGLEN_INTUOS 10 19#define WACOM_PKGLEN_INTUOS 10
20#define WACOM_PKGLEN_PENABLED 8
21#define WACOM_PKGLEN_TPC1FG 5 20#define WACOM_PKGLEN_TPC1FG 5
22#define WACOM_PKGLEN_TPC2FG 14 21#define WACOM_PKGLEN_TPC2FG 14
23 22
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 7208654a94ae..8a8fa4d2d6a8 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -24,17 +24,18 @@ config TOUCHSCREEN_88PM860X
24 module will be called 88pm860x-ts. 24 module will be called 88pm860x-ts.
25 25
26config TOUCHSCREEN_ADS7846 26config TOUCHSCREEN_ADS7846
27 tristate "ADS7846/TSC2046 and ADS7843 based touchscreens" 27 tristate "ADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreens"
28 depends on SPI_MASTER 28 depends on SPI_MASTER
29 depends on HWMON = n || HWMON 29 depends on HWMON = n || HWMON
30 help 30 help
31 Say Y here if you have a touchscreen interface using the 31 Say Y here if you have a touchscreen interface using the
32 ADS7846/TSC2046 or ADS7843 controller, and your board-specific 32 ADS7846/TSC2046/AD7873 or ADS7843/AD7843 controller,
33 setup code includes that in its table of SPI devices. 33 and your board-specific setup code includes that in its
34 table of SPI devices.
34 35
35 If HWMON is selected, and the driver is told the reference voltage 36 If HWMON is selected, and the driver is told the reference voltage
36 on your board, you will also get hwmon interfaces for the voltage 37 on your board, you will also get hwmon interfaces for the voltage
37 (and on ads7846/tsc2046, temperature) sensors of this chip. 38 (and on ads7846/tsc2046/ad7873, temperature) sensors of this chip.
38 39
39 If unsure, say N (but it's safe to say "Y"). 40 If unsure, say N (but it's safe to say "Y").
40 41
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index eb83939c705e..e019d53d1ab4 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -46,7 +46,7 @@
46#include <linux/spi/ad7877.h> 46#include <linux/spi/ad7877.h>
47#include <asm/irq.h> 47#include <asm/irq.h>
48 48
49#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50) 49#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(100)
50 50
51#define MAX_SPI_FREQ_HZ 20000000 51#define MAX_SPI_FREQ_HZ 20000000
52#define MAX_12BIT ((1<<12)-1) 52#define MAX_12BIT ((1<<12)-1)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 8b05d8e97543..532279cda0e4 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -36,6 +36,7 @@
36 * TSC2046 is just newer ads7846 silicon. 36 * TSC2046 is just newer ads7846 silicon.
37 * Support for ads7843 tested on Atmel at91sam926x-EK. 37 * Support for ads7843 tested on Atmel at91sam926x-EK.
38 * Support for ads7845 has only been stubbed in. 38 * Support for ads7845 has only been stubbed in.
39 * Support for Analog Devices AD7873 and AD7843 tested.
39 * 40 *
40 * IRQ handling needs a workaround because of a shortcoming in handling 41 * IRQ handling needs a workaround because of a shortcoming in handling
41 * edge triggered IRQs on some platforms like the OMAP1/2. These 42 * edge triggered IRQs on some platforms like the OMAP1/2. These
@@ -821,6 +822,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
821 822
822 spin_unlock_irq(&ts->lock); 823 spin_unlock_irq(&ts->lock);
823 824
825 if (device_may_wakeup(&ts->spi->dev))
826 enable_irq_wake(ts->spi->irq);
827
824 return 0; 828 return 0;
825 829
826} 830}
@@ -829,6 +833,9 @@ static int ads7846_resume(struct spi_device *spi)
829{ 833{
830 struct ads7846 *ts = dev_get_drvdata(&spi->dev); 834 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
831 835
836 if (device_may_wakeup(&ts->spi->dev))
837 disable_irq_wake(ts->spi->irq);
838
832 spin_lock_irq(&ts->lock); 839 spin_lock_irq(&ts->lock);
833 840
834 ts->is_suspended = 0; 841 ts->is_suspended = 0;
@@ -984,6 +991,15 @@ static int __devinit ads7846_probe(struct spi_device *spi)
984 991
985 vref = pdata->keep_vref_on; 992 vref = pdata->keep_vref_on;
986 993
994 if (ts->model == 7873) {
995 /* The AD7873 is almost identical to the ADS7846
996 * keep VREF off during differential/ratiometric
997 * conversion modes
998 */
999 ts->model = 7846;
1000 vref = 0;
1001 }
1002
987 /* set up the transfers to read touchscreen state; this assumes we 1003 /* set up the transfers to read touchscreen state; this assumes we
988 * use formula #2 for pressure, not #3. 1004 * use formula #2 for pressure, not #3.
989 */ 1005 */
@@ -1191,6 +1207,8 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1191 if (err) 1207 if (err)
1192 goto err_remove_attr_group; 1208 goto err_remove_attr_group;
1193 1209
1210 device_init_wakeup(&spi->dev, pdata->wakeup);
1211
1194 return 0; 1212 return 0;
1195 1213
1196 err_remove_attr_group: 1214 err_remove_attr_group:
@@ -1220,6 +1238,8 @@ static int __devexit ads7846_remove(struct spi_device *spi)
1220{ 1238{
1221 struct ads7846 *ts = dev_get_drvdata(&spi->dev); 1239 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
1222 1240
1241 device_init_wakeup(&spi->dev, false);
1242
1223 ads784x_hwmon_unregister(spi, ts); 1243 ads784x_hwmon_unregister(spi, ts);
1224 input_unregister_device(ts->input); 1244 input_unregister_device(ts->input);
1225 1245
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index 0903f539bf68..0a3b4ed38e48 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -123,7 +123,7 @@ static int ir_copy_table(struct ir_scancode_table *destin,
123 * If the key is not found, returns -EINVAL, otherwise, returns 0. 123 * If the key is not found, returns -EINVAL, otherwise, returns 0.
124 */ 124 */
125static int ir_getkeycode(struct input_dev *dev, 125static int ir_getkeycode(struct input_dev *dev,
126 int scancode, int *keycode) 126 unsigned int scancode, unsigned int *keycode)
127{ 127{
128 int elem; 128 int elem;
129 struct ir_input_dev *ir_dev = input_get_drvdata(dev); 129 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
@@ -291,7 +291,7 @@ static int ir_insert_key(struct ir_scancode_table *rc_tab,
291 * If the key is not found, returns -EINVAL, otherwise, returns 0. 291 * If the key is not found, returns -EINVAL, otherwise, returns 0.
292 */ 292 */
293static int ir_setkeycode(struct input_dev *dev, 293static int ir_setkeycode(struct input_dev *dev,
294 int scancode, int keycode) 294 unsigned int scancode, unsigned int keycode)
295{ 295{
296 int rc = 0; 296 int rc = 0;
297 struct ir_input_dev *ir_dev = input_get_drvdata(dev); 297 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index a03ef7efec9a..852fe89539cf 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -9,7 +9,7 @@
9#include <linux/usb/input.h> 9#include <linux/usb/input.h>
10 10
11static int dvb_usb_getkeycode(struct input_dev *dev, 11static int dvb_usb_getkeycode(struct input_dev *dev,
12 int scancode, int *keycode) 12 unsigned int scancode, unsigned int *keycode)
13{ 13{
14 struct dvb_usb_device *d = input_get_drvdata(dev); 14 struct dvb_usb_device *d = input_get_drvdata(dev);
15 15
@@ -39,7 +39,7 @@ static int dvb_usb_getkeycode(struct input_dev *dev,
39} 39}
40 40
41static int dvb_usb_setkeycode(struct input_dev *dev, 41static int dvb_usb_setkeycode(struct input_dev *dev,
42 int scancode, int keycode) 42 unsigned int scancode, unsigned int keycode)
43{ 43{
44 struct dvb_usb_device *d = input_get_drvdata(dev); 44 struct dvb_usb_device *d = input_get_drvdata(dev);
45 45
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index 1b1dddbd5744..bed764e3ea2a 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -142,7 +142,7 @@ static struct key_entry *dell_wmi_keymap = dell_legacy_wmi_keymap;
142 142
143static struct input_dev *dell_wmi_input_dev; 143static struct input_dev *dell_wmi_input_dev;
144 144
145static struct key_entry *dell_wmi_get_entry_by_scancode(int code) 145static struct key_entry *dell_wmi_get_entry_by_scancode(unsigned int code)
146{ 146{
147 struct key_entry *key; 147 struct key_entry *key;
148 148
@@ -153,7 +153,7 @@ static struct key_entry *dell_wmi_get_entry_by_scancode(int code)
153 return NULL; 153 return NULL;
154} 154}
155 155
156static struct key_entry *dell_wmi_get_entry_by_keycode(int keycode) 156static struct key_entry *dell_wmi_get_entry_by_keycode(unsigned int keycode)
157{ 157{
158 struct key_entry *key; 158 struct key_entry *key;
159 159
@@ -164,8 +164,8 @@ static struct key_entry *dell_wmi_get_entry_by_keycode(int keycode)
164 return NULL; 164 return NULL;
165} 165}
166 166
167static int dell_wmi_getkeycode(struct input_dev *dev, int scancode, 167static int dell_wmi_getkeycode(struct input_dev *dev,
168 int *keycode) 168 unsigned int scancode, unsigned int *keycode)
169{ 169{
170 struct key_entry *key = dell_wmi_get_entry_by_scancode(scancode); 170 struct key_entry *key = dell_wmi_get_entry_by_scancode(scancode);
171 171
@@ -177,13 +177,11 @@ static int dell_wmi_getkeycode(struct input_dev *dev, int scancode,
177 return -EINVAL; 177 return -EINVAL;
178} 178}
179 179
180static int dell_wmi_setkeycode(struct input_dev *dev, int scancode, int keycode) 180static int dell_wmi_setkeycode(struct input_dev *dev,
181 unsigned int scancode, unsigned int keycode)
181{ 182{
182 struct key_entry *key; 183 struct key_entry *key;
183 int old_keycode; 184 unsigned int old_keycode;
184
185 if (keycode < 0 || keycode > KEY_MAX)
186 return -EINVAL;
187 185
188 key = dell_wmi_get_entry_by_scancode(scancode); 186 key = dell_wmi_get_entry_by_scancode(scancode);
189 if (key && key->type == KE_KEY) { 187 if (key && key->type == KE_KEY) {
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 7ccf33c08967..56086363becc 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -278,7 +278,7 @@ static DEVICE_ATTR(als, S_IRUGO | S_IWUSR, show_als, set_als);
278static DEVICE_ATTR(dock, S_IRUGO, show_dock, NULL); 278static DEVICE_ATTR(dock, S_IRUGO, show_dock, NULL);
279static DEVICE_ATTR(tablet, S_IRUGO, show_tablet, NULL); 279static DEVICE_ATTR(tablet, S_IRUGO, show_tablet, NULL);
280 280
281static struct key_entry *hp_wmi_get_entry_by_scancode(int code) 281static struct key_entry *hp_wmi_get_entry_by_scancode(unsigned int code)
282{ 282{
283 struct key_entry *key; 283 struct key_entry *key;
284 284
@@ -289,7 +289,7 @@ static struct key_entry *hp_wmi_get_entry_by_scancode(int code)
289 return NULL; 289 return NULL;
290} 290}
291 291
292static struct key_entry *hp_wmi_get_entry_by_keycode(int keycode) 292static struct key_entry *hp_wmi_get_entry_by_keycode(unsigned int keycode)
293{ 293{
294 struct key_entry *key; 294 struct key_entry *key;
295 295
@@ -300,7 +300,8 @@ static struct key_entry *hp_wmi_get_entry_by_keycode(int keycode)
300 return NULL; 300 return NULL;
301} 301}
302 302
303static int hp_wmi_getkeycode(struct input_dev *dev, int scancode, int *keycode) 303static int hp_wmi_getkeycode(struct input_dev *dev,
304 unsigned int scancode, unsigned int *keycode)
304{ 305{
305 struct key_entry *key = hp_wmi_get_entry_by_scancode(scancode); 306 struct key_entry *key = hp_wmi_get_entry_by_scancode(scancode);
306 307
@@ -312,13 +313,11 @@ static int hp_wmi_getkeycode(struct input_dev *dev, int scancode, int *keycode)
312 return -EINVAL; 313 return -EINVAL;
313} 314}
314 315
315static int hp_wmi_setkeycode(struct input_dev *dev, int scancode, int keycode) 316static int hp_wmi_setkeycode(struct input_dev *dev,
317 unsigned int scancode, unsigned int keycode)
316{ 318{
317 struct key_entry *key; 319 struct key_entry *key;
318 int old_keycode; 320 unsigned int old_keycode;
319
320 if (keycode < 0 || keycode > KEY_MAX)
321 return -EINVAL;
322 321
323 key = hp_wmi_get_entry_by_scancode(scancode); 322 key = hp_wmi_get_entry_by_scancode(scancode);
324 if (key && key->type == KE_KEY) { 323 if (key && key->type == KE_KEY) {
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index fe7cf0188acc..c9fc479fc290 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -200,7 +200,7 @@ static struct acpi_driver acpi_pcc_driver = {
200}; 200};
201 201
202#define KEYMAP_SIZE 11 202#define KEYMAP_SIZE 11
203static const int initial_keymap[KEYMAP_SIZE] = { 203static const unsigned int initial_keymap[KEYMAP_SIZE] = {
204 /* 0 */ KEY_RESERVED, 204 /* 0 */ KEY_RESERVED,
205 /* 1 */ KEY_BRIGHTNESSDOWN, 205 /* 1 */ KEY_BRIGHTNESSDOWN,
206 /* 2 */ KEY_BRIGHTNESSUP, 206 /* 2 */ KEY_BRIGHTNESSUP,
@@ -222,7 +222,7 @@ struct pcc_acpi {
222 struct acpi_device *device; 222 struct acpi_device *device;
223 struct input_dev *input_dev; 223 struct input_dev *input_dev;
224 struct backlight_device *backlight; 224 struct backlight_device *backlight;
225 int keymap[KEYMAP_SIZE]; 225 unsigned int keymap[KEYMAP_SIZE];
226}; 226};
227 227
228struct pcc_keyinput { 228struct pcc_keyinput {
@@ -445,7 +445,8 @@ static struct attribute_group pcc_attr_group = {
445 445
446/* hotkey input device driver */ 446/* hotkey input device driver */
447 447
448static int pcc_getkeycode(struct input_dev *dev, int scancode, int *keycode) 448static int pcc_getkeycode(struct input_dev *dev,
449 unsigned int scancode, unsigned int *keycode)
449{ 450{
450 struct pcc_acpi *pcc = input_get_drvdata(dev); 451 struct pcc_acpi *pcc = input_get_drvdata(dev);
451 452
@@ -457,7 +458,7 @@ static int pcc_getkeycode(struct input_dev *dev, int scancode, int *keycode)
457 return 0; 458 return 0;
458} 459}
459 460
460static int keymap_get_by_keycode(struct pcc_acpi *pcc, int keycode) 461static int keymap_get_by_keycode(struct pcc_acpi *pcc, unsigned int keycode)
461{ 462{
462 int i; 463 int i;
463 464
@@ -469,7 +470,8 @@ static int keymap_get_by_keycode(struct pcc_acpi *pcc, int keycode)
469 return 0; 470 return 0;
470} 471}
471 472
472static int pcc_setkeycode(struct input_dev *dev, int scancode, int keycode) 473static int pcc_setkeycode(struct input_dev *dev,
474 unsigned int scancode, unsigned int keycode)
473{ 475{
474 struct pcc_acpi *pcc = input_get_drvdata(dev); 476 struct pcc_acpi *pcc = input_get_drvdata(dev);
475 int oldkeycode; 477 int oldkeycode;
@@ -477,9 +479,6 @@ static int pcc_setkeycode(struct input_dev *dev, int scancode, int keycode)
477 if (scancode >= ARRAY_SIZE(pcc->keymap)) 479 if (scancode >= ARRAY_SIZE(pcc->keymap))
478 return -EINVAL; 480 return -EINVAL;
479 481
480 if (keycode < 0 || keycode > KEY_MAX)
481 return -EINVAL;
482
483 oldkeycode = pcc->keymap[scancode]; 482 oldkeycode = pcc->keymap[scancode];
484 pcc->keymap[scancode] = keycode; 483 pcc->keymap[scancode] = keycode;
485 484
diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 02f3d4e9e666..4d6516fded7e 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -46,7 +46,7 @@ static struct tps_key_entry topstar_keymap[] = {
46 { } 46 { }
47}; 47};
48 48
49static struct tps_key_entry *tps_get_key_by_scancode(int code) 49static struct tps_key_entry *tps_get_key_by_scancode(unsigned int code)
50{ 50{
51 struct tps_key_entry *key; 51 struct tps_key_entry *key;
52 52
@@ -57,7 +57,7 @@ static struct tps_key_entry *tps_get_key_by_scancode(int code)
57 return NULL; 57 return NULL;
58} 58}
59 59
60static struct tps_key_entry *tps_get_key_by_keycode(int code) 60static struct tps_key_entry *tps_get_key_by_keycode(unsigned int code)
61{ 61{
62 struct tps_key_entry *key; 62 struct tps_key_entry *key;
63 63
@@ -126,7 +126,8 @@ static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state)
126 return 0; 126 return 0;
127} 127}
128 128
129static int topstar_getkeycode(struct input_dev *dev, int scancode, int *keycode) 129static int topstar_getkeycode(struct input_dev *dev,
130 unsigned int scancode, unsigned int *keycode)
130{ 131{
131 struct tps_key_entry *key = tps_get_key_by_scancode(scancode); 132 struct tps_key_entry *key = tps_get_key_by_scancode(scancode);
132 133
@@ -137,14 +138,12 @@ static int topstar_getkeycode(struct input_dev *dev, int scancode, int *keycode)
137 return 0; 138 return 0;
138} 139}
139 140
140static int topstar_setkeycode(struct input_dev *dev, int scancode, int keycode) 141static int topstar_setkeycode(struct input_dev *dev,
142 unsigned int scancode, unsigned int keycode)
141{ 143{
142 struct tps_key_entry *key; 144 struct tps_key_entry *key;
143 int old_keycode; 145 int old_keycode;
144 146
145 if (keycode < 0 || keycode > KEY_MAX)
146 return -EINVAL;
147
148 key = tps_get_key_by_scancode(scancode); 147 key = tps_get_key_by_scancode(scancode);
149 148
150 if (!key) 149 if (!key)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 405b969734d6..789240d1b577 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -745,7 +745,7 @@ static struct backlight_ops toshiba_backlight_data = {
745 .update_status = set_lcd_status, 745 .update_status = set_lcd_status,
746}; 746};
747 747
748static struct key_entry *toshiba_acpi_get_entry_by_scancode(int code) 748static struct key_entry *toshiba_acpi_get_entry_by_scancode(unsigned int code)
749{ 749{
750 struct key_entry *key; 750 struct key_entry *key;
751 751
@@ -756,7 +756,7 @@ static struct key_entry *toshiba_acpi_get_entry_by_scancode(int code)
756 return NULL; 756 return NULL;
757} 757}
758 758
759static struct key_entry *toshiba_acpi_get_entry_by_keycode(int code) 759static struct key_entry *toshiba_acpi_get_entry_by_keycode(unsigned int code)
760{ 760{
761 struct key_entry *key; 761 struct key_entry *key;
762 762
@@ -767,8 +767,8 @@ static struct key_entry *toshiba_acpi_get_entry_by_keycode(int code)
767 return NULL; 767 return NULL;
768} 768}
769 769
770static int toshiba_acpi_getkeycode(struct input_dev *dev, int scancode, 770static int toshiba_acpi_getkeycode(struct input_dev *dev,
771 int *keycode) 771 unsigned int scancode, unsigned int *keycode)
772{ 772{
773 struct key_entry *key = toshiba_acpi_get_entry_by_scancode(scancode); 773 struct key_entry *key = toshiba_acpi_get_entry_by_scancode(scancode);
774 774
@@ -780,14 +780,11 @@ static int toshiba_acpi_getkeycode(struct input_dev *dev, int scancode,
780 return -EINVAL; 780 return -EINVAL;
781} 781}
782 782
783static int toshiba_acpi_setkeycode(struct input_dev *dev, int scancode, 783static int toshiba_acpi_setkeycode(struct input_dev *dev,
784 int keycode) 784 unsigned int scancode, unsigned int keycode)
785{ 785{
786 struct key_entry *key; 786 struct key_entry *key;
787 int old_keycode; 787 unsigned int old_keycode;
788
789 if (keycode < 0 || keycode > KEY_MAX)
790 return -EINVAL;
791 788
792 key = toshiba_acpi_get_entry_by_scancode(scancode); 789 key = toshiba_acpi_get_entry_by_scancode(scancode);
793 if (key && key->type == KE_KEY) { 790 if (key && key->type == KE_KEY) {