aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-24 20:17:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-24 20:17:30 -0500
commit1b59bab55e36082b1db3dc81bb32475616487a98 (patch)
tree0cf4af345f159b7056465053c28b5d5089566650
parentb788769e0641daf90a8d7e800081285f8ca80bd9 (diff)
parent55df811f2066fcaec2548248f0a1a6a0c12dc6b8 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input subsystem updates from Dmitry Torokhov: "Just a swath of driver fixes and cleanups, no new drivers this time (although ALPS now supports one of the newer protocols, more to come)" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (57 commits) Input: wacom - add support for DTU-1031 Input: wacom - fix wacom->shared guards for dual input devices Input: edt_ft5x06 - use devm_* functions where appropriate Input: hyperv-keyboard - pass through 0xE1 prefix Input: logips2pp - fix spelling s/reciver/receiver/ Input: delete non-required instances of include <linux/init.h> Input: twl4030-keypad - convert to using managed resources Input: twl6040-vibra - remove unneeded check for CONFIG_OF Input: twl4030-keypad - add device tree support Input: twl6040-vibra - add missing of_node_put Input: twl4030-vibra - add missing of_node_put Input: i8042 - cleanup SERIO_I8042 dependencies Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on x86 Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on unicore32 Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on sparc Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO for SH_CAYMAN Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on powerpc Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on mips Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on IA64 Input: i8042 - select ARCH_MIGHT_HAVE_PC_SERIO on ARM/Footbridge ...
-rw-r--r--Documentation/devicetree/bindings/input/gpio-beeper.txt13
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt41
-rw-r--r--Documentation/devicetree/bindings/input/twl4030-keypad.txt27
-rw-r--r--Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt21
-rw-r--r--Documentation/input/gamepad.txt6
-rw-r--r--Documentation/input/joystick-api.txt38
-rw-r--r--Documentation/input/joystick.txt8
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/arm/mach-footbridge/Kconfig1
-rw-r--r--arch/arm/mach-imx/mach-cpuimx35.c2
-rw-r--r--arch/arm/mach-imx/mach-cpuimx51sd.c2
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/sh/boards/Kconfig1
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c2
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/unicore32/Kconfig1
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--drivers/input/gameport/emu10k1-gp.c1
-rw-r--r--drivers/input/gameport/fm801-gp.c1
-rw-r--r--drivers/input/input.c76
-rw-r--r--drivers/input/joystick/a3d.c1
-rw-r--r--drivers/input/joystick/adi.c1
-rw-r--r--drivers/input/joystick/cobra.c1
-rw-r--r--drivers/input/joystick/gf2k.c1
-rw-r--r--drivers/input/joystick/grip.c1
-rw-r--r--drivers/input/joystick/grip_mp.c1
-rw-r--r--drivers/input/joystick/guillemot.c1
-rw-r--r--drivers/input/joystick/iforce/iforce.h1
-rw-r--r--drivers/input/joystick/interact.c1
-rw-r--r--drivers/input/joystick/joydump.c1
-rw-r--r--drivers/input/joystick/magellan.c1
-rw-r--r--drivers/input/joystick/sidewinder.c1
-rw-r--r--drivers/input/joystick/spaceball.c1
-rw-r--r--drivers/input/joystick/spaceorb.c1
-rw-r--r--drivers/input/joystick/stinger.c1
-rw-r--r--drivers/input/joystick/tmdc.c1
-rw-r--r--drivers/input/joystick/twidjoy.c1
-rw-r--r--drivers/input/joystick/warrior.c1
-rw-r--r--drivers/input/joystick/xpad.c7
-rw-r--r--drivers/input/joystick/zhenhua.c1
-rw-r--r--drivers/input/keyboard/Kconfig2
-rw-r--r--drivers/input/keyboard/adp5520-keys.c3
-rw-r--r--drivers/input/keyboard/adp5588-keys.c11
-rw-r--r--drivers/input/keyboard/adp5589-keys.c9
-rw-r--r--drivers/input/keyboard/bf54x-keys.c5
-rw-r--r--drivers/input/keyboard/cros_ec_keyb.c15
-rw-r--r--drivers/input/keyboard/davinci_keyscan.c2
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c2
-rw-r--r--drivers/input/keyboard/goldfish_events.c1
-rw-r--r--drivers/input/keyboard/gpio_keys_polled.c1
-rw-r--r--drivers/input/keyboard/hil_kbd.c1
-rw-r--r--drivers/input/keyboard/imx_keypad.c4
-rw-r--r--drivers/input/keyboard/jornada680_kbd.c1
-rw-r--r--drivers/input/keyboard/jornada720_kbd.c1
-rw-r--r--drivers/input/keyboard/lkkbd.c1
-rw-r--r--drivers/input/keyboard/lm8323.c2
-rw-r--r--drivers/input/keyboard/lm8333.c3
-rw-r--r--drivers/input/keyboard/matrix_keypad.c1
-rw-r--r--drivers/input/keyboard/max7359_keypad.c3
-rw-r--r--drivers/input/keyboard/mcs_touchkey.c3
-rw-r--r--drivers/input/keyboard/mpr121_touchkey.c4
-rw-r--r--drivers/input/keyboard/newtonkbd.c1
-rw-r--r--drivers/input/keyboard/nomadik-ske-keypad.c3
-rw-r--r--drivers/input/keyboard/omap-keypad.c3
-rw-r--r--drivers/input/keyboard/omap4-keypad.c1
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c1
-rw-r--r--drivers/input/keyboard/pxa930_rotary.c4
-rw-r--r--drivers/input/keyboard/qt1070.c1
-rw-r--r--drivers/input/keyboard/qt2160.c1
-rw-r--r--drivers/input/keyboard/samsung-keypad.c37
-rw-r--r--drivers/input/keyboard/sh_keysc.c5
-rw-r--r--drivers/input/keyboard/spear-keyboard.c1
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c1
-rw-r--r--drivers/input/keyboard/stowaway.c1
-rw-r--r--drivers/input/keyboard/sunkbd.c1
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c1
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c2
-rw-r--r--drivers/input/keyboard/tnetv107x-keypad.c2
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c122
-rw-r--r--drivers/input/keyboard/w90p910_keypad.c3
-rw-r--r--drivers/input/keyboard/xtkbd.c1
-rw-r--r--drivers/input/misc/Kconfig9
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ad714x.c5
-rw-r--r--drivers/input/misc/adxl34x.c3
-rw-r--r--drivers/input/misc/atlas_btns.c1
-rw-r--r--drivers/input/misc/bfin_rotary.c3
-rw-r--r--drivers/input/misc/bma150.c3
-rw-r--r--drivers/input/misc/cma3000_d0x.c2
-rw-r--r--drivers/input/misc/cobalt_btns.c1
-rw-r--r--drivers/input/misc/da9052_onkey.c1
-rw-r--r--drivers/input/misc/da9055_onkey.c1
-rw-r--r--drivers/input/misc/dm355evm_keys.c1
-rw-r--r--drivers/input/misc/gp2ap002a00f.c2
-rw-r--r--drivers/input/misc/gpio-beeper.c127
-rw-r--r--drivers/input/misc/gpio_tilt_polled.c4
-rw-r--r--drivers/input/misc/keyspan_remote.c1
-rw-r--r--drivers/input/misc/kxtj9.c3
-rw-r--r--drivers/input/misc/max8997_haptic.c1
-rw-r--r--drivers/input/misc/mc13783-pwrbutton.c1
-rw-r--r--drivers/input/misc/mpu3050.c1
-rw-r--r--drivers/input/misc/pcap_keys.c1
-rw-r--r--drivers/input/misc/pcf50633-input.c1
-rw-r--r--drivers/input/misc/pcf8574_keypad.c1
-rw-r--r--drivers/input/misc/pcspkr.c1
-rw-r--r--drivers/input/misc/pm8xxx-vibrator.c107
-rw-r--r--drivers/input/misc/pmic8xxx-pwrkey.c106
-rw-r--r--drivers/input/misc/powermate.c1
-rw-r--r--drivers/input/misc/pwm-beeper.c2
-rw-r--r--drivers/input/misc/retu-pwrbutton.c1
-rw-r--r--drivers/input/misc/rotary_encoder.c1
-rw-r--r--drivers/input/misc/sgi_btns.c1
-rw-r--r--drivers/input/misc/sirfsoc-onkey.c1
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c46
-rw-r--r--drivers/input/misc/twl4030-vibra.c6
-rw-r--r--drivers/input/misc/twl6040-vibra.c8
-rw-r--r--drivers/input/misc/wm831x-on.c1
-rw-r--r--drivers/input/misc/yealink.c1
-rw-r--r--drivers/input/mouse/alps.c214
-rw-r--r--drivers/input/mouse/alps.h7
-rw-r--r--drivers/input/mouse/appletouch.c1
-rw-r--r--drivers/input/mouse/bcm5974.c1
-rw-r--r--drivers/input/mouse/cypress_ps2.c1
-rw-r--r--drivers/input/mouse/elantech.c45
-rw-r--r--drivers/input/mouse/gpio_mouse.c3
-rw-r--r--drivers/input/mouse/logips2pp.c2
-rw-r--r--drivers/input/mouse/navpoint.c1
-rw-r--r--drivers/input/mouse/pxa930_trkball.c3
-rw-r--r--drivers/input/mouse/sermouse.c1
-rw-r--r--drivers/input/mouse/synaptics_usb.c1
-rw-r--r--drivers/input/mouse/vsxxxaa.c1
-rw-r--r--drivers/input/serio/Kconfig11
-rw-r--r--drivers/input/serio/altera_ps2.c1
-rw-r--r--drivers/input/serio/ambakmi.c1
-rw-r--r--drivers/input/serio/hyperv-keyboard.c4
-rw-r--r--drivers/input/serio/libps2.c1
-rw-r--r--drivers/input/serio/olpc_apsp.c1
-rw-r--r--drivers/input/serio/pcips2.c2
-rw-r--r--drivers/input/serio/q40kbd.c1
-rw-r--r--drivers/input/serio/rpckbd.c1
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/input/serio/xilinx_ps2.c1
-rw-r--r--drivers/input/tablet/acecad.c1
-rw-r--r--drivers/input/tablet/aiptek.c1
-rw-r--r--drivers/input/tablet/gtco.c1
-rw-r--r--drivers/input/tablet/hanwang.c1
-rw-r--r--drivers/input/tablet/kbtab.c1
-rw-r--r--drivers/input/tablet/wacom.h1
-rw-r--r--drivers/input/tablet/wacom_sys.c23
-rw-r--r--drivers/input/tablet/wacom_wac.c169
-rw-r--r--drivers/input/tablet/wacom_wac.h13
-rw-r--r--drivers/input/touchscreen/88pm860x-ts.c2
-rw-r--r--drivers/input/touchscreen/ad7877.c3
-rw-r--r--drivers/input/touchscreen/ad7879.c5
-rw-r--r--drivers/input/touchscreen/ads7846.c86
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c3
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c3
-rw-r--r--drivers/input/touchscreen/cy8ctmg110_ts.c2
-rw-r--r--drivers/input/touchscreen/cyttsp_core.c4
-rw-r--r--drivers/input/touchscreen/cyttsp_i2c_common.c2
-rw-r--r--drivers/input/touchscreen/da9034-ts.c3
-rw-r--r--drivers/input/touchscreen/dynapro.c1
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c71
-rw-r--r--drivers/input/touchscreen/eeti_ts.c2
-rw-r--r--drivers/input/touchscreen/egalax_ts.c1
-rw-r--r--drivers/input/touchscreen/elo.c1
-rw-r--r--drivers/input/touchscreen/fujitsu_ts.c1
-rw-r--r--drivers/input/touchscreen/gunze.c1
-rw-r--r--drivers/input/touchscreen/hampshire.c1
-rw-r--r--drivers/input/touchscreen/ili210x.c2
-rw-r--r--drivers/input/touchscreen/inexio.c1
-rw-r--r--drivers/input/touchscreen/intel-mid-touch.c1
-rw-r--r--drivers/input/touchscreen/jornada720_ts.c1
-rw-r--r--drivers/input/touchscreen/lpc32xx_ts.c1
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c1
-rw-r--r--drivers/input/touchscreen/max11801_ts.c1
-rw-r--r--drivers/input/touchscreen/mcs5000_ts.c5
-rw-r--r--drivers/input/touchscreen/mms114.c1
-rw-r--r--drivers/input/touchscreen/mtouch.c1
-rw-r--r--drivers/input/touchscreen/pcap_ts.c1
-rw-r--r--drivers/input/touchscreen/penmount.c1
-rw-r--r--drivers/input/touchscreen/pixcir_i2c_ts.c3
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c5
-rw-r--r--drivers/input/touchscreen/st1232.c2
-rw-r--r--drivers/input/touchscreen/stmpe-ts.c1
-rw-r--r--drivers/input/touchscreen/ti_am335x_tsc.c1
-rw-r--r--drivers/input/touchscreen/touchit213.c1
-rw-r--r--drivers/input/touchscreen/touchright.c1
-rw-r--r--drivers/input/touchscreen/touchwin.c1
-rw-r--r--drivers/input/touchscreen/tsc2005.c2
-rw-r--r--drivers/input/touchscreen/tsc2007.c230
-rw-r--r--drivers/input/touchscreen/tsc40.c1
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c9
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c1
-rw-r--r--drivers/input/touchscreen/wacom_w8001.c1
-rw-r--r--drivers/input/touchscreen/wm831x-ts.c1
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c2
-rw-r--r--drivers/input/touchscreen/zforce_ts.c3
-rw-r--r--drivers/input/touchscreen/zylonite-wm97xx.c1
-rw-r--r--include/linux/i2c/tsc2007.h8
-rw-r--r--include/linux/platform_data/keypad-ep93xx.h10
-rw-r--r--include/linux/platform_data/keypad-omap.h6
204 files changed, 1245 insertions, 768 deletions
diff --git a/Documentation/devicetree/bindings/input/gpio-beeper.txt b/Documentation/devicetree/bindings/input/gpio-beeper.txt
new file mode 100644
index 000000000000..a5086e37fce6
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/gpio-beeper.txt
@@ -0,0 +1,13 @@
1* GPIO beeper device tree bindings
2
3Register a beeper connected to GPIO pin.
4
5Required properties:
6- compatible: Should be "gpio-beeper".
7- gpios: From common gpio binding; gpio connection to beeper enable pin.
8
9Example:
10 beeper: beeper {
11 compatible = "gpio-beeper";
12 gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
13 };
diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
new file mode 100644
index 000000000000..ec365e172236
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
@@ -0,0 +1,41 @@
1* Texas Instruments tsc2007 touchscreen controller
2
3Required properties:
4- compatible: must be "ti,tsc2007".
5- reg: I2C address of the chip.
6- ti,x-plate-ohms: X-plate resistance in ohms.
7
8Optional properties:
9- gpios: the interrupt gpio the chip is connected to (trough the penirq pin).
10 The penirq pin goes to low when the panel is touched.
11 (see GPIO binding[1] for more details).
12- interrupt-parent: the phandle for the gpio controller
13 (see interrupt binding[0]).
14- interrupts: (gpio) interrupt to which the chip is connected
15 (see interrupt binding[0]).
16- ti,max-rt: maximum pressure.
17- ti,fuzzx: specifies the absolute input fuzz x value.
18 If set, it will permit noise in the data up to +- the value given to the fuzz
19 parameter, that is used to filter noise from the event stream.
20- ti,fuzzy: specifies the absolute input fuzz y value.
21- ti,fuzzz: specifies the absolute input fuzz z value.
22- ti,poll-period: how much time to wait (in milliseconds) before reading again the
23 values from the tsc2007.
24
25[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
26[1]: Documentation/devicetree/bindings/gpio/gpio.txt
27
28Example:
29 &i2c1 {
30 /* ... */
31 tsc2007@49 {
32 compatible = "ti,tsc2007";
33 reg = <0x49>;
34 interrupt-parent = <&gpio4>;
35 interrupts = <0x0 0x8>;
36 gpios = <&gpio4 0 0>;
37 ti,x-plate-ohms = <180>;
38 };
39
40 /* ... */
41 };
diff --git a/Documentation/devicetree/bindings/input/twl4030-keypad.txt b/Documentation/devicetree/bindings/input/twl4030-keypad.txt
new file mode 100644
index 000000000000..e4be2f76a717
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/twl4030-keypad.txt
@@ -0,0 +1,27 @@
1* TWL4030's Keypad Controller device tree bindings
2
3TWL4030's Keypad controller is used to interface a SoC with a matrix-type
4keypad device. The keypad controller supports multiple row and column lines.
5A key can be placed at each intersection of a unique row and a unique column.
6The keypad controller can sense a key-press and key-release and report the
7event using a interrupt to the cpu.
8
9This binding is based on the matrix-keymap binding with the following
10changes:
11
12 * keypad,num-rows and keypad,num-columns are required.
13
14Required SoC Specific Properties:
15- compatible: should be one of the following
16 - "ti,twl4030-keypad": For controllers compatible with twl4030 keypad
17 controller.
18- interrupt: should be one of the following
19 - <1>: For controllers compatible with twl4030 keypad controller.
20
21Example:
22 twl_keypad: keypad {
23 compatible = "ti,twl4030-keypad";
24 interrupts = <1>;
25 keypad,num-rows = <8>;
26 keypad,num-columns = <8>;
27 };
diff --git a/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt b/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
new file mode 100644
index 000000000000..c864a46cddcf
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt
@@ -0,0 +1,21 @@
1Texas Instruments TWL family (twl4030) pwrbutton module
2
3This module is part of the TWL4030. For more details about the whole
4chip see Documentation/devicetree/bindings/mfd/twl-familly.txt.
5
6This module provides a simple power button event via an Interrupt.
7
8Required properties:
9- compatible: should be one of the following
10 - "ti,twl4030-pwrbutton": For controllers compatible with twl4030
11- interrupts: should be one of the following
12 - <8>: For controllers compatible with twl4030
13
14Example:
15
16&twl {
17 twl_pwrbutton: pwrbutton {
18 compatible = "ti,twl4030-pwrbutton";
19 interrupts = <8>;
20 };
21};
diff --git a/Documentation/input/gamepad.txt b/Documentation/input/gamepad.txt
index 31bb6a4029ef..3f6d8a5e9cdc 100644
--- a/Documentation/input/gamepad.txt
+++ b/Documentation/input/gamepad.txt
@@ -68,7 +68,7 @@ features that you need, first. How each feature is mapped is described below.
68Legacy drivers often don't comply to these rules. As we cannot change them 68Legacy drivers often don't comply to these rules. As we cannot change them
69for backwards-compatibility reasons, you need to provide fixup mappings in 69for backwards-compatibility reasons, you need to provide fixup mappings in
70user-space yourself. Some of them might also provide module-options that 70user-space yourself. Some of them might also provide module-options that
71change the mappings so you can adivce users to set these. 71change the mappings so you can advise users to set these.
72 72
73All new gamepads are supposed to comply with this mapping. Please report any 73All new gamepads are supposed to comply with this mapping. Please report any
74bugs, if they don't. 74bugs, if they don't.
@@ -150,10 +150,10 @@ Menu-Pad:
150 BTN_START 150 BTN_START
151 Many pads also have a third button which is branded or has a special symbol 151 Many pads also have a third button which is branded or has a special symbol
152 and meaning. Such buttons are mapped as BTN_MODE. Examples are the Nintendo 152 and meaning. Such buttons are mapped as BTN_MODE. Examples are the Nintendo
153 "HOME" button, the XBox "X"-button or Sony "P" button. 153 "HOME" button, the XBox "X"-button or Sony "PS" button.
154 154
155Rumble: 155Rumble:
156 Rumble is adverticed as FF_RUMBLE. 156 Rumble is advertised as FF_RUMBLE.
157 157
158---------------------------------------------------------------------------- 158----------------------------------------------------------------------------
159 Written 2013 by David Herrmann <dh.herrmann@gmail.com> 159 Written 2013 by David Herrmann <dh.herrmann@gmail.com>
diff --git a/Documentation/input/joystick-api.txt b/Documentation/input/joystick-api.txt
index c507330740cd..943b18eac918 100644
--- a/Documentation/input/joystick-api.txt
+++ b/Documentation/input/joystick-api.txt
@@ -16,14 +16,14 @@ joystick.
16 16
17By default, the device is opened in blocking mode. 17By default, the device is opened in blocking mode.
18 18
19 int fd = open ("/dev/js0", O_RDONLY); 19 int fd = open ("/dev/input/js0", O_RDONLY);
20 20
21 21
222. Event Reading 222. Event Reading
23~~~~~~~~~~~~~~~~ 23~~~~~~~~~~~~~~~~
24 24
25 struct js_event e; 25 struct js_event e;
26 read (fd, &e, sizeof(struct js_event)); 26 read (fd, &e, sizeof(e));
27 27
28where js_event is defined as 28where js_event is defined as
29 29
@@ -34,8 +34,8 @@ where js_event is defined as
34 __u8 number; /* axis/button number */ 34 __u8 number; /* axis/button number */
35 }; 35 };
36 36
37If the read is successful, it will return sizeof(struct js_event), unless 37If the read is successful, it will return sizeof(e), unless you wanted to read
38you wanted to read more than one event per read as described in section 3.1. 38more than one event per read as described in section 3.1.
39 39
40 40
412.1 js_event.type 412.1 js_event.type
@@ -99,9 +99,9 @@ may work well if you handle JS_EVENT_INIT events separately,
99 99
100 if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) { 100 if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) {
101 if (js_event.value) 101 if (js_event.value)
102 buttons_state |= (1 << js_event.number); 102 buttons_state |= (1 << js_event.number);
103 else 103 else
104 buttons_state &= ~(1 << js_event.number); 104 buttons_state &= ~(1 << js_event.number);
105 } 105 }
106 106
107is much safer since it can't lose sync with the driver. As you would 107is much safer since it can't lose sync with the driver. As you would
@@ -144,14 +144,14 @@ all events on the queue (that is, until you get a -1).
144For example, 144For example,
145 145
146 while (1) { 146 while (1) {
147 while (read (fd, &e, sizeof(struct js_event)) > 0) { 147 while (read (fd, &e, sizeof(e)) > 0) {
148 process_event (e); 148 process_event (e);
149 } 149 }
150 /* EAGAIN is returned when the queue is empty */ 150 /* EAGAIN is returned when the queue is empty */
151 if (errno != EAGAIN) { 151 if (errno != EAGAIN) {
152 /* error */ 152 /* error */
153 } 153 }
154 /* do something interesting with processed events */ 154 /* do something interesting with processed events */
155 } 155 }
156 156
157One reason for emptying the queue is that if it gets full you'll start 157One reason for emptying the queue is that if it gets full you'll start
@@ -181,7 +181,7 @@ at a time using the typical read(2) functionality. For that, you would
181replace the read above with something like 181replace the read above with something like
182 182
183 struct js_event mybuffer[0xff]; 183 struct js_event mybuffer[0xff];
184 int i = read (fd, mybuffer, sizeof(struct mybuffer)); 184 int i = read (fd, mybuffer, sizeof(mybuffer));
185 185
186In this case, read would return -1 if the queue was empty, or some 186In this case, read would return -1 if the queue was empty, or some
187other value in which the number of events read would be i / 187other value in which the number of events read would be i /
@@ -269,9 +269,9 @@ The driver offers backward compatibility, though. Here's a quick summary:
269 struct JS_DATA_TYPE js; 269 struct JS_DATA_TYPE js;
270 while (1) { 270 while (1) {
271 if (read (fd, &js, JS_RETURN) != JS_RETURN) { 271 if (read (fd, &js, JS_RETURN) != JS_RETURN) {
272 /* error */ 272 /* error */
273 } 273 }
274 usleep (1000); 274 usleep (1000);
275 } 275 }
276 276
277As you can figure out from the example, the read returns immediately, 277As you can figure out from the example, the read returns immediately,
diff --git a/Documentation/input/joystick.txt b/Documentation/input/joystick.txt
index 304262bb661a..8d027dc86c1f 100644
--- a/Documentation/input/joystick.txt
+++ b/Documentation/input/joystick.txt
@@ -116,7 +116,7 @@ your needs:
116 For testing the joystick driver functionality, there is the jstest 116 For testing the joystick driver functionality, there is the jstest
117program in the utilities package. You run it by typing: 117program in the utilities package. You run it by typing:
118 118
119 jstest /dev/js0 119 jstest /dev/input/js0
120 120
121 And it should show a line with the joystick values, which update as you 121 And it should show a line with the joystick values, which update as you
122move the stick, and press its buttons. The axes should all be zero when the 122move the stick, and press its buttons. The axes should all be zero when the
@@ -136,7 +136,7 @@ joystick should be autocalibrated by the driver automagically. However, with
136some analog joysticks, that either do not use linear resistors, or if you 136some analog joysticks, that either do not use linear resistors, or if you
137want better precision, you can use the jscal program 137want better precision, you can use the jscal program
138 138
139 jscal -c /dev/js0 139 jscal -c /dev/input/js0
140 140
141 included in the joystick package to set better correction coefficients than 141 included in the joystick package to set better correction coefficients than
142what the driver would choose itself. 142what the driver would choose itself.
@@ -145,7 +145,7 @@ what the driver would choose itself.
145calibration using the jstest command, and if you do, you then can save the 145calibration using the jstest command, and if you do, you then can save the
146correction coefficients into a file 146correction coefficients into a file
147 147
148 jscal -p /dev/js0 > /etc/joystick.cal 148 jscal -p /dev/input/js0 > /etc/joystick.cal
149 149
150 And add a line to your rc script executing that file 150 And add a line to your rc script executing that file
151 151
@@ -556,7 +556,7 @@ interface, and "old" for the "0.x" interface. You run it by typing:
556 556
5575. FAQ 5575. FAQ
558~~~~~~ 558~~~~~~
559Q: Running 'jstest /dev/js0' results in "File not found" error. What's the 559Q: Running 'jstest /dev/input/js0' results in "File not found" error. What's the
560 cause? 560 cause?
561A: The device files don't exist. Create them (see section 2.2). 561A: The device files don't exist. Create them (see section 2.2).
562 562
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 3ba48fe1c0a5..97a2d9a096b9 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -2,6 +2,7 @@ config ALPHA
2 bool 2 bool
3 default y 3 default y
4 select ARCH_MIGHT_HAVE_PC_PARPORT 4 select ARCH_MIGHT_HAVE_PC_PARPORT
5 select ARCH_MIGHT_HAVE_PC_SERIO
5 select HAVE_AOUT 6 select HAVE_AOUT
6 select HAVE_IDE 7 select HAVE_IDE
7 select HAVE_OPROFILE 8 select HAVE_OPROFILE
diff --git a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig
index 0f2111a11315..fba55fb9f47d 100644
--- a/arch/arm/mach-footbridge/Kconfig
+++ b/arch/arm/mach-footbridge/Kconfig
@@ -85,6 +85,7 @@ config FOOTBRIDGE
85# Footbridge in host mode 85# Footbridge in host mode
86config FOOTBRIDGE_HOST 86config FOOTBRIDGE_HOST
87 bool 87 bool
88 select ARCH_MIGHT_HAVE_PC_SERIO
88 89
89# Footbridge in addin mode 90# Footbridge in addin mode
90config FOOTBRIDGE_ADDIN 91config FOOTBRIDGE_ADDIN
diff --git a/arch/arm/mach-imx/mach-cpuimx35.c b/arch/arm/mach-imx/mach-cpuimx35.c
index 771362d1fbee..65e4c53e1554 100644
--- a/arch/arm/mach-imx/mach-cpuimx35.c
+++ b/arch/arm/mach-imx/mach-cpuimx35.c
@@ -53,7 +53,7 @@ static const struct imxi2c_platform_data
53}; 53};
54 54
55#define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2) 55#define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2)
56static int tsc2007_get_pendown_state(void) 56static int tsc2007_get_pendown_state(struct device *dev)
57{ 57{
58 return !gpio_get_value(TSC2007_IRQGPIO); 58 return !gpio_get_value(TSC2007_IRQGPIO);
59} 59}
diff --git a/arch/arm/mach-imx/mach-cpuimx51sd.c b/arch/arm/mach-imx/mach-cpuimx51sd.c
index 9b5ddf5bbd33..1fba2b8e983f 100644
--- a/arch/arm/mach-imx/mach-cpuimx51sd.c
+++ b/arch/arm/mach-imx/mach-cpuimx51sd.c
@@ -121,7 +121,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
121 .flags = IMXUART_HAVE_RTSCTS, 121 .flags = IMXUART_HAVE_RTSCTS,
122}; 122};
123 123
124static int tsc2007_get_pendown_state(void) 124static int tsc2007_get_pendown_state(struct device *dev)
125{ 125{
126 if (mx51_revision() < IMX_CHIP_REVISION_3_0) 126 if (mx51_revision() < IMX_CHIP_REVISION_3_0)
127 return !gpio_get_value(TSC2007_IRQGPIO_REV2); 127 return !gpio_get_value(TSC2007_IRQGPIO_REV2);
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index c063b054294e..0c8e553e0b9f 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -7,6 +7,7 @@ menu "Processor type and features"
7config IA64 7config IA64
8 bool 8 bool
9 select ARCH_MIGHT_HAVE_PC_PARPORT 9 select ARCH_MIGHT_HAVE_PC_PARPORT
10 select ARCH_MIGHT_HAVE_PC_SERIO
10 select PCI if (!IA64_HP_SIM) 11 select PCI if (!IA64_HP_SIM)
11 select ACPI if (!IA64_HP_SIM) 12 select ACPI if (!IA64_HP_SIM)
12 select PM if (!IA64_HP_SIM) 13 select PM if (!IA64_HP_SIM)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 52dac06ea6b4..c02f1c03a22e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2,6 +2,7 @@ config MIPS
2 bool 2 bool
3 default y 3 default y
4 select ARCH_MIGHT_HAVE_PC_PARPORT 4 select ARCH_MIGHT_HAVE_PC_PARPORT
5 select ARCH_MIGHT_HAVE_PC_SERIO
5 select HAVE_CONTEXT_TRACKING 6 select HAVE_CONTEXT_TRACKING
6 select HAVE_GENERIC_DMA_COHERENT 7 select HAVE_GENERIC_DMA_COHERENT
7 select HAVE_IDE 8 select HAVE_IDE
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index bedc62b44aa6..1695b6ab503d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -86,6 +86,7 @@ config PPC
86 bool 86 bool
87 default y 87 default y
88 select ARCH_MIGHT_HAVE_PC_PARPORT 88 select ARCH_MIGHT_HAVE_PC_PARPORT
89 select ARCH_MIGHT_HAVE_PC_SERIO
89 select BINFMT_ELF 90 select BINFMT_ELF
90 select OF 91 select OF
91 select OF_EARLY_FLATTREE 92 select OF_EARLY_FLATTREE
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index fb5805745ace..eb1cf84231a2 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -321,6 +321,7 @@ config SH_CAYMAN
321 bool "Hitachi Cayman" 321 bool "Hitachi Cayman"
322 depends on CPU_SUBTYPE_SH5_101 || CPU_SUBTYPE_SH5_103 322 depends on CPU_SUBTYPE_SH5_101 || CPU_SUBTYPE_SH5_103
323 select SYS_SUPPORTS_PCI 323 select SYS_SUPPORTS_PCI
324 select ARCH_MIGHT_HAVE_PC_SERIO
324 325
325config SH_POLARIS 326config SH_POLARIS
326 bool "SMSC Polaris" 327 bool "SMSC Polaris"
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 122f737a901f..5bc3a15465c7 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -502,7 +502,7 @@ static struct platform_device keysc_device = {
502/* TouchScreen */ 502/* TouchScreen */
503#define IRQ0 evt2irq(0x600) 503#define IRQ0 evt2irq(0x600)
504 504
505static int ts_get_pendown_state(void) 505static int ts_get_pendown_state(struct device *dev)
506{ 506{
507 int val = 0; 507 int val = 0;
508 gpio_free(GPIO_FN_INTC_IRQ0); 508 gpio_free(GPIO_FN_INTC_IRQ0);
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 63dfe68f4af8..c51efdcd07a2 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -13,6 +13,7 @@ config SPARC
13 bool 13 bool
14 default y 14 default y
15 select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI 15 select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI
16 select ARCH_MIGHT_HAVE_PC_SERIO
16 select OF 17 select OF
17 select OF_PROMTREE 18 select OF_PROMTREE
18 select HAVE_IDE 19 select HAVE_IDE
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index a7ba27b2752b..25c0dba508cc 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -1,6 +1,7 @@
1config UNICORE32 1config UNICORE32
2 def_bool y 2 def_bool y
3 select ARCH_MIGHT_HAVE_PC_PARPORT 3 select ARCH_MIGHT_HAVE_PC_PARPORT
4 select ARCH_MIGHT_HAVE_PC_SERIO
4 select HAVE_MEMBLOCK 5 select HAVE_MEMBLOCK
5 select HAVE_GENERIC_DMA_COHERENT 6 select HAVE_GENERIC_DMA_COHERENT
6 select HAVE_DMA_ATTRS 7 select HAVE_DMA_ATTRS
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3e97a3dd4129..940e50ebfafa 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -23,6 +23,7 @@ config X86
23 def_bool y 23 def_bool y
24 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS 24 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
25 select ARCH_MIGHT_HAVE_PC_PARPORT 25 select ARCH_MIGHT_HAVE_PC_PARPORT
26 select ARCH_MIGHT_HAVE_PC_SERIO
26 select HAVE_AOUT if X86_32 27 select HAVE_AOUT if X86_32
27 select HAVE_UNSTABLE_SCHED_CLOCK 28 select HAVE_UNSTABLE_SCHED_CLOCK
28 select ARCH_SUPPORTS_NUMA_BALANCING 29 select ARCH_SUPPORTS_NUMA_BALANCING
diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c
index fa7a95c1da0e..2909e9561cf3 100644
--- a/drivers/input/gameport/emu10k1-gp.c
+++ b/drivers/input/gameport/emu10k1-gp.c
@@ -30,7 +30,6 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/init.h>
34#include <linux/gameport.h> 33#include <linux/gameport.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/pci.h> 35#include <linux/pci.h>
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index ae912d3aee4e..7c03114158e0 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -27,7 +27,6 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/init.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include <linux/gameport.h> 31#include <linux/gameport.h>
33 32
diff --git a/drivers/input/input.c b/drivers/input/input.c
index d2965e4b3224..1c4c0db05550 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1653,35 +1653,36 @@ static void input_dev_toggle(struct input_dev *dev, bool activate)
1653 */ 1653 */
1654void input_reset_device(struct input_dev *dev) 1654void input_reset_device(struct input_dev *dev)
1655{ 1655{
1656 mutex_lock(&dev->mutex); 1656 unsigned long flags;
1657 1657
1658 if (dev->users) { 1658 mutex_lock(&dev->mutex);
1659 input_dev_toggle(dev, true); 1659 spin_lock_irqsave(&dev->event_lock, flags);
1660 1660
1661 /* 1661 input_dev_toggle(dev, true);
1662 * Keys that have been pressed at suspend time are unlikely 1662 input_dev_release_keys(dev);
1663 * to be still pressed when we resume.
1664 */
1665 spin_lock_irq(&dev->event_lock);
1666 input_dev_release_keys(dev);
1667 spin_unlock_irq(&dev->event_lock);
1668 }
1669 1663
1664 spin_unlock_irqrestore(&dev->event_lock, flags);
1670 mutex_unlock(&dev->mutex); 1665 mutex_unlock(&dev->mutex);
1671} 1666}
1672EXPORT_SYMBOL(input_reset_device); 1667EXPORT_SYMBOL(input_reset_device);
1673 1668
1674#ifdef CONFIG_PM 1669#ifdef CONFIG_PM_SLEEP
1675static int input_dev_suspend(struct device *dev) 1670static int input_dev_suspend(struct device *dev)
1676{ 1671{
1677 struct input_dev *input_dev = to_input_dev(dev); 1672 struct input_dev *input_dev = to_input_dev(dev);
1678 1673
1679 mutex_lock(&input_dev->mutex); 1674 spin_lock_irq(&input_dev->event_lock);
1680 1675
1681 if (input_dev->users) 1676 /*
1682 input_dev_toggle(input_dev, false); 1677 * Keys that are pressed now are unlikely to be
1678 * still pressed when we resume.
1679 */
1680 input_dev_release_keys(input_dev);
1683 1681
1684 mutex_unlock(&input_dev->mutex); 1682 /* Turn off LEDs and sounds, if any are active. */
1683 input_dev_toggle(input_dev, false);
1684
1685 spin_unlock_irq(&input_dev->event_lock);
1685 1686
1686 return 0; 1687 return 0;
1687} 1688}
@@ -1690,7 +1691,43 @@ static int input_dev_resume(struct device *dev)
1690{ 1691{
1691 struct input_dev *input_dev = to_input_dev(dev); 1692 struct input_dev *input_dev = to_input_dev(dev);
1692 1693
1693 input_reset_device(input_dev); 1694 spin_lock_irq(&input_dev->event_lock);
1695
1696 /* Restore state of LEDs and sounds, if any were active. */
1697 input_dev_toggle(input_dev, true);
1698
1699 spin_unlock_irq(&input_dev->event_lock);
1700
1701 return 0;
1702}
1703
1704static int input_dev_freeze(struct device *dev)
1705{
1706 struct input_dev *input_dev = to_input_dev(dev);
1707
1708 spin_lock_irq(&input_dev->event_lock);
1709
1710 /*
1711 * Keys that are pressed now are unlikely to be
1712 * still pressed when we resume.
1713 */
1714 input_dev_release_keys(input_dev);
1715
1716 spin_unlock_irq(&input_dev->event_lock);
1717
1718 return 0;
1719}
1720
1721static int input_dev_poweroff(struct device *dev)
1722{
1723 struct input_dev *input_dev = to_input_dev(dev);
1724
1725 spin_lock_irq(&input_dev->event_lock);
1726
1727 /* Turn off LEDs and sounds, if any are active. */
1728 input_dev_toggle(input_dev, false);
1729
1730 spin_unlock_irq(&input_dev->event_lock);
1694 1731
1695 return 0; 1732 return 0;
1696} 1733}
@@ -1698,7 +1735,8 @@ static int input_dev_resume(struct device *dev)
1698static const struct dev_pm_ops input_dev_pm_ops = { 1735static const struct dev_pm_ops input_dev_pm_ops = {
1699 .suspend = input_dev_suspend, 1736 .suspend = input_dev_suspend,
1700 .resume = input_dev_resume, 1737 .resume = input_dev_resume,
1701 .poweroff = input_dev_suspend, 1738 .freeze = input_dev_freeze,
1739 .poweroff = input_dev_poweroff,
1702 .restore = input_dev_resume, 1740 .restore = input_dev_resume,
1703}; 1741};
1704#endif /* CONFIG_PM */ 1742#endif /* CONFIG_PM */
@@ -1707,7 +1745,7 @@ static struct device_type input_dev_type = {
1707 .groups = input_dev_attr_groups, 1745 .groups = input_dev_attr_groups,
1708 .release = input_dev_release, 1746 .release = input_dev_release,
1709 .uevent = input_dev_uevent, 1747 .uevent = input_dev_uevent,
1710#ifdef CONFIG_PM 1748#ifdef CONFIG_PM_SLEEP
1711 .pm = &input_dev_pm_ops, 1749 .pm = &input_dev_pm_ops,
1712#endif 1750#endif
1713}; 1751};
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index 85bc8dc07cfc..55efdfc7eb62 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -29,7 +29,6 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/init.h>
33#include <linux/gameport.h> 32#include <linux/gameport.h>
34#include <linux/input.h> 33#include <linux/input.h>
35#include <linux/jiffies.h> 34#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 0cbfd2dfabf4..b78425765d3e 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -33,7 +33,6 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/input.h> 34#include <linux/input.h>
35#include <linux/gameport.h> 35#include <linux/gameport.h>
36#include <linux/init.h>
37#include <linux/jiffies.h> 36#include <linux/jiffies.h>
38 37
39#define DRIVER_DESC "Logitech ADI joystick family driver" 38#define DRIVER_DESC "Logitech ADI joystick family driver"
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index 65367e44d715..ae3ee24a2368 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -29,7 +29,6 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/init.h>
33#include <linux/gameport.h> 32#include <linux/gameport.h>
34#include <linux/input.h> 33#include <linux/input.h>
35#include <linux/jiffies.h> 34#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index ab1cf2882004..0f519db64748 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -30,7 +30,6 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h>
34#include <linux/input.h> 33#include <linux/input.h>
35#include <linux/gameport.h> 34#include <linux/gameport.h>
36#include <linux/jiffies.h> 35#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index 9e1beff57c33..eac9c5b8d73e 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -28,7 +28,6 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/slab.h> 31#include <linux/slab.h>
33#include <linux/gameport.h> 32#include <linux/gameport.h>
34#include <linux/input.h> 33#include <linux/input.h>
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index c0f9c7b7eb4e..573191dd78e8 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include <linux/gameport.h> 15#include <linux/gameport.h>
17#include <linux/input.h> 16#include <linux/input.h>
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 55196f730af6..a9ac2f9cfce0 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -30,7 +30,6 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/init.h>
34#include <linux/gameport.h> 33#include <linux/gameport.h>
35#include <linux/input.h> 34#include <linux/input.h>
36#include <linux/jiffies.h> 35#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
index b1d7d9b0eb86..96ae4f5bd0eb 100644
--- a/drivers/input/joystick/iforce/iforce.h
+++ b/drivers/input/joystick/iforce/iforce.h
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/spinlock.h> 32#include <linux/spinlock.h>
34#include <linux/usb.h> 33#include <linux/usb.h>
35#include <linux/serio.h> 34#include <linux/serio.h>
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index 88c22623a2e8..17c2c800743c 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -33,7 +33,6 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/init.h>
37#include <linux/gameport.h> 36#include <linux/gameport.h>
38#include <linux/input.h> 37#include <linux/input.h>
39#include <linux/jiffies.h> 38#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
index 7eb878bab968..d1c6e4846a4a 100644
--- a/drivers/input/joystick/joydump.c
+++ b/drivers/input/joystick/joydump.c
@@ -31,7 +31,6 @@
31#include <linux/gameport.h> 31#include <linux/gameport.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/init.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36 35
37#define DRIVER_DESC "Gameport data dumper module" 36#define DRIVER_DESC "Gameport data dumper module"
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 9fb153eef2fc..c5358ba1f571 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -31,7 +31,6 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/serio.h> 33#include <linux/serio.h>
34#include <linux/init.h>
35 34
36#define DRIVER_DESC "Magellan and SpaceMouse 6dof controller driver" 35#define DRIVER_DESC "Magellan and SpaceMouse 6dof controller driver"
37 36
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 04c69af37148..4a95b224169f 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -30,7 +30,6 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/init.h>
34#include <linux/input.h> 33#include <linux/input.h>
35#include <linux/gameport.h> 34#include <linux/gameport.h>
36#include <linux/jiffies.h> 35#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index 80a7b27a457a..f4445a4e8d6a 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -33,7 +33,6 @@
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/init.h>
37#include <linux/input.h> 36#include <linux/input.h>
38#include <linux/serio.h> 37#include <linux/serio.h>
39 38
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index a41f291652e6..f2667820e8c5 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -32,7 +32,6 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/input.h> 35#include <linux/input.h>
37#include <linux/serio.h> 36#include <linux/serio.h>
38 37
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 0f51a60e14a7..099c6d7b5e08 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -32,7 +32,6 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/input.h> 33#include <linux/input.h>
34#include <linux/serio.h> 34#include <linux/serio.h>
35#include <linux/init.h>
36 35
37#define DRIVER_DESC "Gravis Stinger gamepad driver" 36#define DRIVER_DESC "Gravis Stinger gamepad driver"
38 37
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 5ef9bcdb0345..7e17cde464f0 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -33,7 +33,6 @@
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/init.h>
37#include <linux/gameport.h> 36#include <linux/gameport.h>
38#include <linux/input.h> 37#include <linux/input.h>
39#include <linux/jiffies.h> 38#include <linux/jiffies.h>
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index 2556a8193579..7f7e5ab3f9e3 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -52,7 +52,6 @@
52#include <linux/slab.h> 52#include <linux/slab.h>
53#include <linux/input.h> 53#include <linux/input.h>
54#include <linux/serio.h> 54#include <linux/serio.h>
55#include <linux/init.h>
56 55
57#define DRIVER_DESC "Handykey Twiddler keyboard as a joystick driver" 56#define DRIVER_DESC "Handykey Twiddler keyboard as a joystick driver"
58 57
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index 23b3071abb6e..e13a9144a25d 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -31,7 +31,6 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/serio.h> 33#include <linux/serio.h>
34#include <linux/init.h>
35 34
36#define DRIVER_DESC "Logitech WingMan Warrior joystick driver" 35#define DRIVER_DESC "Logitech WingMan Warrior joystick driver"
37 36
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 75e3b102ce45..603fe0dd3682 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -74,7 +74,6 @@
74 */ 74 */
75 75
76#include <linux/kernel.h> 76#include <linux/kernel.h>
77#include <linux/init.h>
78#include <linux/slab.h> 77#include <linux/slab.h>
79#include <linux/stat.h> 78#include <linux/stat.h>
80#include <linux/module.h> 79#include <linux/module.h>
@@ -125,6 +124,8 @@ static const struct xpad_device {
125 { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 124 { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
126 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 125 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
127 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, 126 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
127 { 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 },
128 { 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 },
128 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, 129 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
129 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, 130 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
130 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX }, 131 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
@@ -166,8 +167,8 @@ static const struct xpad_device {
166 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 }, 167 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
167 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 168 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
168 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, 169 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
169 { 0x1689, 0xfd00, "Razer Onza Tournament Edition", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 170 { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 },
170 { 0x1689, 0xfd01, "Razer Onza Classic Edition", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 171 { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 },
171 { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, 172 { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
172 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 173 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
173 { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 }, 174 { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
diff --git a/drivers/input/joystick/zhenhua.c b/drivers/input/joystick/zhenhua.c
index c4de4388fd7f..30af2e8c670c 100644
--- a/drivers/input/joystick/zhenhua.c
+++ b/drivers/input/joystick/zhenhua.c
@@ -49,7 +49,6 @@
49#include <linux/slab.h> 49#include <linux/slab.h>
50#include <linux/input.h> 50#include <linux/input.h>
51#include <linux/serio.h> 51#include <linux/serio.h>
52#include <linux/init.h>
53 52
54#define DRIVER_DESC "RC transmitter with 5-byte Zhen Hua protocol joystick driver" 53#define DRIVER_DESC "RC transmitter with 5-byte Zhen Hua protocol joystick driver"
55 54
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index bb174c1a9886..a673c9f3a0b9 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -525,7 +525,7 @@ config KEYBOARD_SUNKBD
525 525
526config KEYBOARD_SH_KEYSC 526config KEYBOARD_SH_KEYSC
527 tristate "SuperH KEYSC keypad support" 527 tristate "SuperH KEYSC keypad support"
528 depends on SUPERH || ARM || COMPILE_TEST 528 depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
529 help 529 help
530 Say Y here if you want to use a keypad attached to the KEYSC block 530 Say Y here if you want to use a keypad attached to the KEYSC block
531 on SuperH processors such as sh7722 and sh7343. 531 on SuperH processors such as sh7722 and sh7343.
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c
index ef26b17fb159..4cc14c2fa7d5 100644
--- a/drivers/input/keyboard/adp5520-keys.c
+++ b/drivers/input/keyboard/adp5520-keys.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/platform_device.h> 11#include <linux/platform_device.h>
13#include <linux/input.h> 12#include <linux/input.h>
14#include <linux/mfd/adp5520.h> 13#include <linux/mfd/adp5520.h>
@@ -71,7 +70,7 @@ static int adp5520_keys_notifier(struct notifier_block *nb,
71 70
72static int adp5520_keys_probe(struct platform_device *pdev) 71static int adp5520_keys_probe(struct platform_device *pdev)
73{ 72{
74 struct adp5520_keys_platform_data *pdata = pdev->dev.platform_data; 73 struct adp5520_keys_platform_data *pdata = dev_get_platdata(&pdev->dev);
75 struct input_dev *input; 74 struct input_dev *input;
76 struct adp5520_keys *dev; 75 struct adp5520_keys *dev;
77 int ret, i; 76 int ret, i;
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 3ed23513d881..bb3b57bea8ba 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/interrupt.h> 12#include <linux/interrupt.h>
14#include <linux/irq.h> 13#include <linux/irq.h>
15#include <linux/workqueue.h> 14#include <linux/workqueue.h>
@@ -173,7 +172,7 @@ static int adp5588_build_gpiomap(struct adp5588_kpad *kpad,
173static int adp5588_gpio_add(struct adp5588_kpad *kpad) 172static int adp5588_gpio_add(struct adp5588_kpad *kpad)
174{ 173{
175 struct device *dev = &kpad->client->dev; 174 struct device *dev = &kpad->client->dev;
176 const struct adp5588_kpad_platform_data *pdata = dev->platform_data; 175 const struct adp5588_kpad_platform_data *pdata = dev_get_platdata(dev);
177 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 176 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
178 int i, error; 177 int i, error;
179 178
@@ -227,7 +226,7 @@ static int adp5588_gpio_add(struct adp5588_kpad *kpad)
227static void adp5588_gpio_remove(struct adp5588_kpad *kpad) 226static void adp5588_gpio_remove(struct adp5588_kpad *kpad)
228{ 227{
229 struct device *dev = &kpad->client->dev; 228 struct device *dev = &kpad->client->dev;
230 const struct adp5588_kpad_platform_data *pdata = dev->platform_data; 229 const struct adp5588_kpad_platform_data *pdata = dev_get_platdata(dev);
231 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 230 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
232 int error; 231 int error;
233 232
@@ -321,7 +320,8 @@ static irqreturn_t adp5588_irq(int irq, void *handle)
321 320
322static int adp5588_setup(struct i2c_client *client) 321static int adp5588_setup(struct i2c_client *client)
323{ 322{
324 const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 323 const struct adp5588_kpad_platform_data *pdata =
324 dev_get_platdata(&client->dev);
325 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 325 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
326 int i, ret; 326 int i, ret;
327 unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; 327 unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0;
@@ -424,7 +424,8 @@ static int adp5588_probe(struct i2c_client *client,
424 const struct i2c_device_id *id) 424 const struct i2c_device_id *id)
425{ 425{
426 struct adp5588_kpad *kpad; 426 struct adp5588_kpad *kpad;
427 const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 427 const struct adp5588_kpad_platform_data *pdata =
428 dev_get_platdata(&client->dev);
428 struct input_dev *input; 429 struct input_dev *input;
429 unsigned int revid; 430 unsigned int revid;
430 int ret, i; 431 int ret, i;
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index 60dafd4fa692..6329549bf6ad 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
13#include <linux/irq.h> 12#include <linux/irq.h>
14#include <linux/workqueue.h> 13#include <linux/workqueue.h>
@@ -499,7 +498,7 @@ static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,
499static int adp5589_gpio_add(struct adp5589_kpad *kpad) 498static int adp5589_gpio_add(struct adp5589_kpad *kpad)
500{ 499{
501 struct device *dev = &kpad->client->dev; 500 struct device *dev = &kpad->client->dev;
502 const struct adp5589_kpad_platform_data *pdata = dev->platform_data; 501 const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
503 const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; 502 const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
504 int i, error; 503 int i, error;
505 504
@@ -553,7 +552,7 @@ static int adp5589_gpio_add(struct adp5589_kpad *kpad)
553static void adp5589_gpio_remove(struct adp5589_kpad *kpad) 552static void adp5589_gpio_remove(struct adp5589_kpad *kpad)
554{ 553{
555 struct device *dev = &kpad->client->dev; 554 struct device *dev = &kpad->client->dev;
556 const struct adp5589_kpad_platform_data *pdata = dev->platform_data; 555 const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
557 const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; 556 const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
558 int error; 557 int error;
559 558
@@ -658,7 +657,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
658{ 657{
659 struct i2c_client *client = kpad->client; 658 struct i2c_client *client = kpad->client;
660 const struct adp5589_kpad_platform_data *pdata = 659 const struct adp5589_kpad_platform_data *pdata =
661 client->dev.platform_data; 660 dev_get_platdata(&client->dev);
662 u8 (*reg) (u8) = kpad->var->reg; 661 u8 (*reg) (u8) = kpad->var->reg;
663 unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; 662 unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0;
664 unsigned char pull_mask = 0; 663 unsigned char pull_mask = 0;
@@ -864,7 +863,7 @@ static int adp5589_probe(struct i2c_client *client,
864{ 863{
865 struct adp5589_kpad *kpad; 864 struct adp5589_kpad *kpad;
866 const struct adp5589_kpad_platform_data *pdata = 865 const struct adp5589_kpad_platform_data *pdata =
867 client->dev.platform_data; 866 dev_get_platdata(&client->dev);
868 struct input_dev *input; 867 struct input_dev *input;
869 unsigned int revid; 868 unsigned int revid;
870 int ret, i; 869 int ret, i;
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index 09b91d093087..e6d46c5994d7 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -30,7 +30,6 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32 32
33#include <linux/init.h>
34#include <linux/fs.h> 33#include <linux/fs.h>
35#include <linux/interrupt.h> 34#include <linux/interrupt.h>
36#include <linux/irq.h> 35#include <linux/irq.h>
@@ -180,7 +179,7 @@ static irqreturn_t bfin_kpad_isr(int irq, void *dev_id)
180static int bfin_kpad_probe(struct platform_device *pdev) 179static int bfin_kpad_probe(struct platform_device *pdev)
181{ 180{
182 struct bf54x_kpad *bf54x_kpad; 181 struct bf54x_kpad *bf54x_kpad;
183 struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data; 182 struct bfin_kpad_platform_data *pdata = dev_get_platdata(&pdev->dev);
184 struct input_dev *input; 183 struct input_dev *input;
185 int i, error; 184 int i, error;
186 185
@@ -333,7 +332,7 @@ out:
333 332
334static int bfin_kpad_remove(struct platform_device *pdev) 333static int bfin_kpad_remove(struct platform_device *pdev)
335{ 334{
336 struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data; 335 struct bfin_kpad_platform_data *pdata = dev_get_platdata(&pdev->dev);
337 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 336 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);
338 337
339 del_timer_sync(&bf54x_kpad->timer); 338 del_timer_sync(&bf54x_kpad->timer);
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 7e8b0a52af25..408379669d3c 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -38,6 +38,7 @@
38 * @row_shift: log2 or number of rows, rounded up 38 * @row_shift: log2 or number of rows, rounded up
39 * @keymap_data: Matrix keymap data used to convert to keyscan values 39 * @keymap_data: Matrix keymap data used to convert to keyscan values
40 * @ghost_filter: true to enable the matrix key-ghosting filter 40 * @ghost_filter: true to enable the matrix key-ghosting filter
41 * @old_kb_state: bitmap of keys pressed last scan
41 * @dev: Device pointer 42 * @dev: Device pointer
42 * @idev: Input device 43 * @idev: Input device
43 * @ec: Top level ChromeOS device to use to talk to EC 44 * @ec: Top level ChromeOS device to use to talk to EC
@@ -49,6 +50,7 @@ struct cros_ec_keyb {
49 int row_shift; 50 int row_shift;
50 const struct matrix_keymap_data *keymap_data; 51 const struct matrix_keymap_data *keymap_data;
51 bool ghost_filter; 52 bool ghost_filter;
53 uint8_t *old_kb_state;
52 54
53 struct device *dev; 55 struct device *dev;
54 struct input_dev *idev; 56 struct input_dev *idev;
@@ -135,6 +137,7 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev,
135 struct input_dev *idev = ckdev->idev; 137 struct input_dev *idev = ckdev->idev;
136 int col, row; 138 int col, row;
137 int new_state; 139 int new_state;
140 int old_state;
138 int num_cols; 141 int num_cols;
139 142
140 num_cols = len; 143 num_cols = len;
@@ -153,18 +156,19 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev,
153 for (row = 0; row < ckdev->rows; row++) { 156 for (row = 0; row < ckdev->rows; row++) {
154 int pos = MATRIX_SCAN_CODE(row, col, ckdev->row_shift); 157 int pos = MATRIX_SCAN_CODE(row, col, ckdev->row_shift);
155 const unsigned short *keycodes = idev->keycode; 158 const unsigned short *keycodes = idev->keycode;
156 int code;
157 159
158 code = keycodes[pos];
159 new_state = kb_state[col] & (1 << row); 160 new_state = kb_state[col] & (1 << row);
160 if (!!new_state != test_bit(code, idev->key)) { 161 old_state = ckdev->old_kb_state[col] & (1 << row);
162 if (new_state != old_state) {
161 dev_dbg(ckdev->dev, 163 dev_dbg(ckdev->dev,
162 "changed: [r%d c%d]: byte %02x\n", 164 "changed: [r%d c%d]: byte %02x\n",
163 row, col, new_state); 165 row, col, new_state);
164 166
165 input_report_key(idev, code, new_state); 167 input_report_key(idev, keycodes[pos],
168 new_state);
166 } 169 }
167 } 170 }
171 ckdev->old_kb_state[col] = kb_state[col];
168 } 172 }
169 input_sync(ckdev->idev); 173 input_sync(ckdev->idev);
170} 174}
@@ -226,6 +230,9 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
226 &ckdev->cols); 230 &ckdev->cols);
227 if (err) 231 if (err)
228 return err; 232 return err;
233 ckdev->old_kb_state = devm_kzalloc(&pdev->dev, ckdev->cols, GFP_KERNEL);
234 if (!ckdev->old_kb_state)
235 return -ENOMEM;
229 236
230 idev = devm_input_allocate_device(&pdev->dev); 237 idev = devm_input_allocate_device(&pdev->dev);
231 if (!idev) 238 if (!idev)
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
index d15977a8361e..1559dc1cf951 100644
--- a/drivers/input/keyboard/davinci_keyscan.c
+++ b/drivers/input/keyboard/davinci_keyscan.c
@@ -172,7 +172,7 @@ static int __init davinci_ks_probe(struct platform_device *pdev)
172 struct input_dev *key_dev; 172 struct input_dev *key_dev;
173 struct resource *res, *mem; 173 struct resource *res, *mem;
174 struct device *dev = &pdev->dev; 174 struct device *dev = &pdev->dev;
175 struct davinci_ks_platform_data *pdata = pdev->dev.platform_data; 175 struct davinci_ks_platform_data *pdata = dev_get_platdata(&pdev->dev);
176 int error, i; 176 int error, i;
177 177
178 if (pdata->device_enable) { 178 if (pdata->device_enable) {
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index 47206bdba411..e59876212b8c 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -244,7 +244,7 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
244 if (!keypad) 244 if (!keypad)
245 return -ENOMEM; 245 return -ENOMEM;
246 246
247 keypad->pdata = pdev->dev.platform_data; 247 keypad->pdata = dev_get_platdata(&pdev->dev);
248 if (!keypad->pdata) { 248 if (!keypad->pdata) {
249 err = -EINVAL; 249 err = -EINVAL;
250 goto failed_free; 250 goto failed_free;
diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c
index 9f60a2ec88db..69e854763370 100644
--- a/drivers/input/keyboard/goldfish_events.c
+++ b/drivers/input/keyboard/goldfish_events.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
19#include <linux/types.h> 18#include <linux/types.h>
20#include <linux/input.h> 19#include <linux/input.h>
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index 4e428199e580..e571e194ff84 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -17,7 +17,6 @@
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/input.h> 21#include <linux/input.h>
23#include <linux/input-polldev.h> 22#include <linux/input-polldev.h>
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index 589e3c258f3f..610a8af795a1 100644
--- a/drivers/input/keyboard/hil_kbd.c
+++ b/drivers/input/keyboard/hil_kbd.c
@@ -36,7 +36,6 @@
36#include <linux/serio.h> 36#include <linux/serio.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/init.h>
40#include <linux/completion.h> 39#include <linux/completion.h>
41#include <linux/slab.h> 40#include <linux/slab.h>
42#include <linux/pci_ids.h> 41#include <linux/pci_ids.h>
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 328cfc1eed95..cbf4f8038cba 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -13,7 +13,6 @@
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/init.h>
17#include <linux/input/matrix_keypad.h> 16#include <linux/input/matrix_keypad.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
19#include <linux/io.h> 18#include <linux/io.h>
@@ -425,7 +424,8 @@ MODULE_DEVICE_TABLE(of, imx_keypad_of_match);
425 424
426static int imx_keypad_probe(struct platform_device *pdev) 425static int imx_keypad_probe(struct platform_device *pdev)
427{ 426{
428 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data; 427 const struct matrix_keymap_data *keymap_data =
428 dev_get_platdata(&pdev->dev);
429 struct imx_keypad *keypad; 429 struct imx_keypad *keypad;
430 struct input_dev *input_dev; 430 struct input_dev *input_dev;
431 struct resource *res; 431 struct resource *res;
diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c
index a2a034c25f0b..69b1f002ff52 100644
--- a/drivers/input/keyboard/jornada680_kbd.c
+++ b/drivers/input/keyboard/jornada680_kbd.c
@@ -16,7 +16,6 @@
16 * published by the Free Software Foundation. 16 * published by the Free Software Foundation.
17 */ 17 */
18 18
19#include <linux/init.h>
20#include <linux/input.h> 19#include <linux/input.h>
21#include <linux/input-polldev.h> 20#include <linux/input-polldev.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
diff --git a/drivers/input/keyboard/jornada720_kbd.c b/drivers/input/keyboard/jornada720_kbd.c
index b0ad457ca9d8..cd729d485e98 100644
--- a/drivers/input/keyboard/jornada720_kbd.c
+++ b/drivers/input/keyboard/jornada720_kbd.c
@@ -18,7 +18,6 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/init.h>
22#include <linux/input.h> 21#include <linux/input.h>
23#include <linux/kernel.h> 22#include <linux/kernel.h>
24#include <linux/module.h> 23#include <linux/module.h>
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index fc0a63c2f278..9fcd9f1d5dc8 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -65,7 +65,6 @@
65#include <linux/slab.h> 65#include <linux/slab.h>
66#include <linux/module.h> 66#include <linux/module.h>
67#include <linux/interrupt.h> 67#include <linux/interrupt.h>
68#include <linux/init.h>
69#include <linux/input.h> 68#include <linux/input.h>
70#include <linux/serio.h> 69#include <linux/serio.h>
71#include <linux/workqueue.h> 70#include <linux/workqueue.h>
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index 0de23f41b2d3..0b42118cbf8f 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -627,7 +627,7 @@ static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable);
627static int lm8323_probe(struct i2c_client *client, 627static int lm8323_probe(struct i2c_client *client,
628 const struct i2c_device_id *id) 628 const struct i2c_device_id *id)
629{ 629{
630 struct lm8323_platform_data *pdata = client->dev.platform_data; 630 struct lm8323_platform_data *pdata = dev_get_platdata(&client->dev);
631 struct input_dev *idev; 631 struct input_dev *idev;
632 struct lm8323_chip *lm; 632 struct lm8323_chip *lm;
633 int pwm; 633 int pwm;
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
index 5a8ca35dc9af..9081cbef11ea 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -131,7 +131,8 @@ static irqreturn_t lm8333_irq_thread(int irq, void *data)
131static int lm8333_probe(struct i2c_client *client, 131static int lm8333_probe(struct i2c_client *client,
132 const struct i2c_device_id *id) 132 const struct i2c_device_id *id)
133{ 133{
134 const struct lm8333_platform_data *pdata = client->dev.platform_data; 134 const struct lm8333_platform_data *pdata =
135 dev_get_platdata(&client->dev);
135 struct lm8333 *lm8333; 136 struct lm8333 *lm8333;
136 struct input_dev *input; 137 struct input_dev *input;
137 int err, active_time; 138 int err, active_time;
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 90ff73ace424..8d2e19e81e1e 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -14,7 +14,6 @@
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/init.h>
18#include <linux/input.h> 17#include <linux/input.h>
19#include <linux/irq.h> 18#include <linux/irq.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index bc2cdaf563fd..430b54539720 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -182,7 +182,8 @@ static void max7359_initialize(struct i2c_client *client)
182static int max7359_probe(struct i2c_client *client, 182static int max7359_probe(struct i2c_client *client,
183 const struct i2c_device_id *id) 183 const struct i2c_device_id *id)
184{ 184{
185 const struct matrix_keymap_data *keymap_data = client->dev.platform_data; 185 const struct matrix_keymap_data *keymap_data =
186 dev_get_platdata(&client->dev);
186 struct max7359_keypad *keypad; 187 struct max7359_keypad *keypad;
187 struct input_dev *input_dev; 188 struct input_dev *input_dev;
188 int ret; 189 int ret;
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 7c236f9c6a51..1da8e0b44b56 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/i2c.h> 15#include <linux/i2c.h>
17#include <linux/i2c/mcs.h> 16#include <linux/i2c/mcs.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
@@ -108,7 +107,7 @@ static int mcs_touchkey_probe(struct i2c_client *client,
108 int error; 107 int error;
109 int i; 108 int i;
110 109
111 pdata = client->dev.platform_data; 110 pdata = dev_get_platdata(&client->dev);
112 if (!pdata) { 111 if (!pdata) {
113 dev_err(&client->dev, "no platform data defined\n"); 112 dev_err(&client->dev, "no platform data defined\n");
114 return -EINVAL; 113 return -EINVAL;
diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c
index f7f3e9a9fd3f..009c82256e89 100644
--- a/drivers/input/keyboard/mpr121_touchkey.c
+++ b/drivers/input/keyboard/mpr121_touchkey.c
@@ -13,7 +13,6 @@
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/input.h> 16#include <linux/input.h>
18#include <linux/i2c.h> 17#include <linux/i2c.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
@@ -188,7 +187,8 @@ err_i2c_write:
188static int mpr_touchkey_probe(struct i2c_client *client, 187static int mpr_touchkey_probe(struct i2c_client *client,
189 const struct i2c_device_id *id) 188 const struct i2c_device_id *id)
190{ 189{
191 const struct mpr121_platform_data *pdata = client->dev.platform_data; 190 const struct mpr121_platform_data *pdata =
191 dev_get_platdata(&client->dev);
192 struct mpr121_touchkey *mpr121; 192 struct mpr121_touchkey *mpr121;
193 struct input_dev *input_dev; 193 struct input_dev *input_dev;
194 int error; 194 int error;
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
index f971898ad591..20f044377990 100644
--- a/drivers/input/keyboard/newtonkbd.c
+++ b/drivers/input/keyboard/newtonkbd.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/init.h>
33#include <linux/serio.h> 32#include <linux/serio.h>
34 33
35#define DRIVER_DESC "Newton keyboard driver" 34#define DRIVER_DESC "Newton keyboard driver"
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index c7d505cce72f..63332e2f8628 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -222,7 +222,8 @@ static irqreturn_t ske_keypad_irq(int irq, void *dev_id)
222 222
223static int __init ske_keypad_probe(struct platform_device *pdev) 223static int __init ske_keypad_probe(struct platform_device *pdev)
224{ 224{
225 const struct ske_keypad_platform_data *plat = pdev->dev.platform_data; 225 const struct ske_keypad_platform_data *plat =
226 dev_get_platdata(&pdev->dev);
226 struct ske_keypad *keypad; 227 struct ske_keypad *keypad;
227 struct input_dev *input; 228 struct input_dev *input;
228 struct resource *res; 229 struct resource *res;
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index d0d5226d9cd4..b1acc9852eb7 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -25,7 +25,6 @@
25 */ 25 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
30#include <linux/types.h> 29#include <linux/types.h>
31#include <linux/input.h> 30#include <linux/input.h>
@@ -248,7 +247,7 @@ static int omap_kp_probe(struct platform_device *pdev)
248{ 247{
249 struct omap_kp *omap_kp; 248 struct omap_kp *omap_kp;
250 struct input_dev *input_dev; 249 struct input_dev *input_dev;
251 struct omap_kp_platform_data *pdata = pdev->dev.platform_data; 250 struct omap_kp_platform_data *pdata = dev_get_platdata(&pdev->dev);
252 int i, col_idx, row_idx, ret; 251 int i, col_idx, row_idx, ret;
253 unsigned int row_shift, keycodemax; 252 unsigned int row_shift, keycodemax;
254 253
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 30acfd49fa6c..0400b3f2b4b9 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/platform_device.h> 26#include <linux/platform_device.h>
28#include <linux/errno.h> 27#include <linux/errno.h>
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 186138c720c7..d8241ba0afa0 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -18,7 +18,6 @@
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23#include <linux/input.h> 22#include <linux/input.h>
24#include <linux/device.h> 23#include <linux/device.h>
diff --git a/drivers/input/keyboard/pxa930_rotary.c b/drivers/input/keyboard/pxa930_rotary.c
index 248cdcf95296..374ca0246c8f 100644
--- a/drivers/input/keyboard/pxa930_rotary.c
+++ b/drivers/input/keyboard/pxa930_rotary.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
13#include <linux/input.h> 12#include <linux/input.h>
14#include <linux/platform_device.h> 13#include <linux/platform_device.h>
@@ -84,7 +83,8 @@ static void pxa930_rotary_close(struct input_dev *dev)
84 83
85static int pxa930_rotary_probe(struct platform_device *pdev) 84static int pxa930_rotary_probe(struct platform_device *pdev)
86{ 85{
87 struct pxa930_rotary_platform_data *pdata = pdev->dev.platform_data; 86 struct pxa930_rotary_platform_data *pdata =
87 dev_get_platdata(&pdev->dev);
88 struct pxa930_rotary *r; 88 struct pxa930_rotary *r;
89 struct input_dev *input_dev; 89 struct input_dev *input_dev;
90 struct resource *res; 90 struct resource *res;
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
index 6c561ec3cc09..52cd6e88acd7 100644
--- a/drivers/input/keyboard/qt1070.c
+++ b/drivers/input/keyboard/qt1070.c
@@ -25,7 +25,6 @@
25 */ 25 */
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/i2c.h> 28#include <linux/i2c.h>
30#include <linux/input.h> 29#include <linux/input.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index 1c0ddad0a1cc..819b22897c13 100644
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/leds.h> 22#include <linux/leds.h>
24#include <linux/module.h> 23#include <linux/module.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index ac43a486c775..5e80fbf7b5ed 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -14,7 +14,6 @@
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/init.h>
18#include <linux/input.h> 17#include <linux/input.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/io.h> 19#include <linux/io.h>
@@ -244,8 +243,8 @@ static void samsung_keypad_close(struct input_dev *input_dev)
244} 243}
245 244
246#ifdef CONFIG_OF 245#ifdef CONFIG_OF
247static struct samsung_keypad_platdata *samsung_keypad_parse_dt( 246static struct samsung_keypad_platdata *
248 struct device *dev) 247samsung_keypad_parse_dt(struct device *dev)
249{ 248{
250 struct samsung_keypad_platdata *pdata; 249 struct samsung_keypad_platdata *pdata;
251 struct matrix_keymap_data *keymap_data; 250 struct matrix_keymap_data *keymap_data;
@@ -253,17 +252,22 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt(
253 struct device_node *np = dev->of_node, *key_np; 252 struct device_node *np = dev->of_node, *key_np;
254 unsigned int key_count; 253 unsigned int key_count;
255 254
255 if (!np) {
256 dev_err(dev, "missing device tree data\n");
257 return ERR_PTR(-EINVAL);
258 }
259
256 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 260 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
257 if (!pdata) { 261 if (!pdata) {
258 dev_err(dev, "could not allocate memory for platform data\n"); 262 dev_err(dev, "could not allocate memory for platform data\n");
259 return NULL; 263 return ERR_PTR(-ENOMEM);
260 } 264 }
261 265
262 of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows); 266 of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows);
263 of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols); 267 of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols);
264 if (!num_rows || !num_cols) { 268 if (!num_rows || !num_cols) {
265 dev_err(dev, "number of keypad rows/columns not specified\n"); 269 dev_err(dev, "number of keypad rows/columns not specified\n");
266 return NULL; 270 return ERR_PTR(-EINVAL);
267 } 271 }
268 pdata->rows = num_rows; 272 pdata->rows = num_rows;
269 pdata->cols = num_cols; 273 pdata->cols = num_cols;
@@ -271,7 +275,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt(
271 keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL); 275 keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL);
272 if (!keymap_data) { 276 if (!keymap_data) {
273 dev_err(dev, "could not allocate memory for keymap data\n"); 277 dev_err(dev, "could not allocate memory for keymap data\n");
274 return NULL; 278 return ERR_PTR(-ENOMEM);
275 } 279 }
276 pdata->keymap_data = keymap_data; 280 pdata->keymap_data = keymap_data;
277 281
@@ -280,7 +284,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt(
280 keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); 284 keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
281 if (!keymap) { 285 if (!keymap) {
282 dev_err(dev, "could not allocate memory for keymap\n"); 286 dev_err(dev, "could not allocate memory for keymap\n");
283 return NULL; 287 return ERR_PTR(-ENOMEM);
284 } 288 }
285 keymap_data->keymap = keymap; 289 keymap_data->keymap = keymap;
286 290
@@ -294,16 +298,19 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt(
294 298
295 if (of_get_property(np, "linux,input-no-autorepeat", NULL)) 299 if (of_get_property(np, "linux,input-no-autorepeat", NULL))
296 pdata->no_autorepeat = true; 300 pdata->no_autorepeat = true;
301
297 if (of_get_property(np, "linux,input-wakeup", NULL)) 302 if (of_get_property(np, "linux,input-wakeup", NULL))
298 pdata->wakeup = true; 303 pdata->wakeup = true;
299 304
300 return pdata; 305 return pdata;
301} 306}
302#else 307#else
303static 308static struct samsung_keypad_platdata *
304struct samsung_keypad_platdata *samsung_keypad_parse_dt(struct device *dev) 309samsung_keypad_parse_dt(struct device *dev)
305{ 310{
306 return NULL; 311 dev_err(dev, "no platform data defined\n");
312
313 return ERR_PTR(-EINVAL);
307} 314}
308#endif 315#endif
309 316
@@ -318,13 +325,11 @@ static int samsung_keypad_probe(struct platform_device *pdev)
318 unsigned int keymap_size; 325 unsigned int keymap_size;
319 int error; 326 int error;
320 327
321 if (pdev->dev.of_node) 328 pdata = dev_get_platdata(&pdev->dev);
322 pdata = samsung_keypad_parse_dt(&pdev->dev);
323 else
324 pdata = pdev->dev.platform_data;
325 if (!pdata) { 329 if (!pdata) {
326 dev_err(&pdev->dev, "no platform data defined\n"); 330 pdata = samsung_keypad_parse_dt(&pdev->dev);
327 return -EINVAL; 331 if (IS_ERR(pdata))
332 return PTR_ERR(pdata);
328 } 333 }
329 334
330 keymap_data = pdata->keymap_data; 335 keymap_data = pdata->keymap_data;
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index fe0e498d2479..7abf03b4cc9c 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
17#include <linux/irq.h> 16#include <linux/irq.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
@@ -171,7 +170,7 @@ static int sh_keysc_probe(struct platform_device *pdev)
171 int i; 170 int i;
172 int irq, error; 171 int irq, error;
173 172
174 if (!pdev->dev.platform_data) { 173 if (!dev_get_platdata(&pdev->dev)) {
175 dev_err(&pdev->dev, "no platform data defined\n"); 174 dev_err(&pdev->dev, "no platform data defined\n");
176 error = -EINVAL; 175 error = -EINVAL;
177 goto err0; 176 goto err0;
@@ -198,7 +197,7 @@ static int sh_keysc_probe(struct platform_device *pdev)
198 } 197 }
199 198
200 platform_set_drvdata(pdev, priv); 199 platform_set_drvdata(pdev, priv);
201 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); 200 memcpy(&priv->pdata, dev_get_platdata(&pdev->dev), sizeof(priv->pdata));
202 pdata = &priv->pdata; 201 pdata = &priv->pdata;
203 202
204 priv->iomem_base = ioremap_nocache(res->start, resource_size(res)); 203 priv->iomem_base = ioremap_nocache(res->start, resource_size(res));
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 85ff530d9a91..258af10e5811 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/init.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
17#include <linux/input.h> 16#include <linux/input.h>
18#include <linux/io.h> 17#include <linux/io.h>
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 5cbec56f7720..c6727dda68f2 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/init.h>
10#include <linux/slab.h> 9#include <linux/slab.h>
11#include <linux/input.h> 10#include <linux/input.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c
index cc612c5d5427..a6e0d565e306 100644
--- a/drivers/input/keyboard/stowaway.c
+++ b/drivers/input/keyboard/stowaway.c
@@ -32,7 +32,6 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/input.h> 34#include <linux/input.h>
35#include <linux/init.h>
36#include <linux/serio.h> 35#include <linux/serio.h>
37 36
38#define DRIVER_DESC "Stowaway keyboard driver" 37#define DRIVER_DESC "Stowaway keyboard driver"
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index 5f836b1638c1..dc6bb9d5b4f0 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -31,7 +31,6 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/init.h>
35#include <linux/input.h> 34#include <linux/input.h>
36#include <linux/serio.h> 35#include <linux/serio.h>
37#include <linux/workqueue.h> 36#include <linux/workqueue.h>
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index 208de7cbb7fa..74494a357522 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/interrupt.h> 13#include <linux/interrupt.h>
15#include <linux/input.h> 14#include <linux/input.h>
16#include <linux/platform_device.h> 15#include <linux/platform_device.h>
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index bfc832c35a7c..dc983ab6c0ad 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -213,7 +213,7 @@ static int tca6416_keypad_probe(struct i2c_client *client,
213 return -ENODEV; 213 return -ENODEV;
214 } 214 }
215 215
216 pdata = client->dev.platform_data; 216 pdata = dev_get_platdata(&client->dev);
217 if (!pdata) { 217 if (!pdata) {
218 dev_dbg(&client->dev, "no platform data\n"); 218 dev_dbg(&client->dev, "no platform data\n");
219 return -EINVAL; 219 return -EINVAL;
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c
index 8bd24d52bf1b..086511c2121b 100644
--- a/drivers/input/keyboard/tnetv107x-keypad.c
+++ b/drivers/input/keyboard/tnetv107x-keypad.c
@@ -162,7 +162,7 @@ static int keypad_probe(struct platform_device *pdev)
162 int error = 0, sz, row_shift; 162 int error = 0, sz, row_shift;
163 u32 rev = 0; 163 u32 rev = 0;
164 164
165 pdata = pdev->dev.platform_data; 165 pdata = dev_get_platdata(&pdev->dev);
166 if (!pdata) { 166 if (!pdata) {
167 dev_err(dev, "cannot find device data\n"); 167 dev_err(dev, "cannot find device data\n");
168 return -EINVAL; 168 return -EINVAL;
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index d2d178c84ea7..c5a11700a1bf 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -27,12 +27,12 @@
27 27
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/interrupt.h> 30#include <linux/interrupt.h>
32#include <linux/input.h> 31#include <linux/input.h>
33#include <linux/platform_device.h> 32#include <linux/platform_device.h>
34#include <linux/i2c/twl.h> 33#include <linux/i2c/twl.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/of.h>
36 36
37/* 37/*
38 * The TWL4030 family chips include a keypad controller that supports 38 * The TWL4030 family chips include a keypad controller that supports
@@ -60,6 +60,7 @@
60struct twl4030_keypad { 60struct twl4030_keypad {
61 unsigned short keymap[TWL4030_KEYMAP_SIZE]; 61 unsigned short keymap[TWL4030_KEYMAP_SIZE];
62 u16 kp_state[TWL4030_MAX_ROWS]; 62 u16 kp_state[TWL4030_MAX_ROWS];
63 bool autorepeat;
63 unsigned n_rows; 64 unsigned n_rows;
64 unsigned n_cols; 65 unsigned n_cols;
65 unsigned irq; 66 unsigned irq;
@@ -330,70 +331,89 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
330 */ 331 */
331static int twl4030_kp_probe(struct platform_device *pdev) 332static int twl4030_kp_probe(struct platform_device *pdev)
332{ 333{
333 struct twl4030_keypad_data *pdata = pdev->dev.platform_data; 334 struct twl4030_keypad_data *pdata = dev_get_platdata(&pdev->dev);
334 const struct matrix_keymap_data *keymap_data; 335 const struct matrix_keymap_data *keymap_data = NULL;
335 struct twl4030_keypad *kp; 336 struct twl4030_keypad *kp;
336 struct input_dev *input; 337 struct input_dev *input;
337 u8 reg; 338 u8 reg;
338 int error; 339 int error;
339 340
340 if (!pdata || !pdata->rows || !pdata->cols || !pdata->keymap_data || 341 kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
341 pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) { 342 if (!kp)
342 dev_err(&pdev->dev, "Invalid platform_data\n"); 343 return -ENOMEM;
343 return -EINVAL;
344 }
345 344
346 keymap_data = pdata->keymap_data; 345 input = devm_input_allocate_device(&pdev->dev);
347 346 if (!input)
348 kp = kzalloc(sizeof(*kp), GFP_KERNEL); 347 return -ENOMEM;
349 input = input_allocate_device();
350 if (!kp || !input) {
351 error = -ENOMEM;
352 goto err1;
353 }
354 348
355 /* Get the debug Device */ 349 /* get the debug device */
356 kp->dbg_dev = &pdev->dev; 350 kp->dbg_dev = &pdev->dev;
357 kp->input = input; 351 kp->input = input;
358
359 kp->n_rows = pdata->rows;
360 kp->n_cols = pdata->cols;
361 kp->irq = platform_get_irq(pdev, 0);
362 352
363 /* setup input device */ 353 /* setup input device */
364 input->name = "TWL4030 Keypad"; 354 input->name = "TWL4030 Keypad";
365 input->phys = "twl4030_keypad/input0"; 355 input->phys = "twl4030_keypad/input0";
366 input->dev.parent = &pdev->dev;
367 356
368 input->id.bustype = BUS_HOST; 357 input->id.bustype = BUS_HOST;
369 input->id.vendor = 0x0001; 358 input->id.vendor = 0x0001;
370 input->id.product = 0x0001; 359 input->id.product = 0x0001;
371 input->id.version = 0x0003; 360 input->id.version = 0x0003;
372 361
362 if (pdata) {
363 if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
364 dev_err(&pdev->dev, "Missing platform_data\n");
365 return -EINVAL;
366 }
367
368 kp->n_rows = pdata->rows;
369 kp->n_cols = pdata->cols;
370 kp->autorepeat = pdata->rep;
371 keymap_data = pdata->keymap_data;
372 } else {
373 error = matrix_keypad_parse_of_params(&pdev->dev, &kp->n_rows,
374 &kp->n_cols);
375 if (error)
376 return error;
377
378 kp->autorepeat = true;
379 }
380
381 if (kp->n_rows > TWL4030_MAX_ROWS || kp->n_cols > TWL4030_MAX_COLS) {
382 dev_err(&pdev->dev,
383 "Invalid rows/cols amount specified in platform/devicetree data\n");
384 return -EINVAL;
385 }
386
387 kp->irq = platform_get_irq(pdev, 0);
388 if (!kp->irq) {
389 dev_err(&pdev->dev, "no keyboard irq assigned\n");
390 return -EINVAL;
391 }
392
373 error = matrix_keypad_build_keymap(keymap_data, NULL, 393 error = matrix_keypad_build_keymap(keymap_data, NULL,
374 TWL4030_MAX_ROWS, 394 TWL4030_MAX_ROWS,
375 1 << TWL4030_ROW_SHIFT, 395 1 << TWL4030_ROW_SHIFT,
376 kp->keymap, input); 396 kp->keymap, input);
377 if (error) { 397 if (error) {
378 dev_err(kp->dbg_dev, "Failed to build keymap\n"); 398 dev_err(kp->dbg_dev, "Failed to build keymap\n");
379 goto err1; 399 return error;
380 } 400 }
381 401
382 input_set_capability(input, EV_MSC, MSC_SCAN); 402 input_set_capability(input, EV_MSC, MSC_SCAN);
383 /* Enable auto repeat feature of Linux input subsystem */ 403 /* Enable auto repeat feature of Linux input subsystem */
384 if (pdata->rep) 404 if (kp->autorepeat)
385 __set_bit(EV_REP, input->evbit); 405 __set_bit(EV_REP, input->evbit);
386 406
387 error = input_register_device(input); 407 error = input_register_device(input);
388 if (error) { 408 if (error) {
389 dev_err(kp->dbg_dev, 409 dev_err(kp->dbg_dev,
390 "Unable to register twl4030 keypad device\n"); 410 "Unable to register twl4030 keypad device\n");
391 goto err1; 411 return error;
392 } 412 }
393 413
394 error = twl4030_kp_program(kp); 414 error = twl4030_kp_program(kp);
395 if (error) 415 if (error)
396 goto err2; 416 return error;
397 417
398 /* 418 /*
399 * This ISR will always execute in kernel thread context because of 419 * This ISR will always execute in kernel thread context because of
@@ -401,47 +421,33 @@ static int twl4030_kp_probe(struct platform_device *pdev)
401 * 421 *
402 * NOTE: we assume this host is wired to TWL4040 INT1, not INT2 ... 422 * NOTE: we assume this host is wired to TWL4040 INT1, not INT2 ...
403 */ 423 */
404 error = request_threaded_irq(kp->irq, NULL, do_kp_irq, 424 error = devm_request_threaded_irq(&pdev->dev, kp->irq, NULL, do_kp_irq,
405 0, pdev->name, kp); 425 0, pdev->name, kp);
406 if (error) { 426 if (error) {
407 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d\n", 427 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d: %d\n",
408 kp->irq); 428 kp->irq, error);
409 goto err2; 429 return error;
410 } 430 }
411 431
412 /* Enable KP and TO interrupts now. */ 432 /* Enable KP and TO interrupts now. */
413 reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO); 433 reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO);
414 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) { 434 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) {
415 error = -EIO; 435 /* mask all events - we don't care about the result */
416 goto err3; 436 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);
437 return -EIO;
417 } 438 }
418 439
419 platform_set_drvdata(pdev, kp); 440 platform_set_drvdata(pdev, kp);
420 return 0; 441 return 0;
421
422err3:
423 /* mask all events - we don't care about the result */
424 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);
425 free_irq(kp->irq, kp);
426err2:
427 input_unregister_device(input);
428 input = NULL;
429err1:
430 input_free_device(input);
431 kfree(kp);
432 return error;
433} 442}
434 443
435static int twl4030_kp_remove(struct platform_device *pdev) 444#ifdef CONFIG_OF
436{ 445static const struct of_device_id twl4030_keypad_dt_match_table[] = {
437 struct twl4030_keypad *kp = platform_get_drvdata(pdev); 446 { .compatible = "ti,twl4030-keypad" },
438 447 {},
439 free_irq(kp->irq, kp); 448};
440 input_unregister_device(kp->input); 449MODULE_DEVICE_TABLE(of, twl4030_keypad_dt_match_table);
441 kfree(kp); 450#endif
442
443 return 0;
444}
445 451
446/* 452/*
447 * NOTE: twl4030 are multi-function devices connected via I2C. 453 * NOTE: twl4030 are multi-function devices connected via I2C.
@@ -451,10 +457,10 @@ static int twl4030_kp_remove(struct platform_device *pdev)
451 457
452static struct platform_driver twl4030_kp_driver = { 458static struct platform_driver twl4030_kp_driver = {
453 .probe = twl4030_kp_probe, 459 .probe = twl4030_kp_probe,
454 .remove = twl4030_kp_remove,
455 .driver = { 460 .driver = {
456 .name = "twl4030_keypad", 461 .name = "twl4030_keypad",
457 .owner = THIS_MODULE, 462 .owner = THIS_MODULE,
463 .of_match_table = of_match_ptr(twl4030_keypad_dt_match_table),
458 }, 464 },
459}; 465};
460module_platform_driver(twl4030_kp_driver); 466module_platform_driver(twl4030_kp_driver);
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c
index 7b039162a3f8..e8b9d94daae7 100644
--- a/drivers/input/keyboard/w90p910_keypad.c
+++ b/drivers/input/keyboard/w90p910_keypad.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/interrupt.h> 14#include <linux/interrupt.h>
16#include <linux/input.h> 15#include <linux/input.h>
17#include <linux/device.h> 16#include <linux/device.h>
@@ -121,7 +120,7 @@ static void w90p910_keypad_close(struct input_dev *dev)
121static int w90p910_keypad_probe(struct platform_device *pdev) 120static int w90p910_keypad_probe(struct platform_device *pdev)
122{ 121{
123 const struct w90p910_keypad_platform_data *pdata = 122 const struct w90p910_keypad_platform_data *pdata =
124 pdev->dev.platform_data; 123 dev_get_platdata(&pdev->dev);
125 const struct matrix_keymap_data *keymap_data; 124 const struct matrix_keymap_data *keymap_data;
126 struct w90p910_keypad *keypad; 125 struct w90p910_keypad *keypad;
127 struct input_dev *input_dev; 126 struct input_dev *input_dev;
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index d050d9d0011b..7c2325bd7408 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/init.h>
33#include <linux/serio.h> 32#include <linux/serio.h>
34 33
35#define DRIVER_DESC "XT keyboard driver" 34#define DRIVER_DESC "XT keyboard driver"
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index e2413acbbb16..7904ab05527a 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -222,6 +222,15 @@ config INPUT_GP2A
222 To compile this driver as a module, choose M here: the 222 To compile this driver as a module, choose M here: the
223 module will be called gp2ap002a00f. 223 module will be called gp2ap002a00f.
224 224
225config INPUT_GPIO_BEEPER
226 tristate "Generic GPIO Beeper support"
227 depends on OF_GPIO
228 help
229 Say Y here if you have a beeper connected to a GPIO pin.
230
231 To compile this driver as a module, choose M here: the
232 module will be called gpio-beeper.
233
225config INPUT_GPIO_TILT_POLLED 234config INPUT_GPIO_TILT_POLLED
226 tristate "Polled GPIO tilt switch" 235 tristate "Polled GPIO tilt switch"
227 depends on GPIOLIB 236 depends on GPIOLIB
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 0ebfb6dbf0f7..cda71fc52fb3 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o
27obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o 27obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o
28obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o 28obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o
29obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o 29obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o
30obj-$(CONFIG_INPUT_GPIO_BEEPER) += gpio-beeper.o
30obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o 31obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o
31obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 32obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
32obj-$(CONFIG_INPUT_IMS_PCU) += ims-pcu.o 33obj-$(CONFIG_INPUT_IMS_PCU) += ims-pcu.o
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c
index 2e5d5e1de647..7a61e9ee682c 100644
--- a/drivers/input/misc/ad714x.c
+++ b/drivers/input/misc/ad714x.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/device.h> 9#include <linux/device.h>
10#include <linux/init.h>
11#include <linux/input.h> 10#include <linux/input.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
13#include <linux/slab.h> 12#include <linux/slab.h>
@@ -969,7 +968,7 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
969 int error; 968 int error;
970 struct input_dev *input[MAX_DEVICE_NUM]; 969 struct input_dev *input[MAX_DEVICE_NUM];
971 970
972 struct ad714x_platform_data *plat_data = dev->platform_data; 971 struct ad714x_platform_data *plat_data = dev_get_platdata(dev);
973 struct ad714x_chip *ad714x; 972 struct ad714x_chip *ad714x;
974 void *drv_mem; 973 void *drv_mem;
975 unsigned long irqflags; 974 unsigned long irqflags;
@@ -986,7 +985,7 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
986 goto err_out; 985 goto err_out;
987 } 986 }
988 987
989 if (dev->platform_data == NULL) { 988 if (dev_get_platdata(dev) == NULL) {
990 dev_err(dev, "platform data for ad714x doesn't exist\n"); 989 dev_err(dev, "platform data for ad714x doesn't exist\n");
991 error = -EINVAL; 990 error = -EINVAL;
992 goto err_out; 991 goto err_out;
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index 1cb1da294419..2b2d02f408bb 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/init.h>
12#include <linux/delay.h> 11#include <linux/delay.h>
13#include <linux/input.h> 12#include <linux/input.h>
14#include <linux/interrupt.h> 13#include <linux/interrupt.h>
@@ -714,7 +713,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
714 713
715 ac->fifo_delay = fifo_delay_default; 714 ac->fifo_delay = fifo_delay_default;
716 715
717 pdata = dev->platform_data; 716 pdata = dev_get_platdata(dev);
718 if (!pdata) { 717 if (!pdata) {
719 dev_dbg(dev, 718 dev_dbg(dev,
720 "No platform data: Using default initialization\n"); 719 "No platform data: Using default initialization\n");
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index d781b5e52065..638165c78e75 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/input.h> 28#include <linux/input.h>
30#include <linux/types.h> 29#include <linux/types.h>
31#include <linux/acpi.h> 30#include <linux/acpi.h>
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c
index cd139cb17e32..e69d9bcb37e1 100644
--- a/drivers/input/misc/bfin_rotary.c
+++ b/drivers/input/misc/bfin_rotary.c
@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/init.h>
10#include <linux/interrupt.h> 9#include <linux/interrupt.h>
11#include <linux/irq.h> 10#include <linux/irq.h>
12#include <linux/pm.h> 11#include <linux/pm.h>
@@ -92,7 +91,7 @@ static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
92 91
93static int bfin_rotary_probe(struct platform_device *pdev) 92static int bfin_rotary_probe(struct platform_device *pdev)
94{ 93{
95 struct bfin_rotary_platform_data *pdata = pdev->dev.platform_data; 94 struct bfin_rotary_platform_data *pdata = dev_get_platdata(&pdev->dev);
96 struct bfin_rot *rotary; 95 struct bfin_rot *rotary;
97 struct input_dev *input; 96 struct input_dev *input;
98 int error; 97 int error;
diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c
index 865c2f9d25b9..52d3a9b28f0b 100644
--- a/drivers/input/misc/bma150.c
+++ b/drivers/input/misc/bma150.c
@@ -526,7 +526,8 @@ static int bma150_register_polled_device(struct bma150_data *bma150)
526static int bma150_probe(struct i2c_client *client, 526static int bma150_probe(struct i2c_client *client,
527 const struct i2c_device_id *id) 527 const struct i2c_device_id *id)
528{ 528{
529 const struct bma150_platform_data *pdata = client->dev.platform_data; 529 const struct bma150_platform_data *pdata =
530 dev_get_platdata(&client->dev);
530 const struct bma150_cfg *cfg; 531 const struct bma150_cfg *cfg;
531 struct bma150_data *bma150; 532 struct bma150_data *bma150;
532 int chip_id; 533 int chip_id;
diff --git a/drivers/input/misc/cma3000_d0x.c b/drivers/input/misc/cma3000_d0x.c
index df9b756594f8..c7d00748277b 100644
--- a/drivers/input/misc/cma3000_d0x.c
+++ b/drivers/input/misc/cma3000_d0x.c
@@ -284,7 +284,7 @@ EXPORT_SYMBOL(cma3000_resume);
284struct cma3000_accl_data *cma3000_init(struct device *dev, int irq, 284struct cma3000_accl_data *cma3000_init(struct device *dev, int irq,
285 const struct cma3000_bus_ops *bops) 285 const struct cma3000_bus_ops *bops)
286{ 286{
287 const struct cma3000_platform_data *pdata = dev->platform_data; 287 const struct cma3000_platform_data *pdata = dev_get_platdata(dev);
288 struct cma3000_accl_data *data; 288 struct cma3000_accl_data *data;
289 struct input_dev *input_dev; 289 struct input_dev *input_dev;
290 int rev; 290 int rev;
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
index b5d71d245854..3e11510ff82d 100644
--- a/drivers/input/misc/cobalt_btns.c
+++ b/drivers/input/misc/cobalt_btns.c
@@ -17,7 +17,6 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20#include <linux/init.h>
21#include <linux/input-polldev.h> 20#include <linux/input-polldev.h>
22#include <linux/ioport.h> 21#include <linux/ioport.h>
23#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 020569a499f2..1f695f229ea8 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -11,7 +11,6 @@
11 * option) any later version. 11 * option) any later version.
12 */ 12 */
13 13
14#include <linux/init.h>
15#include <linux/input.h> 14#include <linux/input.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c
index a0af8b2506ce..4b11ede34950 100644
--- a/drivers/input/misc/da9055_onkey.c
+++ b/drivers/input/misc/da9055_onkey.c
@@ -11,7 +11,6 @@
11 * option) any later version. 11 * option) any later version.
12 */ 12 */
13 13
14#include <linux/init.h>
15#include <linux/input.h> 14#include <linux/input.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c
index a309a5c0899e..0eba94f581df 100644
--- a/drivers/input/misc/dm355evm_keys.c
+++ b/drivers/input/misc/dm355evm_keys.c
@@ -9,7 +9,6 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/slab.h> 12#include <linux/slab.h>
14#include <linux/input.h> 13#include <linux/input.h>
15#include <linux/input/sparse-keymap.h> 14#include <linux/input/sparse-keymap.h>
diff --git a/drivers/input/misc/gp2ap002a00f.c b/drivers/input/misc/gp2ap002a00f.c
index fe30bd0fe4bd..de21e317da32 100644
--- a/drivers/input/misc/gp2ap002a00f.c
+++ b/drivers/input/misc/gp2ap002a00f.c
@@ -125,7 +125,7 @@ static int gp2a_initialize(struct gp2a_data *dt)
125static int gp2a_probe(struct i2c_client *client, 125static int gp2a_probe(struct i2c_client *client,
126 const struct i2c_device_id *id) 126 const struct i2c_device_id *id)
127{ 127{
128 const struct gp2a_platform_data *pdata = client->dev.platform_data; 128 const struct gp2a_platform_data *pdata = dev_get_platdata(&client->dev);
129 struct gp2a_data *dt; 129 struct gp2a_data *dt;
130 int error; 130 int error;
131 131
diff --git a/drivers/input/misc/gpio-beeper.c b/drivers/input/misc/gpio-beeper.c
new file mode 100644
index 000000000000..b757435e2b3d
--- /dev/null
+++ b/drivers/input/misc/gpio-beeper.c
@@ -0,0 +1,127 @@
1/*
2 * Generic GPIO beeper driver
3 *
4 * Copyright (C) 2013 Alexander Shiyan <shc_work@mail.ru>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/input.h>
13#include <linux/module.h>
14#include <linux/of_gpio.h>
15#include <linux/workqueue.h>
16#include <linux/platform_device.h>
17
18#define BEEPER_MODNAME "gpio-beeper"
19
20struct gpio_beeper {
21 struct work_struct work;
22 int gpio;
23 bool active_low;
24 bool beeping;
25};
26
27static void gpio_beeper_toggle(struct gpio_beeper *beep, bool on)
28{
29 gpio_set_value_cansleep(beep->gpio, on ^ beep->active_low);
30}
31
32static void gpio_beeper_work(struct work_struct *work)
33{
34 struct gpio_beeper *beep = container_of(work, struct gpio_beeper, work);
35
36 gpio_beeper_toggle(beep, beep->beeping);
37}
38
39static int gpio_beeper_event(struct input_dev *dev, unsigned int type,
40 unsigned int code, int value)
41{
42 struct gpio_beeper *beep = input_get_drvdata(dev);
43
44 if (type != EV_SND || code != SND_BELL)
45 return -ENOTSUPP;
46
47 if (value < 0)
48 return -EINVAL;
49
50 beep->beeping = value;
51 /* Schedule work to actually turn the beeper on or off */
52 schedule_work(&beep->work);
53
54 return 0;
55}
56
57static void gpio_beeper_close(struct input_dev *input)
58{
59 struct gpio_beeper *beep = input_get_drvdata(input);
60
61 cancel_work_sync(&beep->work);
62 gpio_beeper_toggle(beep, false);
63}
64
65static int gpio_beeper_probe(struct platform_device *pdev)
66{
67 struct gpio_beeper *beep;
68 enum of_gpio_flags flags;
69 struct input_dev *input;
70 unsigned long gflags;
71 int err;
72
73 beep = devm_kzalloc(&pdev->dev, sizeof(*beep), GFP_KERNEL);
74 if (!beep)
75 return -ENOMEM;
76
77 beep->gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
78 if (!gpio_is_valid(beep->gpio))
79 return beep->gpio;
80
81 input = devm_input_allocate_device(&pdev->dev);
82 if (!input)
83 return -ENOMEM;
84
85 INIT_WORK(&beep->work, gpio_beeper_work);
86
87 input->name = pdev->name;
88 input->id.bustype = BUS_HOST;
89 input->id.vendor = 0x0001;
90 input->id.product = 0x0001;
91 input->id.version = 0x0100;
92 input->close = gpio_beeper_close;
93 input->event = gpio_beeper_event;
94
95 input_set_capability(input, EV_SND, SND_BELL);
96
97 beep->active_low = flags & OF_GPIO_ACTIVE_LOW;
98 gflags = beep->active_low ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
99
100 err = devm_gpio_request_one(&pdev->dev, beep->gpio, gflags, pdev->name);
101 if (err)
102 return err;
103
104 input_set_drvdata(input, beep);
105
106 return input_register_device(input);
107}
108
109static struct of_device_id gpio_beeper_of_match[] = {
110 { .compatible = BEEPER_MODNAME, },
111 { }
112};
113MODULE_DEVICE_TABLE(of, gpio_beeper_of_match);
114
115static struct platform_driver gpio_beeper_platform_driver = {
116 .driver = {
117 .name = BEEPER_MODNAME,
118 .owner = THIS_MODULE,
119 .of_match_table = gpio_beeper_of_match,
120 },
121 .probe = gpio_beeper_probe,
122};
123module_platform_driver(gpio_beeper_platform_driver);
124
125MODULE_LICENSE("GPL");
126MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>");
127MODULE_DESCRIPTION("Generic GPIO beeper driver");
diff --git a/drivers/input/misc/gpio_tilt_polled.c b/drivers/input/misc/gpio_tilt_polled.c
index 714c68369134..1a81d9115226 100644
--- a/drivers/input/misc/gpio_tilt_polled.c
+++ b/drivers/input/misc/gpio_tilt_polled.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include <linux/input.h> 20#include <linux/input.h>
22#include <linux/input-polldev.h> 21#include <linux/input-polldev.h>
@@ -98,7 +97,8 @@ static void gpio_tilt_polled_close(struct input_polled_dev *dev)
98 97
99static int gpio_tilt_polled_probe(struct platform_device *pdev) 98static int gpio_tilt_polled_probe(struct platform_device *pdev)
100{ 99{
101 const struct gpio_tilt_platform_data *pdata = pdev->dev.platform_data; 100 const struct gpio_tilt_platform_data *pdata =
101 dev_get_platdata(&pdev->dev);
102 struct device *dev = &pdev->dev; 102 struct device *dev = &pdev->dev;
103 struct gpio_tilt_polled_dev *tdev; 103 struct gpio_tilt_polled_dev *tdev;
104 struct input_polled_dev *poll_dev; 104 struct input_polled_dev *poll_dev;
diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c
index 290fa5f97ded..01f3b5b300f3 100644
--- a/drivers/input/misc/keyspan_remote.c
+++ b/drivers/input/misc/keyspan_remote.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/init.h>
17#include <linux/slab.h> 16#include <linux/slab.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/usb/input.h> 18#include <linux/usb/input.h>
diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c
index a993b67a8a5b..d708478bc5b5 100644
--- a/drivers/input/misc/kxtj9.c
+++ b/drivers/input/misc/kxtj9.c
@@ -509,7 +509,8 @@ out:
509static int kxtj9_probe(struct i2c_client *client, 509static int kxtj9_probe(struct i2c_client *client,
510 const struct i2c_device_id *id) 510 const struct i2c_device_id *id)
511{ 511{
512 const struct kxtj9_platform_data *pdata = client->dev.platform_data; 512 const struct kxtj9_platform_data *pdata =
513 dev_get_platdata(&client->dev);
513 struct kxtj9_data *tj9; 514 struct kxtj9_data *tj9;
514 int err; 515 int err;
515 516
diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
index e973133212a5..1fea5484941f 100644
--- a/drivers/input/misc/max8997_haptic.c
+++ b/drivers/input/misc/max8997_haptic.c
@@ -23,7 +23,6 @@
23 */ 23 */
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
28#include <linux/platform_device.h> 27#include <linux/platform_device.h>
29#include <linux/err.h> 28#include <linux/err.h>
diff --git a/drivers/input/misc/mc13783-pwrbutton.c b/drivers/input/misc/mc13783-pwrbutton.c
index d0277a7b1579..0df6e8d8bd03 100644
--- a/drivers/input/misc/mc13783-pwrbutton.c
+++ b/drivers/input/misc/mc13783-pwrbutton.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/errno.h> 24#include <linux/errno.h>
26#include <linux/input.h> 25#include <linux/input.h>
diff --git a/drivers/input/misc/mpu3050.c b/drivers/input/misc/mpu3050.c
index 6983ffbbfb94..5e5051351c3a 100644
--- a/drivers/input/misc/mpu3050.c
+++ b/drivers/input/misc/mpu3050.c
@@ -30,7 +30,6 @@
30 */ 30 */
31 31
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h>
34#include <linux/interrupt.h> 33#include <linux/interrupt.h>
35#include <linux/platform_device.h> 34#include <linux/platform_device.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
index 40ac9a5adf89..cd230365166e 100644
--- a/drivers/input/misc/pcap_keys.c
+++ b/drivers/input/misc/pcap_keys.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/input.h> 17#include <linux/input.h>
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
index 73b13ebabe56..db92f4f3c99b 100644
--- a/drivers/input/misc/pcf50633-input.c
+++ b/drivers/input/misc/pcf50633-input.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h> 19#include <linux/device.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22#include <linux/input.h> 21#include <linux/input.h>
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c
index 0deca5a3c87f..97f711a7bd20 100644
--- a/drivers/input/misc/pcf8574_keypad.c
+++ b/drivers/input/misc/pcf8574_keypad.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/input.h> 10#include <linux/input.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
13#include <linux/i2c.h> 12#include <linux/i2c.h>
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index 7288b267613d..674a2cfc3c0e 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -15,7 +15,6 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/i8253.h> 17#include <linux/i8253.h>
18#include <linux/init.h>
19#include <linux/input.h> 18#include <linux/input.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
21#include <linux/timex.h> 20#include <linux/timex.h>
diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
index ec086f6f3cc3..b88b7cbf93e2 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -11,13 +11,12 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/errno.h> 15#include <linux/errno.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/input.h> 17#include <linux/input.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/mfd/pm8xxx/core.h> 19#include <linux/regmap.h>
21 20
22#define VIB_DRV 0x4A 21#define VIB_DRV 0x4A
23 22
@@ -35,7 +34,7 @@
35 * struct pm8xxx_vib - structure to hold vibrator data 34 * struct pm8xxx_vib - structure to hold vibrator data
36 * @vib_input_dev: input device supporting force feedback 35 * @vib_input_dev: input device supporting force feedback
37 * @work: work structure to set the vibration parameters 36 * @work: work structure to set the vibration parameters
38 * @dev: device supporting force feedback 37 * @regmap: regmap for register read/write
39 * @speed: speed of vibration set from userland 38 * @speed: speed of vibration set from userland
40 * @active: state of vibrator 39 * @active: state of vibrator
41 * @level: level of vibration to set in the chip 40 * @level: level of vibration to set in the chip
@@ -44,7 +43,7 @@
44struct pm8xxx_vib { 43struct pm8xxx_vib {
45 struct input_dev *vib_input_dev; 44 struct input_dev *vib_input_dev;
46 struct work_struct work; 45 struct work_struct work;
47 struct device *dev; 46 struct regmap *regmap;
48 int speed; 47 int speed;
49 int level; 48 int level;
50 bool active; 49 bool active;
@@ -52,42 +51,6 @@ struct pm8xxx_vib {
52}; 51};
53 52
54/** 53/**
55 * pm8xxx_vib_read_u8 - helper to read a byte from pmic chip
56 * @vib: pointer to vibrator structure
57 * @data: placeholder for data to be read
58 * @reg: register address
59 */
60static int pm8xxx_vib_read_u8(struct pm8xxx_vib *vib,
61 u8 *data, u16 reg)
62{
63 int rc;
64
65 rc = pm8xxx_readb(vib->dev->parent, reg, data);
66 if (rc < 0)
67 dev_warn(vib->dev, "Error reading pm8xxx reg 0x%x(0x%x)\n",
68 reg, rc);
69 return rc;
70}
71
72/**
73 * pm8xxx_vib_write_u8 - helper to write a byte to pmic chip
74 * @vib: pointer to vibrator structure
75 * @data: data to write
76 * @reg: register address
77 */
78static int pm8xxx_vib_write_u8(struct pm8xxx_vib *vib,
79 u8 data, u16 reg)
80{
81 int rc;
82
83 rc = pm8xxx_writeb(vib->dev->parent, reg, data);
84 if (rc < 0)
85 dev_warn(vib->dev, "Error writing pm8xxx reg 0x%x(0x%x)\n",
86 reg, rc);
87 return rc;
88}
89
90/**
91 * pm8xxx_vib_set - handler to start/stop vibration 54 * pm8xxx_vib_set - handler to start/stop vibration
92 * @vib: pointer to vibrator structure 55 * @vib: pointer to vibrator structure
93 * @on: state to set 56 * @on: state to set
@@ -95,14 +58,14 @@ static int pm8xxx_vib_write_u8(struct pm8xxx_vib *vib,
95static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on) 58static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
96{ 59{
97 int rc; 60 int rc;
98 u8 val = vib->reg_vib_drv; 61 unsigned int val = vib->reg_vib_drv;
99 62
100 if (on) 63 if (on)
101 val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK); 64 val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
102 else 65 else
103 val &= ~VIB_DRV_SEL_MASK; 66 val &= ~VIB_DRV_SEL_MASK;
104 67
105 rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV); 68 rc = regmap_write(vib->regmap, VIB_DRV, val);
106 if (rc < 0) 69 if (rc < 0)
107 return rc; 70 return rc;
108 71
@@ -118,9 +81,9 @@ static void pm8xxx_work_handler(struct work_struct *work)
118{ 81{
119 struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, work); 82 struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, work);
120 int rc; 83 int rc;
121 u8 val; 84 unsigned int val;
122 85
123 rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV); 86 rc = regmap_read(vib->regmap, VIB_DRV, &val);
124 if (rc < 0) 87 if (rc < 0)
125 return; 88 return;
126 89
@@ -184,34 +147,37 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
184 struct pm8xxx_vib *vib; 147 struct pm8xxx_vib *vib;
185 struct input_dev *input_dev; 148 struct input_dev *input_dev;
186 int error; 149 int error;
187 u8 val; 150 unsigned int val;
188 151
189 vib = kzalloc(sizeof(*vib), GFP_KERNEL); 152 vib = devm_kzalloc(&pdev->dev, sizeof(*vib), GFP_KERNEL);
190 input_dev = input_allocate_device(); 153 if (!vib)
191 if (!vib || !input_dev) { 154 return -ENOMEM;
192 dev_err(&pdev->dev, "couldn't allocate memory\n"); 155
193 error = -ENOMEM; 156 vib->regmap = dev_get_regmap(pdev->dev.parent, NULL);
194 goto err_free_mem; 157 if (!vib->regmap)
195 } 158 return -ENODEV;
159
160 input_dev = devm_input_allocate_device(&pdev->dev);
161 if (!input_dev)
162 return -ENOMEM;
196 163
197 INIT_WORK(&vib->work, pm8xxx_work_handler); 164 INIT_WORK(&vib->work, pm8xxx_work_handler);
198 vib->dev = &pdev->dev;
199 vib->vib_input_dev = input_dev; 165 vib->vib_input_dev = input_dev;
200 166
201 /* operate in manual mode */ 167 /* operate in manual mode */
202 error = pm8xxx_vib_read_u8(vib, &val, VIB_DRV); 168 error = regmap_read(vib->regmap, VIB_DRV, &val);
203 if (error < 0) 169 if (error < 0)
204 goto err_free_mem; 170 return error;
171
205 val &= ~VIB_DRV_EN_MANUAL_MASK; 172 val &= ~VIB_DRV_EN_MANUAL_MASK;
206 error = pm8xxx_vib_write_u8(vib, val, VIB_DRV); 173 error = regmap_write(vib->regmap, VIB_DRV, val);
207 if (error < 0) 174 if (error < 0)
208 goto err_free_mem; 175 return error;
209 176
210 vib->reg_vib_drv = val; 177 vib->reg_vib_drv = val;
211 178
212 input_dev->name = "pm8xxx_vib_ffmemless"; 179 input_dev->name = "pm8xxx_vib_ffmemless";
213 input_dev->id.version = 1; 180 input_dev->id.version = 1;
214 input_dev->dev.parent = &pdev->dev;
215 input_dev->close = pm8xxx_vib_close; 181 input_dev->close = pm8xxx_vib_close;
216 input_set_drvdata(input_dev, vib); 182 input_set_drvdata(input_dev, vib);
217 input_set_capability(vib->vib_input_dev, EV_FF, FF_RUMBLE); 183 input_set_capability(vib->vib_input_dev, EV_FF, FF_RUMBLE);
@@ -221,35 +187,17 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
221 if (error) { 187 if (error) {
222 dev_err(&pdev->dev, 188 dev_err(&pdev->dev,
223 "couldn't register vibrator as FF device\n"); 189 "couldn't register vibrator as FF device\n");
224 goto err_free_mem; 190 return error;
225 } 191 }
226 192
227 error = input_register_device(input_dev); 193 error = input_register_device(input_dev);
228 if (error) { 194 if (error) {
229 dev_err(&pdev->dev, "couldn't register input device\n"); 195 dev_err(&pdev->dev, "couldn't register input device\n");
230 goto err_destroy_memless; 196 return error;
231 } 197 }
232 198
233 platform_set_drvdata(pdev, vib); 199 platform_set_drvdata(pdev, vib);
234 return 0; 200 return 0;
235
236err_destroy_memless:
237 input_ff_destroy(input_dev);
238err_free_mem:
239 input_free_device(input_dev);
240 kfree(vib);
241
242 return error;
243}
244
245static int pm8xxx_vib_remove(struct platform_device *pdev)
246{
247 struct pm8xxx_vib *vib = platform_get_drvdata(pdev);
248
249 input_unregister_device(vib->vib_input_dev);
250 kfree(vib);
251
252 return 0;
253} 201}
254 202
255#ifdef CONFIG_PM_SLEEP 203#ifdef CONFIG_PM_SLEEP
@@ -268,7 +216,6 @@ static SIMPLE_DEV_PM_OPS(pm8xxx_vib_pm_ops, pm8xxx_vib_suspend, NULL);
268 216
269static struct platform_driver pm8xxx_vib_driver = { 217static struct platform_driver pm8xxx_vib_driver = {
270 .probe = pm8xxx_vib_probe, 218 .probe = pm8xxx_vib_probe,
271 .remove = pm8xxx_vib_remove,
272 .driver = { 219 .driver = {
273 .name = "pm8xxx-vib", 220 .name = "pm8xxx-vib",
274 .owner = THIS_MODULE, 221 .owner = THIS_MODULE,
diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c b/drivers/input/misc/pmic8xxx-pwrkey.c
index b49b738aa9c6..0e1a05f95858 100644
--- a/drivers/input/misc/pmic8xxx-pwrkey.c
+++ b/drivers/input/misc/pmic8xxx-pwrkey.c
@@ -11,16 +11,15 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/errno.h> 15#include <linux/errno.h>
17#include <linux/slab.h> 16#include <linux/slab.h>
18#include <linux/input.h> 17#include <linux/input.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regmap.h>
21#include <linux/log2.h> 21#include <linux/log2.h>
22 22
23#include <linux/mfd/pm8xxx/core.h>
24#include <linux/input/pmic8xxx-pwrkey.h> 23#include <linux/input/pmic8xxx-pwrkey.h>
25 24
26#define PON_CNTL_1 0x1C 25#define PON_CNTL_1 0x1C
@@ -32,26 +31,25 @@
32 * @key_press_irq: key press irq number 31 * @key_press_irq: key press irq number
33 */ 32 */
34struct pmic8xxx_pwrkey { 33struct pmic8xxx_pwrkey {
35 struct input_dev *pwr;
36 int key_press_irq; 34 int key_press_irq;
37}; 35};
38 36
39static irqreturn_t pwrkey_press_irq(int irq, void *_pwrkey) 37static irqreturn_t pwrkey_press_irq(int irq, void *_pwr)
40{ 38{
41 struct pmic8xxx_pwrkey *pwrkey = _pwrkey; 39 struct input_dev *pwr = _pwr;
42 40
43 input_report_key(pwrkey->pwr, KEY_POWER, 1); 41 input_report_key(pwr, KEY_POWER, 1);
44 input_sync(pwrkey->pwr); 42 input_sync(pwr);
45 43
46 return IRQ_HANDLED; 44 return IRQ_HANDLED;
47} 45}
48 46
49static irqreturn_t pwrkey_release_irq(int irq, void *_pwrkey) 47static irqreturn_t pwrkey_release_irq(int irq, void *_pwr)
50{ 48{
51 struct pmic8xxx_pwrkey *pwrkey = _pwrkey; 49 struct input_dev *pwr = _pwr;
52 50
53 input_report_key(pwrkey->pwr, KEY_POWER, 0); 51 input_report_key(pwr, KEY_POWER, 0);
54 input_sync(pwrkey->pwr); 52 input_sync(pwr);
55 53
56 return IRQ_HANDLED; 54 return IRQ_HANDLED;
57} 55}
@@ -88,7 +86,8 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
88 int key_press_irq = platform_get_irq(pdev, 1); 86 int key_press_irq = platform_get_irq(pdev, 1);
89 int err; 87 int err;
90 unsigned int delay; 88 unsigned int delay;
91 u8 pon_cntl; 89 unsigned int pon_cntl;
90 struct regmap *regmap;
92 struct pmic8xxx_pwrkey *pwrkey; 91 struct pmic8xxx_pwrkey *pwrkey;
93 const struct pm8xxx_pwrkey_platform_data *pdata = 92 const struct pm8xxx_pwrkey_platform_data *pdata =
94 dev_get_platdata(&pdev->dev); 93 dev_get_platdata(&pdev->dev);
@@ -103,30 +102,36 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
103 return -EINVAL; 102 return -EINVAL;
104 } 103 }
105 104
106 pwrkey = kzalloc(sizeof(*pwrkey), GFP_KERNEL); 105 regmap = dev_get_regmap(pdev->dev.parent, NULL);
106 if (!regmap) {
107 dev_err(&pdev->dev, "failed to locate regmap for the device\n");
108 return -ENODEV;
109 }
110
111 pwrkey = devm_kzalloc(&pdev->dev, sizeof(*pwrkey), GFP_KERNEL);
107 if (!pwrkey) 112 if (!pwrkey)
108 return -ENOMEM; 113 return -ENOMEM;
109 114
110 pwr = input_allocate_device(); 115 pwrkey->key_press_irq = key_press_irq;
116
117 pwr = devm_input_allocate_device(&pdev->dev);
111 if (!pwr) { 118 if (!pwr) {
112 dev_dbg(&pdev->dev, "Can't allocate power button\n"); 119 dev_dbg(&pdev->dev, "Can't allocate power button\n");
113 err = -ENOMEM; 120 return -ENOMEM;
114 goto free_pwrkey;
115 } 121 }
116 122
117 input_set_capability(pwr, EV_KEY, KEY_POWER); 123 input_set_capability(pwr, EV_KEY, KEY_POWER);
118 124
119 pwr->name = "pmic8xxx_pwrkey"; 125 pwr->name = "pmic8xxx_pwrkey";
120 pwr->phys = "pmic8xxx_pwrkey/input0"; 126 pwr->phys = "pmic8xxx_pwrkey/input0";
121 pwr->dev.parent = &pdev->dev;
122 127
123 delay = (pdata->kpd_trigger_delay_us << 10) / USEC_PER_SEC; 128 delay = (pdata->kpd_trigger_delay_us << 10) / USEC_PER_SEC;
124 delay = 1 + ilog2(delay); 129 delay = 1 + ilog2(delay);
125 130
126 err = pm8xxx_readb(pdev->dev.parent, PON_CNTL_1, &pon_cntl); 131 err = regmap_read(regmap, PON_CNTL_1, &pon_cntl);
127 if (err < 0) { 132 if (err < 0) {
128 dev_err(&pdev->dev, "failed reading PON_CNTL_1 err=%d\n", err); 133 dev_err(&pdev->dev, "failed reading PON_CNTL_1 err=%d\n", err);
129 goto free_input_dev; 134 return err;
130 } 135 }
131 136
132 pon_cntl &= ~PON_CNTL_TRIG_DELAY_MASK; 137 pon_cntl &= ~PON_CNTL_TRIG_DELAY_MASK;
@@ -136,69 +141,46 @@ static int pmic8xxx_pwrkey_probe(struct platform_device *pdev)
136 else 141 else
137 pon_cntl &= ~PON_CNTL_PULL_UP; 142 pon_cntl &= ~PON_CNTL_PULL_UP;
138 143
139 err = pm8xxx_writeb(pdev->dev.parent, PON_CNTL_1, pon_cntl); 144 err = regmap_write(regmap, PON_CNTL_1, pon_cntl);
140 if (err < 0) { 145 if (err < 0) {
141 dev_err(&pdev->dev, "failed writing PON_CNTL_1 err=%d\n", err); 146 dev_err(&pdev->dev, "failed writing PON_CNTL_1 err=%d\n", err);
142 goto free_input_dev; 147 return err;
143 } 148 }
144 149
145 err = input_register_device(pwr); 150 err = devm_request_irq(&pdev->dev, key_press_irq, pwrkey_press_irq,
151 IRQF_TRIGGER_RISING,
152 "pmic8xxx_pwrkey_press", pwr);
146 if (err) { 153 if (err) {
147 dev_dbg(&pdev->dev, "Can't register power key: %d\n", err); 154 dev_err(&pdev->dev, "Can't get %d IRQ for pwrkey: %d\n",
148 goto free_input_dev; 155 key_press_irq, err);
156 return err;
149 } 157 }
150 158
151 pwrkey->key_press_irq = key_press_irq; 159 err = devm_request_irq(&pdev->dev, key_release_irq, pwrkey_release_irq,
152 pwrkey->pwr = pwr; 160 IRQF_TRIGGER_RISING,
153 161 "pmic8xxx_pwrkey_release", pwr);
154 platform_set_drvdata(pdev, pwrkey); 162 if (err) {
155 163 dev_err(&pdev->dev, "Can't get %d IRQ for pwrkey: %d\n",
156 err = request_irq(key_press_irq, pwrkey_press_irq, 164 key_release_irq, err);
157 IRQF_TRIGGER_RISING, "pmic8xxx_pwrkey_press", pwrkey); 165 return err;
158 if (err < 0) {
159 dev_dbg(&pdev->dev, "Can't get %d IRQ for pwrkey: %d\n",
160 key_press_irq, err);
161 goto unreg_input_dev;
162 } 166 }
163 167
164 err = request_irq(key_release_irq, pwrkey_release_irq, 168 err = input_register_device(pwr);
165 IRQF_TRIGGER_RISING, "pmic8xxx_pwrkey_release", pwrkey); 169 if (err) {
166 if (err < 0) { 170 dev_err(&pdev->dev, "Can't register power key: %d\n", err);
167 dev_dbg(&pdev->dev, "Can't get %d IRQ for pwrkey: %d\n", 171 return err;
168 key_release_irq, err);
169
170 goto free_press_irq;
171 } 172 }
172 173
174 platform_set_drvdata(pdev, pwrkey);
173 device_init_wakeup(&pdev->dev, pdata->wakeup); 175 device_init_wakeup(&pdev->dev, pdata->wakeup);
174 176
175 return 0; 177 return 0;
176
177free_press_irq:
178 free_irq(key_press_irq, pwrkey);
179unreg_input_dev:
180 input_unregister_device(pwr);
181 pwr = NULL;
182free_input_dev:
183 input_free_device(pwr);
184free_pwrkey:
185 kfree(pwrkey);
186 return err;
187} 178}
188 179
189static int pmic8xxx_pwrkey_remove(struct platform_device *pdev) 180static int pmic8xxx_pwrkey_remove(struct platform_device *pdev)
190{ 181{
191 struct pmic8xxx_pwrkey *pwrkey = platform_get_drvdata(pdev);
192 int key_release_irq = platform_get_irq(pdev, 0);
193 int key_press_irq = platform_get_irq(pdev, 1);
194
195 device_init_wakeup(&pdev->dev, 0); 182 device_init_wakeup(&pdev->dev, 0);
196 183
197 free_irq(key_press_irq, pwrkey);
198 free_irq(key_release_irq, pwrkey);
199 input_unregister_device(pwrkey->pwr);
200 kfree(pwrkey);
201
202 return 0; 184 return 0;
203} 185}
204 186
diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c
index 49c0c3ebd321..63b539d3daba 100644
--- a/drivers/input/misc/powermate.c
+++ b/drivers/input/misc/powermate.c
@@ -31,7 +31,6 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/init.h>
35#include <linux/spinlock.h> 34#include <linux/spinlock.h>
36#include <linux/usb/input.h> 35#include <linux/usb/input.h>
37 36
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index 940566e7be13..8ef288e7c971 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -68,7 +68,7 @@ static int pwm_beeper_event(struct input_dev *input,
68 68
69static int pwm_beeper_probe(struct platform_device *pdev) 69static int pwm_beeper_probe(struct platform_device *pdev)
70{ 70{
71 unsigned long pwm_id = (unsigned long)pdev->dev.platform_data; 71 unsigned long pwm_id = (unsigned long)dev_get_platdata(&pdev->dev);
72 struct pwm_beeper *beeper; 72 struct pwm_beeper *beeper;
73 int error; 73 int error;
74 74
diff --git a/drivers/input/misc/retu-pwrbutton.c b/drivers/input/misc/retu-pwrbutton.c
index 7ca09baa0016..4bff1aa9b0db 100644
--- a/drivers/input/misc/retu-pwrbutton.c
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -17,7 +17,6 @@
17 */ 17 */
18 18
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/init.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/errno.h> 21#include <linux/errno.h>
23#include <linux/input.h> 22#include <linux/input.h>
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index f920ba7ab51f..99b9e42aa748 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
21#include <linux/input.h> 20#include <linux/input.h>
22#include <linux/device.h> 21#include <linux/device.h>
diff --git a/drivers/input/misc/sgi_btns.c b/drivers/input/misc/sgi_btns.c
index 95cf299ef9a3..f10474937a64 100644
--- a/drivers/input/misc/sgi_btns.c
+++ b/drivers/input/misc/sgi_btns.c
@@ -17,7 +17,6 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20#include <linux/init.h>
21#include <linux/input-polldev.h> 20#include <linux/input-polldev.h>
22#include <linux/ioport.h> 21#include <linux/ioport.h>
23#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c
index 7b8b03e0d0be..e8897c36d21b 100644
--- a/drivers/input/misc/sirfsoc-onkey.c
+++ b/drivers/input/misc/sirfsoc-onkey.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/interrupt.h> 10#include <linux/interrupt.h>
12#include <linux/delay.h> 11#include <linux/delay.h>
13#include <linux/platform_device.h> 12#include <linux/platform_device.h>
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index b9a05fda03e4..fb3b63b2f85c 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -52,15 +52,15 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
52 return IRQ_HANDLED; 52 return IRQ_HANDLED;
53} 53}
54 54
55static int __init twl4030_pwrbutton_probe(struct platform_device *pdev) 55static int twl4030_pwrbutton_probe(struct platform_device *pdev)
56{ 56{
57 struct input_dev *pwr; 57 struct input_dev *pwr;
58 int irq = platform_get_irq(pdev, 0); 58 int irq = platform_get_irq(pdev, 0);
59 int err; 59 int err;
60 60
61 pwr = input_allocate_device(); 61 pwr = devm_input_allocate_device(&pdev->dev);
62 if (!pwr) { 62 if (!pwr) {
63 dev_dbg(&pdev->dev, "Can't allocate power button\n"); 63 dev_err(&pdev->dev, "Can't allocate power button\n");
64 return -ENOMEM; 64 return -ENOMEM;
65 } 65 }
66 66
@@ -70,52 +70,42 @@ static int __init twl4030_pwrbutton_probe(struct platform_device *pdev)
70 pwr->phys = "twl4030_pwrbutton/input0"; 70 pwr->phys = "twl4030_pwrbutton/input0";
71 pwr->dev.parent = &pdev->dev; 71 pwr->dev.parent = &pdev->dev;
72 72
73 err = request_threaded_irq(irq, NULL, powerbutton_irq, 73 err = devm_request_threaded_irq(&pwr->dev, irq, NULL, powerbutton_irq,
74 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 74 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
75 "twl4030_pwrbutton", pwr); 75 "twl4030_pwrbutton", pwr);
76 if (err < 0) { 76 if (err < 0) {
77 dev_dbg(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err); 77 dev_err(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
78 goto free_input_dev; 78 return err;
79 } 79 }
80 80
81 err = input_register_device(pwr); 81 err = input_register_device(pwr);
82 if (err) { 82 if (err) {
83 dev_dbg(&pdev->dev, "Can't register power button: %d\n", err); 83 dev_err(&pdev->dev, "Can't register power button: %d\n", err);
84 goto free_irq; 84 return err;
85 } 85 }
86 86
87 platform_set_drvdata(pdev, pwr); 87 platform_set_drvdata(pdev, pwr);
88 88
89 return 0; 89 return 0;
90
91free_irq:
92 free_irq(irq, pwr);
93free_input_dev:
94 input_free_device(pwr);
95 return err;
96} 90}
97 91
98static int __exit twl4030_pwrbutton_remove(struct platform_device *pdev) 92#ifdef CONFIG_OF
99{ 93static const struct of_device_id twl4030_pwrbutton_dt_match_table[] = {
100 struct input_dev *pwr = platform_get_drvdata(pdev); 94 { .compatible = "ti,twl4030-pwrbutton" },
101 int irq = platform_get_irq(pdev, 0); 95 {},
102 96};
103 free_irq(irq, pwr); 97MODULE_DEVICE_TABLE(of, twl4030_pwrbutton_dt_match_table);
104 input_unregister_device(pwr); 98#endif
105
106 return 0;
107}
108 99
109static struct platform_driver twl4030_pwrbutton_driver = { 100static struct platform_driver twl4030_pwrbutton_driver = {
110 .remove = __exit_p(twl4030_pwrbutton_remove), 101 .probe = twl4030_pwrbutton_probe,
111 .driver = { 102 .driver = {
112 .name = "twl4030_pwrbutton", 103 .name = "twl4030_pwrbutton",
113 .owner = THIS_MODULE, 104 .owner = THIS_MODULE,
105 .of_match_table = of_match_ptr(twl4030_pwrbutton_dt_match_table),
114 }, 106 },
115}; 107};
116 108module_platform_driver(twl4030_pwrbutton_driver);
117module_platform_driver_probe(twl4030_pwrbutton_driver,
118 twl4030_pwrbutton_probe);
119 109
120MODULE_ALIAS("platform:twl4030_pwrbutton"); 110MODULE_ALIAS("platform:twl4030_pwrbutton");
121MODULE_DESCRIPTION("Triton2 Power Button"); 111MODULE_DESCRIPTION("Triton2 Power Button");
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index 68a5f33152a8..960ef2a70910 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -185,15 +185,17 @@ static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata,
185 if (pdata && pdata->coexist) 185 if (pdata && pdata->coexist)
186 return true; 186 return true;
187 187
188 if (of_find_node_by_name(node, "codec")) 188 if (of_find_node_by_name(node, "codec")) {
189 of_node_put(node);
189 return true; 190 return true;
191 }
190 192
191 return false; 193 return false;
192} 194}
193 195
194static int twl4030_vibra_probe(struct platform_device *pdev) 196static int twl4030_vibra_probe(struct platform_device *pdev)
195{ 197{
196 struct twl4030_vibra_data *pdata = pdev->dev.platform_data; 198 struct twl4030_vibra_data *pdata = dev_get_platdata(&pdev->dev);
197 struct device_node *twl4030_core_node = pdev->dev.parent->of_node; 199 struct device_node *twl4030_core_node = pdev->dev.parent->of_node;
198 struct vibra_info *info; 200 struct vibra_info *info;
199 int ret; 201 int ret;
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 7864b0c3ebb3..77dc23b94eb1 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -258,17 +258,14 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL);
258static int twl6040_vibra_probe(struct platform_device *pdev) 258static int twl6040_vibra_probe(struct platform_device *pdev)
259{ 259{
260 struct device *twl6040_core_dev = pdev->dev.parent; 260 struct device *twl6040_core_dev = pdev->dev.parent;
261 struct device_node *twl6040_core_node = NULL; 261 struct device_node *twl6040_core_node;
262 struct vibra_info *info; 262 struct vibra_info *info;
263 int vddvibl_uV = 0; 263 int vddvibl_uV = 0;
264 int vddvibr_uV = 0; 264 int vddvibr_uV = 0;
265 int ret; 265 int ret;
266 266
267#ifdef CONFIG_OF
268 twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node, 267 twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node,
269 "vibra"); 268 "vibra");
270#endif
271
272 if (!twl6040_core_node) { 269 if (!twl6040_core_node) {
273 dev_err(&pdev->dev, "parent of node is missing?\n"); 270 dev_err(&pdev->dev, "parent of node is missing?\n");
274 return -EINVAL; 271 return -EINVAL;
@@ -276,6 +273,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
276 273
277 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 274 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
278 if (!info) { 275 if (!info) {
276 of_node_put(twl6040_core_node);
279 dev_err(&pdev->dev, "couldn't allocate memory\n"); 277 dev_err(&pdev->dev, "couldn't allocate memory\n");
280 return -ENOMEM; 278 return -ENOMEM;
281 } 279 }
@@ -295,6 +293,8 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
295 of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV); 293 of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV);
296 of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV); 294 of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV);
297 295
296 of_node_put(twl6040_core_node);
297
298 if ((!info->vibldrv_res && !info->viblmotor_res) || 298 if ((!info->vibldrv_res && !info->viblmotor_res) ||
299 (!info->vibrdrv_res && !info->vibrmotor_res)) { 299 (!info->vibrdrv_res && !info->vibrmotor_res)) {
300 dev_err(info->dev, "invalid vibra driver/motor resistance\n"); 300 dev_err(info->dev, "invalid vibra driver/motor resistance\n");
diff --git a/drivers/input/misc/wm831x-on.c b/drivers/input/misc/wm831x-on.c
index caa2c4068f09..173b6dcca0da 100644
--- a/drivers/input/misc/wm831x-on.c
+++ b/drivers/input/misc/wm831x-on.c
@@ -18,7 +18,6 @@
18 */ 18 */
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/kernel.h> 22#include <linux/kernel.h>
24#include <linux/errno.h> 23#include <linux/errno.h>
diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
index 285a5bd6cbc9..79c964c075f1 100644
--- a/drivers/input/misc/yealink.c
+++ b/drivers/input/misc/yealink.c
@@ -47,7 +47,6 @@
47 */ 47 */
48 48
49#include <linux/kernel.h> 49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/slab.h> 50#include <linux/slab.h>
52#include <linux/module.h> 51#include <linux/module.h>
53#include <linux/rwsem.h> 52#include <linux/rwsem.h>
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 5cf62e315218..fb15c64ffb95 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -277,6 +277,57 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse)
277} 277}
278 278
279/* 279/*
280 * Process bitmap data for V5 protocols. Return value is null.
281 *
282 * The bitmaps don't have enough data to track fingers, so this function
283 * only generates points representing a bounding box of at most two contacts.
284 * These two points are returned in x1, y1, x2, and y2.
285 */
286static void alps_process_bitmap_dolphin(struct alps_data *priv,
287 struct alps_fields *fields,
288 int *x1, int *y1, int *x2, int *y2)
289{
290 int box_middle_x, box_middle_y;
291 unsigned int x_map, y_map;
292 unsigned char start_bit, end_bit;
293 unsigned char x_msb, x_lsb, y_msb, y_lsb;
294
295 x_map = fields->x_map;
296 y_map = fields->y_map;
297
298 if (!x_map || !y_map)
299 return;
300
301 /* Get Most-significant and Least-significant bit */
302 x_msb = fls(x_map);
303 x_lsb = ffs(x_map);
304 y_msb = fls(y_map);
305 y_lsb = ffs(y_map);
306
307 /* Most-significant bit should never exceed max sensor line number */
308 if (x_msb > priv->x_bits || y_msb > priv->y_bits)
309 return;
310
311 *x1 = *y1 = *x2 = *y2 = 0;
312
313 if (fields->fingers > 1) {
314 start_bit = priv->x_bits - x_msb;
315 end_bit = priv->x_bits - x_lsb;
316 box_middle_x = (priv->x_max * (start_bit + end_bit)) /
317 (2 * (priv->x_bits - 1));
318
319 start_bit = y_lsb - 1;
320 end_bit = y_msb - 1;
321 box_middle_y = (priv->y_max * (start_bit + end_bit)) /
322 (2 * (priv->y_bits - 1));
323 *x1 = fields->x;
324 *y1 = fields->y;
325 *x2 = 2 * box_middle_x - *x1;
326 *y2 = 2 * box_middle_y - *y1;
327 }
328}
329
330/*
280 * Process bitmap data from v3 and v4 protocols. Returns the number of 331 * Process bitmap data from v3 and v4 protocols. Returns the number of
281 * fingers detected. A return value of 0 means at least one of the 332 * fingers detected. A return value of 0 means at least one of the
282 * bitmaps was empty. 333 * bitmaps was empty.
@@ -481,7 +532,8 @@ static void alps_decode_buttons_v3(struct alps_fields *f, unsigned char *p)
481 f->ts_middle = !!(p[3] & 0x40); 532 f->ts_middle = !!(p[3] & 0x40);
482} 533}
483 534
484static void alps_decode_pinnacle(struct alps_fields *f, unsigned char *p) 535static void alps_decode_pinnacle(struct alps_fields *f, unsigned char *p,
536 struct psmouse *psmouse)
485{ 537{
486 f->first_mp = !!(p[4] & 0x40); 538 f->first_mp = !!(p[4] & 0x40);
487 f->is_mp = !!(p[0] & 0x40); 539 f->is_mp = !!(p[0] & 0x40);
@@ -502,48 +554,61 @@ static void alps_decode_pinnacle(struct alps_fields *f, unsigned char *p)
502 alps_decode_buttons_v3(f, p); 554 alps_decode_buttons_v3(f, p);
503} 555}
504 556
505static void alps_decode_rushmore(struct alps_fields *f, unsigned char *p) 557static void alps_decode_rushmore(struct alps_fields *f, unsigned char *p,
558 struct psmouse *psmouse)
506{ 559{
507 alps_decode_pinnacle(f, p); 560 alps_decode_pinnacle(f, p, psmouse);
508 561
509 f->x_map |= (p[5] & 0x10) << 11; 562 f->x_map |= (p[5] & 0x10) << 11;
510 f->y_map |= (p[5] & 0x20) << 6; 563 f->y_map |= (p[5] & 0x20) << 6;
511} 564}
512 565
513static void alps_decode_dolphin(struct alps_fields *f, unsigned char *p) 566static void alps_decode_dolphin(struct alps_fields *f, unsigned char *p,
567 struct psmouse *psmouse)
514{ 568{
569 u64 palm_data = 0;
570 struct alps_data *priv = psmouse->private;
571
515 f->first_mp = !!(p[0] & 0x02); 572 f->first_mp = !!(p[0] & 0x02);
516 f->is_mp = !!(p[0] & 0x20); 573 f->is_mp = !!(p[0] & 0x20);
517 574
518 f->fingers = ((p[0] & 0x6) >> 1 | 575 if (!f->is_mp) {
576 f->x = ((p[1] & 0x7f) | ((p[4] & 0x0f) << 7));
577 f->y = ((p[2] & 0x7f) | ((p[4] & 0xf0) << 3));
578 f->z = (p[0] & 4) ? 0 : p[5] & 0x7f;
579 alps_decode_buttons_v3(f, p);
580 } else {
581 f->fingers = ((p[0] & 0x6) >> 1 |
519 (p[0] & 0x10) >> 2); 582 (p[0] & 0x10) >> 2);
520 f->x_map = ((p[2] & 0x60) >> 5) |
521 ((p[4] & 0x7f) << 2) |
522 ((p[5] & 0x7f) << 9) |
523 ((p[3] & 0x07) << 16) |
524 ((p[3] & 0x70) << 15) |
525 ((p[0] & 0x01) << 22);
526 f->y_map = (p[1] & 0x7f) |
527 ((p[2] & 0x1f) << 7);
528
529 f->x = ((p[1] & 0x7f) | ((p[4] & 0x0f) << 7));
530 f->y = ((p[2] & 0x7f) | ((p[4] & 0xf0) << 3));
531 f->z = (p[0] & 4) ? 0 : p[5] & 0x7f;
532 583
533 alps_decode_buttons_v3(f, p); 584 palm_data = (p[1] & 0x7f) |
585 ((p[2] & 0x7f) << 7) |
586 ((p[4] & 0x7f) << 14) |
587 ((p[5] & 0x7f) << 21) |
588 ((p[3] & 0x07) << 28) |
589 (((u64)p[3] & 0x70) << 27) |
590 (((u64)p[0] & 0x01) << 34);
591
592 /* Y-profile is stored in P(0) to p(n-1), n = y_bits; */
593 f->y_map = palm_data & (BIT(priv->y_bits) - 1);
594
595 /* X-profile is stored in p(n) to p(n+m-1), m = x_bits; */
596 f->x_map = (palm_data >> priv->y_bits) &
597 (BIT(priv->x_bits) - 1);
598 }
534} 599}
535 600
536static void alps_process_touchpad_packet_v3(struct psmouse *psmouse) 601static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse)
537{ 602{
538 struct alps_data *priv = psmouse->private; 603 struct alps_data *priv = psmouse->private;
539 unsigned char *packet = psmouse->packet; 604 unsigned char *packet = psmouse->packet;
540 struct input_dev *dev = psmouse->dev; 605 struct input_dev *dev = psmouse->dev;
541 struct input_dev *dev2 = priv->dev2; 606 struct input_dev *dev2 = priv->dev2;
542 int x1 = 0, y1 = 0, x2 = 0, y2 = 0; 607 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
543 int fingers = 0, bmap_fingers; 608 int fingers = 0, bmap_fn;
544 struct alps_fields f; 609 struct alps_fields f = {0};
545 610
546 priv->decode_fields(&f, packet); 611 priv->decode_fields(&f, packet, psmouse);
547 612
548 /* 613 /*
549 * There's no single feature of touchpad position and bitmap packets 614 * There's no single feature of touchpad position and bitmap packets
@@ -560,19 +625,38 @@ static void alps_process_touchpad_packet_v3(struct psmouse *psmouse)
560 */ 625 */
561 if (f.is_mp) { 626 if (f.is_mp) {
562 fingers = f.fingers; 627 fingers = f.fingers;
563 bmap_fingers = alps_process_bitmap(priv, 628 if (priv->proto_version == ALPS_PROTO_V3) {
564 f.x_map, f.y_map, 629 bmap_fn = alps_process_bitmap(priv, f.x_map,
565 &x1, &y1, &x2, &y2); 630 f.y_map, &x1, &y1,
566 631 &x2, &y2);
567 /* 632
568 * We shouldn't report more than one finger if 633 /*
569 * we don't have two coordinates. 634 * We shouldn't report more than one finger if
570 */ 635 * we don't have two coordinates.
571 if (fingers > 1 && bmap_fingers < 2) 636 */
572 fingers = bmap_fingers; 637 if (fingers > 1 && bmap_fn < 2)
573 638 fingers = bmap_fn;
574 /* Now process position packet */ 639
575 priv->decode_fields(&f, priv->multi_data); 640 /* Now process position packet */
641 priv->decode_fields(&f, priv->multi_data,
642 psmouse);
643 } else {
644 /*
645 * Because Dolphin uses position packet's
646 * coordinate data as Pt1 and uses it to
647 * calculate Pt2, so we need to do position
648 * packet decode first.
649 */
650 priv->decode_fields(&f, priv->multi_data,
651 psmouse);
652
653 /*
654 * Since Dolphin's finger number is reliable,
655 * there is no need to compare with bmap_fn.
656 */
657 alps_process_bitmap_dolphin(priv, &f, &x1, &y1,
658 &x2, &y2);
659 }
576 } else { 660 } else {
577 priv->multi_packet = 0; 661 priv->multi_packet = 0;
578 } 662 }
@@ -662,7 +746,7 @@ static void alps_process_packet_v3(struct psmouse *psmouse)
662 return; 746 return;
663 } 747 }
664 748
665 alps_process_touchpad_packet_v3(psmouse); 749 alps_process_touchpad_packet_v3_v5(psmouse);
666} 750}
667 751
668static void alps_process_packet_v6(struct psmouse *psmouse) 752static void alps_process_packet_v6(struct psmouse *psmouse)
@@ -1709,6 +1793,52 @@ error:
1709 return -1; 1793 return -1;
1710} 1794}
1711 1795
1796static int alps_dolphin_get_device_area(struct psmouse *psmouse,
1797 struct alps_data *priv)
1798{
1799 struct ps2dev *ps2dev = &psmouse->ps2dev;
1800 unsigned char param[4] = {0};
1801 int num_x_electrode, num_y_electrode;
1802
1803 if (alps_enter_command_mode(psmouse))
1804 return -1;
1805
1806 param[0] = 0x0a;
1807 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) ||
1808 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETPOLL) ||
1809 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETPOLL) ||
1810 ps2_command(ps2dev, &param[0], PSMOUSE_CMD_SETRATE) ||
1811 ps2_command(ps2dev, &param[0], PSMOUSE_CMD_SETRATE))
1812 return -1;
1813
1814 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
1815 return -1;
1816
1817 /*
1818 * Dolphin's sensor line number is not fixed. It can be calculated
1819 * by adding the device's register value with DOLPHIN_PROFILE_X/YOFFSET.
1820 * Further more, we can get device's x_max and y_max by multiplying
1821 * sensor line number with DOLPHIN_COUNT_PER_ELECTRODE.
1822 *
1823 * e.g. When we get register's sensor_x = 11 & sensor_y = 8,
1824 * real sensor line number X = 11 + 8 = 19, and
1825 * real sensor line number Y = 8 + 1 = 9.
1826 * So, x_max = (19 - 1) * 64 = 1152, and
1827 * y_max = (9 - 1) * 64 = 512.
1828 */
1829 num_x_electrode = DOLPHIN_PROFILE_XOFFSET + (param[2] & 0x0F);
1830 num_y_electrode = DOLPHIN_PROFILE_YOFFSET + ((param[2] >> 4) & 0x0F);
1831 priv->x_bits = num_x_electrode;
1832 priv->y_bits = num_y_electrode;
1833 priv->x_max = (num_x_electrode - 1) * DOLPHIN_COUNT_PER_ELECTRODE;
1834 priv->y_max = (num_y_electrode - 1) * DOLPHIN_COUNT_PER_ELECTRODE;
1835
1836 if (alps_exit_command_mode(psmouse))
1837 return -1;
1838
1839 return 0;
1840}
1841
1712static int alps_hw_init_dolphin_v1(struct psmouse *psmouse) 1842static int alps_hw_init_dolphin_v1(struct psmouse *psmouse)
1713{ 1843{
1714 struct ps2dev *ps2dev = &psmouse->ps2dev; 1844 struct ps2dev *ps2dev = &psmouse->ps2dev;
@@ -1763,13 +1893,13 @@ static void alps_set_defaults(struct alps_data *priv)
1763 break; 1893 break;
1764 case ALPS_PROTO_V5: 1894 case ALPS_PROTO_V5:
1765 priv->hw_init = alps_hw_init_dolphin_v1; 1895 priv->hw_init = alps_hw_init_dolphin_v1;
1766 priv->process_packet = alps_process_packet_v3; 1896 priv->process_packet = alps_process_touchpad_packet_v3_v5;
1767 priv->decode_fields = alps_decode_dolphin; 1897 priv->decode_fields = alps_decode_dolphin;
1768 priv->set_abs_params = alps_set_abs_params_mt; 1898 priv->set_abs_params = alps_set_abs_params_mt;
1769 priv->nibble_commands = alps_v3_nibble_commands; 1899 priv->nibble_commands = alps_v3_nibble_commands;
1770 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; 1900 priv->addr_command = PSMOUSE_CMD_RESET_WRAP;
1771 priv->byte0 = 0xc8; 1901 priv->byte0 = 0xc8;
1772 priv->mask0 = 0xc8; 1902 priv->mask0 = 0xd8;
1773 priv->flags = 0; 1903 priv->flags = 0;
1774 priv->x_max = 1360; 1904 priv->x_max = 1360;
1775 priv->y_max = 660; 1905 priv->y_max = 660;
@@ -1845,11 +1975,13 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
1845 if (alps_match_table(psmouse, priv, e7, ec) == 0) { 1975 if (alps_match_table(psmouse, priv, e7, ec) == 0) {
1846 return 0; 1976 return 0;
1847 } else if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0x50 && 1977 } else if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0x50 &&
1848 ec[0] == 0x73 && ec[1] == 0x01) { 1978 ec[0] == 0x73 && (ec[1] == 0x01 || ec[1] == 0x02)) {
1849 priv->proto_version = ALPS_PROTO_V5; 1979 priv->proto_version = ALPS_PROTO_V5;
1850 alps_set_defaults(priv); 1980 alps_set_defaults(priv);
1851 1981 if (alps_dolphin_get_device_area(psmouse, priv))
1852 return 0; 1982 return -EIO;
1983 else
1984 return 0;
1853 } else if (ec[0] == 0x88 && ec[1] == 0x08) { 1985 } else if (ec[0] == 0x88 && ec[1] == 0x08) {
1854 priv->proto_version = ALPS_PROTO_V3; 1986 priv->proto_version = ALPS_PROTO_V3;
1855 alps_set_defaults(priv); 1987 alps_set_defaults(priv);
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index 704f0f924307..03f88b6940c7 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -19,6 +19,10 @@
19#define ALPS_PROTO_V5 5 19#define ALPS_PROTO_V5 5
20#define ALPS_PROTO_V6 6 20#define ALPS_PROTO_V6 6
21 21
22#define DOLPHIN_COUNT_PER_ELECTRODE 64
23#define DOLPHIN_PROFILE_XOFFSET 8 /* x-electrode offset */
24#define DOLPHIN_PROFILE_YOFFSET 1 /* y-electrode offset */
25
22/** 26/**
23 * struct alps_model_info - touchpad ID table 27 * struct alps_model_info - touchpad ID table
24 * @signature: E7 response string to match. 28 * @signature: E7 response string to match.
@@ -146,7 +150,8 @@ struct alps_data {
146 150
147 int (*hw_init)(struct psmouse *psmouse); 151 int (*hw_init)(struct psmouse *psmouse);
148 void (*process_packet)(struct psmouse *psmouse); 152 void (*process_packet)(struct psmouse *psmouse);
149 void (*decode_fields)(struct alps_fields *f, unsigned char *p); 153 void (*decode_fields)(struct alps_fields *f, unsigned char *p,
154 struct psmouse *psmouse);
150 void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1); 155 void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
151 156
152 int prev_fin; 157 int prev_fin;
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index e42f1fa8cdc0..800ca7dfafc2 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -30,7 +30,6 @@
30 30
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/init.h>
34#include <linux/slab.h> 33#include <linux/slab.h>
35#include <linux/module.h> 34#include <linux/module.h>
36#include <linux/usb/input.h> 35#include <linux/usb/input.h>
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index a73f9618b0ad..c329cdb0b91a 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -34,7 +34,6 @@
34 34
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/init.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <linux/module.h> 38#include <linux/module.h>
40#include <linux/usb/input.h> 39#include <linux/usb/input.h>
diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
index a5869a856ea5..87095e2f5153 100644
--- a/drivers/input/mouse/cypress_ps2.c
+++ b/drivers/input/mouse/cypress_ps2.c
@@ -15,7 +15,6 @@
15 * the Free Software Foundation. 15 * the Free Software Foundation.
16 */ 16 */
17 17
18#include <linux/init.h>
19#include <linux/module.h> 18#include <linux/module.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 597e9b8fc18d..ef1cf52f8bb9 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
486 unsigned char *packet = psmouse->packet; 486 unsigned char *packet = psmouse->packet;
487 487
488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
489 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
489 input_mt_report_pointer_emulation(dev, true); 490 input_mt_report_pointer_emulation(dev, true);
490 input_sync(dev); 491 input_sync(dev);
491} 492}
@@ -984,6 +985,44 @@ static int elantech_get_resolution_v4(struct psmouse *psmouse,
984} 985}
985 986
986/* 987/*
988 * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in
989 * fw_version for this is based on the following fw_version & caps table:
990 *
991 * Laptop-model: fw_version: caps: buttons:
992 * Acer S3 0x461f00 10, 13, 0e clickpad
993 * Acer S7-392 0x581f01 50, 17, 0d clickpad
994 * Acer V5-131 0x461f02 01, 16, 0c clickpad
995 * Acer V5-551 0x461f00 ? clickpad
996 * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons
997 * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons
998 * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons
999 * Asus UX31 0x361f00 20, 15, 0e clickpad
1000 * Asus UX32VD 0x361f02 00, 15, 0e clickpad
1001 * Avatar AVIU-145A2 0x361f00 ? clickpad
1002 * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons
1003 * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*)
1004 * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons
1005 * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad
1006 * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad
1007 * Samsung NP900X3E-A02 0x575f03 ? clickpad
1008 * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad
1009 * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons
1010 * Samsung RF710 0x450f00 ? 2 hw buttons
1011 * System76 Pangolin 0x250f01 ? 2 hw buttons
1012 * (*) + 3 trackpoint buttons
1013 */
1014static void elantech_set_buttonpad_prop(struct psmouse *psmouse)
1015{
1016 struct input_dev *dev = psmouse->dev;
1017 struct elantech_data *etd = psmouse->private;
1018
1019 if (etd->fw_version & 0x001000) {
1020 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
1021 __clear_bit(BTN_RIGHT, dev->keybit);
1022 }
1023}
1024
1025/*
987 * Set the appropriate event bits for the input subsystem 1026 * Set the appropriate event bits for the input subsystem
988 */ 1027 */
989static int elantech_set_input_params(struct psmouse *psmouse) 1028static int elantech_set_input_params(struct psmouse *psmouse)
@@ -1026,6 +1065,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1026 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); 1065 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
1027 /* fall through */ 1066 /* fall through */
1028 case 3: 1067 case 3:
1068 if (etd->hw_version == 3)
1069 elantech_set_buttonpad_prop(psmouse);
1029 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); 1070 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
1030 input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); 1071 input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0);
1031 if (etd->reports_pressure) { 1072 if (etd->reports_pressure) {
@@ -1047,9 +1088,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1047 */ 1088 */
1048 psmouse_warn(psmouse, "couldn't query resolution data.\n"); 1089 psmouse_warn(psmouse, "couldn't query resolution data.\n");
1049 } 1090 }
1050 /* v4 is clickpad, with only one button. */ 1091 elantech_set_buttonpad_prop(psmouse);
1051 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
1052 __clear_bit(BTN_RIGHT, dev->keybit);
1053 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 1092 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
1054 /* For X to recognize me as touchpad. */ 1093 /* For X to recognize me as touchpad. */
1055 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); 1094 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index 6b44413f54e3..8c7d94200bdb 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -8,7 +8,6 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/init.h>
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/platform_device.h> 12#include <linux/platform_device.h>
14#include <linux/input-polldev.h> 13#include <linux/input-polldev.h>
@@ -48,7 +47,7 @@ static void gpio_mouse_scan(struct input_polled_dev *dev)
48 47
49static int gpio_mouse_probe(struct platform_device *pdev) 48static int gpio_mouse_probe(struct platform_device *pdev)
50{ 49{
51 struct gpio_mouse_platform_data *pdata = pdev->dev.platform_data; 50 struct gpio_mouse_platform_data *pdata = dev_get_platdata(&pdev->dev);
52 struct input_polled_dev *input_poll; 51 struct input_polled_dev *input_poll;
53 struct input_dev *input; 52 struct input_dev *input;
54 int pin, i; 53 int pin, i;
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 84de2fc6acc1..136e222e2a16 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -220,7 +220,7 @@ static const struct ps2pp_info *get_model_info(unsigned char model)
220 { 61, PS2PP_KIND_MX, /* MX700 */ 220 { 61, PS2PP_KIND_MX, /* MX700 */
221 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | 221 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
222 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, 222 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN },
223 { 66, PS2PP_KIND_MX, /* MX3100 reciver */ 223 { 66, PS2PP_KIND_MX, /* MX3100 receiver */
224 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | 224 PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN |
225 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL }, 225 PS2PP_EXTRA_BTN | PS2PP_NAV_BTN | PS2PP_HWHEEL },
226 { 72, PS2PP_KIND_TRACKMAN, 0 }, /* T-CH11: TrackMan Marble */ 226 { 72, PS2PP_KIND_TRACKMAN, 0 }, /* T-CH11: TrackMan Marble */
diff --git a/drivers/input/mouse/navpoint.c b/drivers/input/mouse/navpoint.c
index 0b8d33591dee..1ccc88af1f0b 100644
--- a/drivers/input/mouse/navpoint.c
+++ b/drivers/input/mouse/navpoint.c
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/platform_device.h> 13#include <linux/platform_device.h>
15#include <linux/clk.h> 14#include <linux/clk.h>
diff --git a/drivers/input/mouse/pxa930_trkball.c b/drivers/input/mouse/pxa930_trkball.c
index 0ecb9e7945eb..9b4d9a59e229 100644
--- a/drivers/input/mouse/pxa930_trkball.c
+++ b/drivers/input/mouse/pxa930_trkball.c
@@ -10,7 +10,6 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/init.h>
14#include <linux/input.h> 13#include <linux/input.h>
15#include <linux/interrupt.h> 14#include <linux/interrupt.h>
16#include <linux/module.h> 15#include <linux/module.h>
@@ -166,7 +165,7 @@ static int pxa930_trkball_probe(struct platform_device *pdev)
166 if (!trkball) 165 if (!trkball)
167 return -ENOMEM; 166 return -ENOMEM;
168 167
169 trkball->pdata = pdev->dev.platform_data; 168 trkball->pdata = dev_get_platdata(&pdev->dev);
170 if (!trkball->pdata) { 169 if (!trkball->pdata) {
171 dev_err(&pdev->dev, "no platform data defined\n"); 170 dev_err(&pdev->dev, "no platform data defined\n");
172 error = -EINVAL; 171 error = -EINVAL;
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index d5928fd0c914..8df526620ebf 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -32,7 +32,6 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/input.h> 33#include <linux/input.h>
34#include <linux/serio.h> 34#include <linux/serio.h>
35#include <linux/init.h>
36 35
37#define DRIVER_DESC "Serial mouse driver" 36#define DRIVER_DESC "Serial mouse driver"
38 37
diff --git a/drivers/input/mouse/synaptics_usb.c b/drivers/input/mouse/synaptics_usb.c
index 64cf34ea7604..e122bda16aab 100644
--- a/drivers/input/mouse/synaptics_usb.c
+++ b/drivers/input/mouse/synaptics_usb.c
@@ -39,7 +39,6 @@
39 */ 39 */
40 40
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/init.h>
43#include <linux/slab.h> 42#include <linux/slab.h>
44#include <linux/module.h> 43#include <linux/module.h>
45#include <linux/moduleparam.h> 44#include <linux/moduleparam.h>
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index e900d465aaf6..38298232124f 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -82,7 +82,6 @@
82#include <linux/interrupt.h> 82#include <linux/interrupt.h>
83#include <linux/input.h> 83#include <linux/input.h>
84#include <linux/serio.h> 84#include <linux/serio.h>
85#include <linux/init.h>
86 85
87#define DRIVER_DESC "Driver for DEC VSXXX-AA and -GA mice and VSXXX-AB tablet" 86#define DRIVER_DESC "Driver for DEC VSXXX-AA and -GA mice and VSXXX-AB tablet"
88 87
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index 8541f949778d..aec54e283580 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -16,14 +16,19 @@ config SERIO
16 To compile this driver as a module, choose M here: the 16 To compile this driver as a module, choose M here: the
17 module will be called serio. 17 module will be called serio.
18 18
19config ARCH_MIGHT_HAVE_PC_SERIO
20 bool
21 help
22 Select this config option from the architecture Kconfig if
23 the architecture might use a PC serio device (i8042) to
24 communicate with keyboard, mouse, etc.
25
19if SERIO 26if SERIO
20 27
21config SERIO_I8042 28config SERIO_I8042
22 tristate "i8042 PC Keyboard controller" 29 tristate "i8042 PC Keyboard controller"
23 default y 30 default y
24 depends on !PARISC && (!ARM || FOOTBRIDGE_HOST) && \ 31 depends on ARCH_MIGHT_HAVE_PC_SERIO
25 (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN && !S390 && \
26 !ARC
27 help 32 help
28 i8042 is the chip over which the standard AT keyboard and PS/2 33 i8042 is the chip over which the standard AT keyboard and PS/2
29 mouse are connected to the computer. If you use these devices, 34 mouse are connected to the computer. If you use these devices,
diff --git a/drivers/input/serio/altera_ps2.c b/drivers/input/serio/altera_ps2.c
index 4777a73cd390..cce69d6b9587 100644
--- a/drivers/input/serio/altera_ps2.c
+++ b/drivers/input/serio/altera_ps2.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/input.h> 15#include <linux/input.h>
17#include <linux/serio.h> 16#include <linux/serio.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
index b7c206db0df8..762b08432de0 100644
--- a/drivers/input/serio/ambakmi.c
+++ b/drivers/input/serio/ambakmi.c
@@ -10,7 +10,6 @@
10 * (at your option) any later version. 10 * (at your option) any later version.
11 */ 11 */
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/serio.h> 13#include <linux/serio.h>
15#include <linux/errno.h> 14#include <linux/errno.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
diff --git a/drivers/input/serio/hyperv-keyboard.c b/drivers/input/serio/hyperv-keyboard.c
index 3a83c3c14b23..613261994621 100644
--- a/drivers/input/serio/hyperv-keyboard.c
+++ b/drivers/input/serio/hyperv-keyboard.c
@@ -160,7 +160,9 @@ static void hv_kbd_on_receive(struct hv_device *hv_dev,
160 if (info & IS_E0) 160 if (info & IS_E0)
161 serio_interrupt(kbd_dev->hv_serio, 161 serio_interrupt(kbd_dev->hv_serio,
162 XTKBD_EMUL0, 0); 162 XTKBD_EMUL0, 0);
163 163 if (info & IS_E1)
164 serio_interrupt(kbd_dev->hv_serio,
165 XTKBD_EMUL1, 0);
164 scan_code = __le16_to_cpu(ks_msg->make_code); 166 scan_code = __le16_to_cpu(ks_msg->make_code);
165 if (info & IS_BREAK) 167 if (info & IS_BREAK)
166 scan_code |= XTKBD_RELEASE; 168 scan_code |= XTKBD_RELEASE;
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 07a8363f3c5c..75516996db20 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -18,7 +18,6 @@
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/serio.h> 19#include <linux/serio.h>
20#include <linux/i8042.h> 20#include <linux/i8042.h>
21#include <linux/init.h>
22#include <linux/libps2.h> 21#include <linux/libps2.h>
23 22
24#define DRIVER_DESC "PS/2 driver library" 23#define DRIVER_DESC "PS/2 driver library"
diff --git a/drivers/input/serio/olpc_apsp.c b/drivers/input/serio/olpc_apsp.c
index 51b1d40cc286..5d2fe7ece7ca 100644
--- a/drivers/input/serio/olpc_apsp.c
+++ b/drivers/input/serio/olpc_apsp.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/init.h>
20#include <linux/serio.h> 19#include <linux/serio.h>
21#include <linux/err.h> 20#include <linux/err.h>
22#include <linux/platform_device.h> 21#include <linux/platform_device.h>
diff --git a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
index 76f83836fd5a..e862c6ea9d9e 100644
--- a/drivers/input/serio/pcips2.c
+++ b/drivers/input/serio/pcips2.c
@@ -16,7 +16,6 @@
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/init.h>
20#include <linux/serio.h> 19#include <linux/serio.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <asm/io.h> 21#include <asm/io.h>
@@ -181,7 +180,6 @@ static void pcips2_remove(struct pci_dev *dev)
181 struct pcips2_data *ps2if = pci_get_drvdata(dev); 180 struct pcips2_data *ps2if = pci_get_drvdata(dev);
182 181
183 serio_unregister_port(ps2if->io); 182 serio_unregister_port(ps2if->io);
184 pci_set_drvdata(dev, NULL);
185 kfree(ps2if); 183 kfree(ps2if);
186 pci_release_regions(dev); 184 pci_release_regions(dev);
187 pci_disable_device(dev); 185 pci_disable_device(dev);
diff --git a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
index 7a65a1bc5226..594256c38554 100644
--- a/drivers/input/serio/q40kbd.c
+++ b/drivers/input/serio/q40kbd.c
@@ -30,7 +30,6 @@
30 */ 30 */
31 31
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h>
34#include <linux/serio.h> 33#include <linux/serio.h>
35#include <linux/interrupt.h> 34#include <linux/interrupt.h>
36#include <linux/err.h> 35#include <linux/err.h>
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index 567566ae0dae..e462e7791bb8 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -29,7 +29,6 @@
29 29
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/init.h>
33#include <linux/serio.h> 32#include <linux/serio.h>
34#include <linux/err.h> 33#include <linux/err.h>
35#include <linux/platform_device.h> 34#include <linux/platform_device.h>
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 59df2e7317a3..c9a02fe57576 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -15,7 +15,6 @@
15#include <linux/poll.h> 15#include <linux/poll.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/serio.h> 17#include <linux/serio.h>
18#include <linux/init.h>
19#include <linux/major.h> 18#include <linux/major.h>
20#include <linux/device.h> 19#include <linux/device.h>
21#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index dfbcd872f95e..e6cf52ebad87 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -20,7 +20,6 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/init.h>
24#include <linux/list.h> 23#include <linux/list.h>
25#include <linux/io.h> 24#include <linux/io.h>
26#include <linux/of_address.h> 25#include <linux/of_address.h>
diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c
index e062ec899ca1..889f6b77e8cb 100644
--- a/drivers/input/tablet/acecad.c
+++ b/drivers/input/tablet/acecad.c
@@ -28,7 +28,6 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/usb/input.h> 31#include <linux/usb/input.h>
33 32
34/* 33/*
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index ee83c3904ee8..e7f966da6efa 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -74,7 +74,6 @@
74#include <linux/kernel.h> 74#include <linux/kernel.h>
75#include <linux/slab.h> 75#include <linux/slab.h>
76#include <linux/module.h> 76#include <linux/module.h>
77#include <linux/init.h>
78#include <linux/usb/input.h> 77#include <linux/usb/input.h>
79#include <asm/uaccess.h> 78#include <asm/uaccess.h>
80#include <asm/unaligned.h> 79#include <asm/unaligned.h>
diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
index 29e01ab6859f..caecffe8caff 100644
--- a/drivers/input/tablet/gtco.c
+++ b/drivers/input/tablet/gtco.c
@@ -53,7 +53,6 @@ Scott Hill shill@gtcocalcomp.com
53#include <linux/kernel.h> 53#include <linux/kernel.h>
54#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/errno.h> 55#include <linux/errno.h>
56#include <linux/init.h>
57#include <linux/slab.h> 56#include <linux/slab.h>
58#include <linux/input.h> 57#include <linux/input.h>
59#include <linux/usb.h> 58#include <linux/usb.h>
diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c
index 5cc04124995c..cd852059b99e 100644
--- a/drivers/input/tablet/hanwang.c
+++ b/drivers/input/tablet/hanwang.c
@@ -26,7 +26,6 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h>
30#include <linux/usb/input.h> 29#include <linux/usb/input.h>
31 30
32#define DRIVER_AUTHOR "Xing Wei <weixing@hanwang.com.cn>" 31#define DRIVER_AUTHOR "Xing Wei <weixing@hanwang.com.cn>"
diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c
index 3fba74b9b602..d2ac7c2b5b82 100644
--- a/drivers/input/tablet/kbtab.c
+++ b/drivers/input/tablet/kbtab.c
@@ -1,7 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/slab.h> 2#include <linux/slab.h>
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/init.h>
5#include <linux/usb/input.h> 4#include <linux/usb/input.h>
6#include <asm/unaligned.h> 5#include <asm/unaligned.h>
7 6
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index b79d45198d82..9ebf0ed3b3b3 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -86,7 +86,6 @@
86#include <linux/slab.h> 86#include <linux/slab.h>
87#include <linux/module.h> 87#include <linux/module.h>
88#include <linux/mod_devicetable.h> 88#include <linux/mod_devicetable.h>
89#include <linux/init.h>
90#include <linux/usb/input.h> 89#include <linux/usb/input.h>
91#include <linux/power_supply.h> 90#include <linux/power_supply.h>
92#include <asm/unaligned.h> 91#include <asm/unaligned.h>
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 867e7c33ac55..b16ebef5b911 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -304,7 +304,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
304 struct usb_device *dev = interface_to_usbdev(intf); 304 struct usb_device *dev = interface_to_usbdev(intf);
305 char limit = 0; 305 char limit = 0;
306 /* result has to be defined as int for some devices */ 306 /* result has to be defined as int for some devices */
307 int result = 0; 307 int result = 0, touch_max = 0;
308 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0; 308 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
309 unsigned char *report; 309 unsigned char *report;
310 310
@@ -351,7 +351,8 @@ static int wacom_parse_hid(struct usb_interface *intf,
351 if (usage == WCM_DESKTOP) { 351 if (usage == WCM_DESKTOP) {
352 if (finger) { 352 if (finger) {
353 features->device_type = BTN_TOOL_FINGER; 353 features->device_type = BTN_TOOL_FINGER;
354 354 /* touch device at least supports one touch point */
355 touch_max = 1;
355 switch (features->type) { 356 switch (features->type) {
356 case TABLETPC2FG: 357 case TABLETPC2FG:
357 features->pktlen = WACOM_PKGLEN_TPC2FG; 358 features->pktlen = WACOM_PKGLEN_TPC2FG;
@@ -504,6 +505,8 @@ static int wacom_parse_hid(struct usb_interface *intf,
504 } 505 }
505 506
506 out: 507 out:
508 if (!features->touch_max && touch_max)
509 features->touch_max = touch_max;
507 result = 0; 510 result = 0;
508 kfree(report); 511 kfree(report);
509 return result; 512 return result;
@@ -1194,12 +1197,15 @@ static void wacom_wireless_work(struct work_struct *work)
1194 wacom_wac1->features.device_type = BTN_TOOL_PEN; 1197 wacom_wac1->features.device_type = BTN_TOOL_PEN;
1195 snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", 1198 snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen",
1196 wacom_wac1->features.name); 1199 wacom_wac1->features.name);
1200 wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
1201 wacom_wac1->shared->type = wacom_wac1->features.type;
1197 error = wacom_register_input(wacom1); 1202 error = wacom_register_input(wacom1);
1198 if (error) 1203 if (error)
1199 goto fail; 1204 goto fail;
1200 1205
1201 /* Touch interface */ 1206 /* Touch interface */
1202 if (wacom_wac1->features.touch_max) { 1207 if (wacom_wac1->features.touch_max ||
1208 wacom_wac1->features.type == INTUOSHT) {
1203 wacom_wac2->features = 1209 wacom_wac2->features =
1204 *((struct wacom_features *)id->driver_info); 1210 *((struct wacom_features *)id->driver_info);
1205 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1211 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
@@ -1214,6 +1220,10 @@ static void wacom_wireless_work(struct work_struct *work)
1214 error = wacom_register_input(wacom2); 1220 error = wacom_register_input(wacom2);
1215 if (error) 1221 if (error)
1216 goto fail; 1222 goto fail;
1223
1224 if (wacom_wac1->features.type == INTUOSHT &&
1225 wacom_wac1->features.touch_max)
1226 wacom_wac->shared->touch_input = wacom_wac2->input;
1217 } 1227 }
1218 1228
1219 error = wacom_initialize_battery(wacom); 1229 error = wacom_initialize_battery(wacom);
@@ -1322,7 +1332,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1322 * HID descriptor. If this is the touch interface (wMaxPacketSize 1332 * HID descriptor. If this is the touch interface (wMaxPacketSize
1323 * of WACOM_PKGLEN_BBTOUCH3), override the table values. 1333 * of WACOM_PKGLEN_BBTOUCH3), override the table values.
1324 */ 1334 */
1325 if (features->type >= INTUOS5S && features->type <= INTUOSPL) { 1335 if (features->type >= INTUOS5S && features->type <= INTUOSHT) {
1326 if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) { 1336 if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) {
1327 features->device_type = BTN_TOOL_FINGER; 1337 features->device_type = BTN_TOOL_FINGER;
1328 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 1338 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
@@ -1393,6 +1403,11 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1393 } 1403 }
1394 } 1404 }
1395 1405
1406 if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) {
1407 if (wacom_wac->features.device_type == BTN_TOOL_FINGER)
1408 wacom_wac->shared->touch_input = wacom_wac->input;
1409 }
1410
1396 return 0; 1411 return 0;
1397 1412
1398 fail5: wacom_destroy_leds(wacom); 1413 fail5: wacom_destroy_leds(wacom);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 782c2535f1d8..05f371df6c40 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -210,6 +210,62 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
210 return 1; 210 return 1;
211} 211}
212 212
213static int wacom_dtus_irq(struct wacom_wac *wacom)
214{
215 char *data = wacom->data;
216 struct input_dev *input = wacom->input;
217 unsigned short prox, pressure = 0;
218
219 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
220 dev_dbg(input->dev.parent,
221 "%s: received unknown report #%d", __func__, data[0]);
222 return 0;
223 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
224 input_report_key(input, BTN_0, (data[1] & 0x01));
225 input_report_key(input, BTN_1, (data[1] & 0x02));
226 input_report_key(input, BTN_2, (data[1] & 0x04));
227 input_report_key(input, BTN_3, (data[1] & 0x08));
228 input_report_abs(input, ABS_MISC,
229 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
230 /*
231 * Serial number is required when expresskeys are
232 * reported through pen interface.
233 */
234 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
235 return 1;
236 } else {
237 prox = data[1] & 0x80;
238 if (prox) {
239 switch ((data[1] >> 3) & 3) {
240 case 1: /* Rubber */
241 wacom->tool[0] = BTN_TOOL_RUBBER;
242 wacom->id[0] = ERASER_DEVICE_ID;
243 break;
244
245 case 2: /* Pen */
246 wacom->tool[0] = BTN_TOOL_PEN;
247 wacom->id[0] = STYLUS_DEVICE_ID;
248 break;
249 }
250 }
251
252 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
253 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
254 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
255 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
256 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
257 input_report_abs(input, ABS_PRESSURE, pressure);
258 input_report_key(input, BTN_TOUCH, pressure > 10);
259
260 if (!prox) /* out-prox */
261 wacom->id[0] = 0;
262 input_report_key(input, wacom->tool[0], prox);
263 input_report_abs(input, ABS_MISC, wacom->id[0]);
264 input_event(input, EV_MSC, MSC_SERIAL, 1);
265 return 1;
266 }
267}
268
213static int wacom_graphire_irq(struct wacom_wac *wacom) 269static int wacom_graphire_irq(struct wacom_wac *wacom)
214{ 270{
215 struct wacom_features *features = &wacom->features; 271 struct wacom_features *features = &wacom->features;
@@ -331,7 +387,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
331 387
332 /* Enter report */ 388 /* Enter report */
333 if ((data[1] & 0xfc) == 0xc0) { 389 if ((data[1] & 0xfc) == 0xc0) {
334 if (features->quirks == WACOM_QUIRK_MULTI_INPUT) 390 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
335 wacom->shared->stylus_in_proximity = true; 391 wacom->shared->stylus_in_proximity = true;
336 392
337 /* serial number of the tool */ 393 /* serial number of the tool */
@@ -436,7 +492,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
436 492
437 /* Exit report */ 493 /* Exit report */
438 if ((data[1] & 0xfe) == 0x80) { 494 if ((data[1] & 0xfe) == 0x80) {
439 if (features->quirks == WACOM_QUIRK_MULTI_INPUT) 495 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
440 wacom->shared->stylus_in_proximity = false; 496 wacom->shared->stylus_in_proximity = false;
441 497
442 /* 498 /*
@@ -1151,8 +1207,8 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1151 int width, height; 1207 int width, height;
1152 1208
1153 if (features->type >= INTUOSPS && features->type <= INTUOSPL) { 1209 if (features->type >= INTUOSPS && features->type <= INTUOSPL) {
1154 width = data[5]; 1210 width = data[5] * 100;
1155 height = data[6]; 1211 height = data[6] * 100;
1156 } else { 1212 } else {
1157 /* 1213 /*
1158 * "a" is a scaled-down area which we assume is 1214 * "a" is a scaled-down area which we assume is
@@ -1176,10 +1232,16 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1176static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) 1232static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1177{ 1233{
1178 struct input_dev *input = wacom->input; 1234 struct input_dev *input = wacom->input;
1235 struct wacom_features *features = &wacom->features;
1179 1236
1180 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); 1237 if (features->type == INTUOSHT) {
1238 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
1239 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
1240 } else {
1241 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1242 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1243 }
1181 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); 1244 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1182 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1183 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); 1245 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1184} 1246}
1185 1247
@@ -1213,13 +1275,23 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
1213 1275
1214static int wacom_bpt_pen(struct wacom_wac *wacom) 1276static int wacom_bpt_pen(struct wacom_wac *wacom)
1215{ 1277{
1278 struct wacom_features *features = &wacom->features;
1216 struct input_dev *input = wacom->input; 1279 struct input_dev *input = wacom->input;
1217 unsigned char *data = wacom->data; 1280 unsigned char *data = wacom->data;
1218 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; 1281 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1219 1282
1220 if (data[0] != 0x02) 1283 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
1221 return 0; 1284 return 0;
1222 1285
1286 if (data[0] == WACOM_REPORT_USB) {
1287 if (features->type == INTUOSHT && features->touch_max) {
1288 input_report_switch(wacom->shared->touch_input,
1289 SW_MUTE_DEVICE, data[8] & 0x40);
1290 input_sync(wacom->shared->touch_input);
1291 }
1292 return 0;
1293 }
1294
1223 prox = (data[1] & 0x20) == 0x20; 1295 prox = (data[1] & 0x20) == 0x20;
1224 1296
1225 /* 1297 /*
@@ -1252,8 +1324,8 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
1252 * touching and applying pressure; do not report negative 1324 * touching and applying pressure; do not report negative
1253 * distance. 1325 * distance.
1254 */ 1326 */
1255 if (data[8] <= wacom->features.distance_max) 1327 if (data[8] <= features->distance_max)
1256 d = wacom->features.distance_max - data[8]; 1328 d = features->distance_max - data[8];
1257 1329
1258 pen = data[1] & 0x01; 1330 pen = data[1] & 0x01;
1259 btn1 = data[1] & 0x02; 1331 btn1 = data[1] & 0x02;
@@ -1297,13 +1369,20 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1297 unsigned char *data = wacom->data; 1369 unsigned char *data = wacom->data;
1298 int connected; 1370 int connected;
1299 1371
1300 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80) 1372 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
1301 return 0; 1373 return 0;
1302 1374
1303 connected = data[1] & 0x01; 1375 connected = data[1] & 0x01;
1304 if (connected) { 1376 if (connected) {
1305 int pid, battery; 1377 int pid, battery;
1306 1378
1379 if ((wacom->shared->type == INTUOSHT) &&
1380 wacom->shared->touch_max) {
1381 input_report_switch(wacom->shared->touch_input,
1382 SW_MUTE_DEVICE, data[5] & 0x40);
1383 input_sync(wacom->shared->touch_input);
1384 }
1385
1307 pid = get_unaligned_be16(&data[6]); 1386 pid = get_unaligned_be16(&data[6]);
1308 battery = data[5] & 0x3f; 1387 battery = data[5] & 0x3f;
1309 if (wacom->pid != pid) { 1388 if (wacom->pid != pid) {
@@ -1348,6 +1427,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1348 sync = wacom_dtu_irq(wacom_wac); 1427 sync = wacom_dtu_irq(wacom_wac);
1349 break; 1428 break;
1350 1429
1430 case DTUS:
1431 sync = wacom_dtus_irq(wacom_wac);
1432 break;
1433
1351 case INTUOS: 1434 case INTUOS:
1352 case INTUOS3S: 1435 case INTUOS3S:
1353 case INTUOS3: 1436 case INTUOS3:
@@ -1391,6 +1474,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1391 break; 1474 break;
1392 1475
1393 case BAMBOO_PT: 1476 case BAMBOO_PT:
1477 case INTUOSHT:
1394 sync = wacom_bpt_irq(wacom_wac, len); 1478 sync = wacom_bpt_irq(wacom_wac, len);
1395 break; 1479 break;
1396 1480
@@ -1459,7 +1543,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1459 1543
1460 /* these device have multiple inputs */ 1544 /* these device have multiple inputs */
1461 if (features->type >= WIRELESS || 1545 if (features->type >= WIRELESS ||
1462 (features->type >= INTUOS5S && features->type <= INTUOSPL) || 1546 (features->type >= INTUOS5S && features->type <= INTUOSHT) ||
1463 (features->oVid && features->oPid)) 1547 (features->oVid && features->oPid))
1464 features->quirks |= WACOM_QUIRK_MULTI_INPUT; 1548 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
1465 1549
@@ -1538,7 +1622,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1538 1622
1539 wacom_abs_set_axis(input_dev, wacom_wac); 1623 wacom_abs_set_axis(input_dev, wacom_wac);
1540 1624
1541 switch (wacom_wac->features.type) { 1625 switch (features->type) {
1542 case WACOM_MO: 1626 case WACOM_MO:
1543 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 1627 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1544 /* fall through */ 1628 /* fall through */
@@ -1749,8 +1833,14 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1749 1833
1750 /* fall through */ 1834 /* fall through */
1751 1835
1836 case DTUS:
1752 case PL: 1837 case PL:
1753 case DTU: 1838 case DTU:
1839 if (features->type == DTUS) {
1840 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1841 for (i = 0; i < 3; i++)
1842 __set_bit(BTN_0 + i, input_dev->keybit);
1843 }
1754 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1844 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1755 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1845 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1756 __set_bit(BTN_STYLUS, input_dev->keybit); 1846 __set_bit(BTN_STYLUS, input_dev->keybit);
@@ -1771,33 +1861,50 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1771 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1861 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1772 break; 1862 break;
1773 1863
1864 case INTUOSHT:
1865 if (features->touch_max &&
1866 features->device_type == BTN_TOOL_FINGER) {
1867 input_dev->evbit[0] |= BIT_MASK(EV_SW);
1868 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
1869 }
1870 /* fall through */
1871
1774 case BAMBOO_PT: 1872 case BAMBOO_PT:
1775 __clear_bit(ABS_MISC, input_dev->absbit); 1873 __clear_bit(ABS_MISC, input_dev->absbit);
1776 1874
1777 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1778
1779 if (features->device_type == BTN_TOOL_FINGER) { 1875 if (features->device_type == BTN_TOOL_FINGER) {
1780 unsigned int flags = INPUT_MT_POINTER;
1781 1876
1782 __set_bit(BTN_LEFT, input_dev->keybit); 1877 __set_bit(BTN_LEFT, input_dev->keybit);
1783 __set_bit(BTN_FORWARD, input_dev->keybit); 1878 __set_bit(BTN_FORWARD, input_dev->keybit);
1784 __set_bit(BTN_BACK, input_dev->keybit); 1879 __set_bit(BTN_BACK, input_dev->keybit);
1785 __set_bit(BTN_RIGHT, input_dev->keybit); 1880 __set_bit(BTN_RIGHT, input_dev->keybit);
1786 1881
1787 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 1882 if (features->touch_max) {
1788 input_set_abs_params(input_dev, 1883 /* touch interface */
1884 unsigned int flags = INPUT_MT_POINTER;
1885
1886 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1887 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1888 input_set_abs_params(input_dev,
1789 ABS_MT_TOUCH_MAJOR, 1889 ABS_MT_TOUCH_MAJOR,
1790 0, features->x_max, 0, 0); 1890 0, features->x_max, 0, 0);
1791 input_set_abs_params(input_dev, 1891 input_set_abs_params(input_dev,
1792 ABS_MT_TOUCH_MINOR, 1892 ABS_MT_TOUCH_MINOR,
1793 0, features->y_max, 0, 0); 1893 0, features->y_max, 0, 0);
1894 } else {
1895 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1896 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1897 flags = 0;
1898 }
1899 input_mt_init_slots(input_dev, features->touch_max, flags);
1794 } else { 1900 } else {
1795 __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1901 /* buttons/keys only interface */
1796 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1902 __clear_bit(ABS_X, input_dev->absbit);
1797 flags = 0; 1903 __clear_bit(ABS_Y, input_dev->absbit);
1904 __clear_bit(BTN_TOUCH, input_dev->keybit);
1798 } 1905 }
1799 input_mt_init_slots(input_dev, features->touch_max, flags);
1800 } else if (features->device_type == BTN_TOOL_PEN) { 1906 } else if (features->device_type == BTN_TOOL_PEN) {
1907 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1801 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1908 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1802 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1909 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1803 __set_bit(BTN_STYLUS, input_dev->keybit); 1910 __set_bit(BTN_STYLUS, input_dev->keybit);
@@ -2055,6 +2162,9 @@ static const struct wacom_features wacom_features_0xCE =
2055static const struct wacom_features wacom_features_0xF0 = 2162static const struct wacom_features wacom_features_0xF0 =
2056 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511, 2163 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
2057 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2164 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2165static const struct wacom_features wacom_features_0xFB =
2166 { "Wacom DTU1031", WACOM_PKGLEN_DTUS, 22096, 13960, 511,
2167 0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2058static const struct wacom_features wacom_features_0x57 = 2168static const struct wacom_features wacom_features_0x57 =
2059 { "Wacom DTK2241", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047, 2169 { "Wacom DTK2241", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
2060 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES}; 2170 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES};
@@ -2200,6 +2310,17 @@ static const struct wacom_features wacom_features_0x300 =
2200static const struct wacom_features wacom_features_0x301 = 2310static const struct wacom_features wacom_features_0x301 =
2201 { "Wacom Bamboo One M", WACOM_PKGLEN_BBPEN, 21648, 13530, 1023, 2311 { "Wacom Bamboo One M", WACOM_PKGLEN_BBPEN, 21648, 13530, 1023,
2202 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2312 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2313static const struct wacom_features wacom_features_0x302 =
2314 { "Wacom Intuos PT S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023,
2315 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2316 .touch_max = 16 };
2317static const struct wacom_features wacom_features_0x303 =
2318 { "Wacom Intuos PT M", WACOM_PKGLEN_BBPEN, 21600, 13500, 1023,
2319 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2320 .touch_max = 16 };
2321static const struct wacom_features wacom_features_0x30E =
2322 { "Wacom Intuos S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023,
2323 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2203static const struct wacom_features wacom_features_0x6004 = 2324static const struct wacom_features wacom_features_0x6004 =
2204 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255, 2325 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
2205 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2326 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2337,6 +2458,9 @@ const struct usb_device_id wacom_ids[] = {
2337 { USB_DEVICE_WACOM(0x10F) }, 2458 { USB_DEVICE_WACOM(0x10F) },
2338 { USB_DEVICE_WACOM(0x300) }, 2459 { USB_DEVICE_WACOM(0x300) },
2339 { USB_DEVICE_WACOM(0x301) }, 2460 { USB_DEVICE_WACOM(0x301) },
2461 { USB_DEVICE_DETAILED(0x302, USB_CLASS_HID, 0, 0) },
2462 { USB_DEVICE_DETAILED(0x303, USB_CLASS_HID, 0, 0) },
2463 { USB_DEVICE_DETAILED(0x30E, USB_CLASS_HID, 0, 0) },
2340 { USB_DEVICE_WACOM(0x304) }, 2464 { USB_DEVICE_WACOM(0x304) },
2341 { USB_DEVICE_DETAILED(0x314, USB_CLASS_HID, 0, 0) }, 2465 { USB_DEVICE_DETAILED(0x314, USB_CLASS_HID, 0, 0) },
2342 { USB_DEVICE_DETAILED(0x315, USB_CLASS_HID, 0, 0) }, 2466 { USB_DEVICE_DETAILED(0x315, USB_CLASS_HID, 0, 0) },
@@ -2347,6 +2471,7 @@ const struct usb_device_id wacom_ids[] = {
2347 { USB_DEVICE_WACOM(0xF8) }, 2471 { USB_DEVICE_WACOM(0xF8) },
2348 { USB_DEVICE_DETAILED(0xF6, USB_CLASS_HID, 0, 0) }, 2472 { USB_DEVICE_DETAILED(0xF6, USB_CLASS_HID, 0, 0) },
2349 { USB_DEVICE_WACOM(0xFA) }, 2473 { USB_DEVICE_WACOM(0xFA) },
2474 { USB_DEVICE_WACOM(0xFB) },
2350 { USB_DEVICE_WACOM(0x0307) }, 2475 { USB_DEVICE_WACOM(0x0307) },
2351 { USB_DEVICE_DETAILED(0x0309, USB_CLASS_HID, 0, 0) }, 2476 { USB_DEVICE_DETAILED(0x0309, USB_CLASS_HID, 0, 0) },
2352 { USB_DEVICE_LENOVO(0x6004) }, 2477 { USB_DEVICE_LENOVO(0x6004) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index fd23a3790605..f69c0ebe7fa9 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -12,7 +12,7 @@
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14/* maximum packet length for USB devices */ 14/* maximum packet length for USB devices */
15#define WACOM_PKGLEN_MAX 64 15#define WACOM_PKGLEN_MAX 68
16 16
17#define WACOM_NAME_MAX 64 17#define WACOM_NAME_MAX 64
18 18
@@ -29,6 +29,7 @@
29#define WACOM_PKGLEN_WIRELESS 32 29#define WACOM_PKGLEN_WIRELESS 32
30#define WACOM_PKGLEN_MTOUCH 62 30#define WACOM_PKGLEN_MTOUCH 62
31#define WACOM_PKGLEN_MTTPC 40 31#define WACOM_PKGLEN_MTTPC 40
32#define WACOM_PKGLEN_DTUS 68
32 33
33/* wacom data size per MT contact */ 34/* wacom data size per MT contact */
34#define WACOM_BYTES_PER_MT_PACKET 11 35#define WACOM_BYTES_PER_MT_PACKET 11
@@ -47,13 +48,17 @@
47#define WACOM_REPORT_INTUOSWRITE 6 48#define WACOM_REPORT_INTUOSWRITE 6
48#define WACOM_REPORT_INTUOSPAD 12 49#define WACOM_REPORT_INTUOSPAD 12
49#define WACOM_REPORT_INTUOS5PAD 3 50#define WACOM_REPORT_INTUOS5PAD 3
51#define WACOM_REPORT_DTUSPAD 21
50#define WACOM_REPORT_TPC1FG 6 52#define WACOM_REPORT_TPC1FG 6
51#define WACOM_REPORT_TPC2FG 13 53#define WACOM_REPORT_TPC2FG 13
52#define WACOM_REPORT_TPCMT 13 54#define WACOM_REPORT_TPCMT 13
53#define WACOM_REPORT_TPCHID 15 55#define WACOM_REPORT_TPCHID 15
54#define WACOM_REPORT_TPCST 16 56#define WACOM_REPORT_TPCST 16
57#define WACOM_REPORT_DTUS 17
55#define WACOM_REPORT_TPC1FGE 18 58#define WACOM_REPORT_TPC1FGE 18
56#define WACOM_REPORT_24HDT 1 59#define WACOM_REPORT_24HDT 1
60#define WACOM_REPORT_WL 128
61#define WACOM_REPORT_USB 192
57 62
58/* device quirks */ 63/* device quirks */
59#define WACOM_QUIRK_MULTI_INPUT 0x0001 64#define WACOM_QUIRK_MULTI_INPUT 0x0001
@@ -68,6 +73,7 @@ enum {
68 PTU, 73 PTU,
69 PL, 74 PL,
70 DTU, 75 DTU,
76 DTUS,
71 INTUOS, 77 INTUOS,
72 INTUOS3S, 78 INTUOS3S,
73 INTUOS3, 79 INTUOS3,
@@ -81,6 +87,7 @@ enum {
81 INTUOSPS, 87 INTUOSPS,
82 INTUOSPM, 88 INTUOSPM,
83 INTUOSPL, 89 INTUOSPL,
90 INTUOSHT,
84 WACOM_21UX2, 91 WACOM_21UX2,
85 WACOM_22HD, 92 WACOM_22HD,
86 DTK, 93 DTK,
@@ -129,6 +136,10 @@ struct wacom_features {
129struct wacom_shared { 136struct wacom_shared {
130 bool stylus_in_proximity; 137 bool stylus_in_proximity;
131 bool touch_down; 138 bool touch_down;
139 /* for wireless device to access USB interfaces */
140 unsigned touch_max;
141 int type;
142 struct input_dev *touch_input;
132}; 143};
133 144
134struct wacom_wac { 145struct wacom_wac {
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
index f7de14a268bf..544e20c551f8 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -172,7 +172,7 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
172static int pm860x_touch_probe(struct platform_device *pdev) 172static int pm860x_touch_probe(struct platform_device *pdev)
173{ 173{
174 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 174 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
175 struct pm860x_touch_pdata *pdata = pdev->dev.platform_data; 175 struct pm860x_touch_pdata *pdata = dev_get_platdata(&pdev->dev);
176 struct pm860x_touch *touch; 176 struct pm860x_touch *touch;
177 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ 177 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \
178 : chip->companion; 178 : chip->companion;
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index 69834dd3c313..6793c85903ae 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -37,7 +37,6 @@
37 37
38 38
39#include <linux/device.h> 39#include <linux/device.h>
40#include <linux/init.h>
41#include <linux/delay.h> 40#include <linux/delay.h>
42#include <linux/input.h> 41#include <linux/input.h>
43#include <linux/interrupt.h> 42#include <linux/interrupt.h>
@@ -686,7 +685,7 @@ static int ad7877_probe(struct spi_device *spi)
686{ 685{
687 struct ad7877 *ts; 686 struct ad7877 *ts;
688 struct input_dev *input_dev; 687 struct input_dev *input_dev;
689 struct ad7877_platform_data *pdata = spi->dev.platform_data; 688 struct ad7877_platform_data *pdata = dev_get_platdata(&spi->dev);
690 int err; 689 int err;
691 u16 verify; 690 u16 verify;
692 691
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index facd3057b62d..fce590677b7b 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/init.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/input.h> 26#include <linux/input.h>
28#include <linux/interrupt.h> 27#include <linux/interrupt.h>
@@ -470,7 +469,7 @@ static int ad7879_gpio_add(struct ad7879 *ts,
470 469
471static void ad7879_gpio_remove(struct ad7879 *ts) 470static void ad7879_gpio_remove(struct ad7879 *ts)
472{ 471{
473 const struct ad7879_platform_data *pdata = ts->dev->platform_data; 472 const struct ad7879_platform_data *pdata = dev_get_platdata(ts->dev);
474 int ret; 473 int ret;
475 474
476 if (pdata->gpio_export) { 475 if (pdata->gpio_export) {
@@ -495,7 +494,7 @@ static inline void ad7879_gpio_remove(struct ad7879 *ts)
495struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq, 494struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
496 const struct ad7879_bus_ops *bops) 495 const struct ad7879_bus_ops *bops)
497{ 496{
498 struct ad7879_platform_data *pdata = dev->platform_data; 497 struct ad7879_platform_data *pdata = dev_get_platdata(dev);
499 struct ad7879 *ts; 498 struct ad7879 *ts;
500 struct input_dev *input_dev; 499 struct input_dev *input_dev;
501 int err; 500 int err;
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index ea195360747e..45a06e495ed2 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -19,7 +19,6 @@
19 */ 19 */
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/hwmon.h> 21#include <linux/hwmon.h>
22#include <linux/init.h>
23#include <linux/err.h> 22#include <linux/err.h>
24#include <linux/sched.h> 23#include <linux/sched.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
@@ -101,8 +100,7 @@ struct ads7846 {
101 struct spi_device *spi; 100 struct spi_device *spi;
102 struct regulator *reg; 101 struct regulator *reg;
103 102
104#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 103#if IS_ENABLED(CONFIG_HWMON)
105 struct attribute_group *attr_group;
106 struct device *hwmon; 104 struct device *hwmon;
107#endif 105#endif
108 106
@@ -421,7 +419,7 @@ static int ads7845_read12_ser(struct device *dev, unsigned command)
421 return status; 419 return status;
422} 420}
423 421
424#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 422#if IS_ENABLED(CONFIG_HWMON)
425 423
426#define SHOW(name, var, adjust) static ssize_t \ 424#define SHOW(name, var, adjust) static ssize_t \
427name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ 425name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
@@ -479,42 +477,36 @@ static inline unsigned vbatt_adjust(struct ads7846 *ts, ssize_t v)
479SHOW(in0_input, vaux, vaux_adjust) 477SHOW(in0_input, vaux, vaux_adjust)
480SHOW(in1_input, vbatt, vbatt_adjust) 478SHOW(in1_input, vbatt, vbatt_adjust)
481 479
482static struct attribute *ads7846_attributes[] = { 480static umode_t ads7846_is_visible(struct kobject *kobj, struct attribute *attr,
483 &dev_attr_temp0.attr, 481 int index)
484 &dev_attr_temp1.attr, 482{
485 &dev_attr_in0_input.attr, 483 struct device *dev = container_of(kobj, struct device, kobj);
486 &dev_attr_in1_input.attr, 484 struct ads7846 *ts = dev_get_drvdata(dev);
487 NULL,
488};
489
490static struct attribute_group ads7846_attr_group = {
491 .attrs = ads7846_attributes,
492};
493 485
494static struct attribute *ads7843_attributes[] = { 486 if (ts->model == 7843 && index < 2) /* in0, in1 */
495 &dev_attr_in0_input.attr, 487 return 0;
496 &dev_attr_in1_input.attr, 488 if (ts->model == 7845 && index != 2) /* in0 */
497 NULL, 489 return 0;
498};
499 490
500static struct attribute_group ads7843_attr_group = { 491 return attr->mode;
501 .attrs = ads7843_attributes, 492}
502};
503 493
504static struct attribute *ads7845_attributes[] = { 494static struct attribute *ads7846_attributes[] = {
505 &dev_attr_in0_input.attr, 495 &dev_attr_temp0.attr, /* 0 */
496 &dev_attr_temp1.attr, /* 1 */
497 &dev_attr_in0_input.attr, /* 2 */
498 &dev_attr_in1_input.attr, /* 3 */
506 NULL, 499 NULL,
507}; 500};
508 501
509static struct attribute_group ads7845_attr_group = { 502static struct attribute_group ads7846_attr_group = {
510 .attrs = ads7845_attributes, 503 .attrs = ads7846_attributes,
504 .is_visible = ads7846_is_visible,
511}; 505};
506__ATTRIBUTE_GROUPS(ads7846_attr);
512 507
513static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts) 508static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
514{ 509{
515 struct device *hwmon;
516 int err;
517
518 /* hwmon sensors need a reference voltage */ 510 /* hwmon sensors need a reference voltage */
519 switch (ts->model) { 511 switch (ts->model) {
520 case 7846: 512 case 7846:
@@ -535,43 +527,19 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
535 break; 527 break;
536 } 528 }
537 529
538 /* different chips have different sensor groups */ 530 ts->hwmon = hwmon_device_register_with_groups(&spi->dev, spi->modalias,
539 switch (ts->model) { 531 ts, ads7846_attr_groups);
540 case 7846: 532 if (IS_ERR(ts->hwmon))
541 ts->attr_group = &ads7846_attr_group; 533 return PTR_ERR(ts->hwmon);
542 break;
543 case 7845:
544 ts->attr_group = &ads7845_attr_group;
545 break;
546 case 7843:
547 ts->attr_group = &ads7843_attr_group;
548 break;
549 default:
550 dev_dbg(&spi->dev, "ADS%d not recognized\n", ts->model);
551 return 0;
552 }
553
554 err = sysfs_create_group(&spi->dev.kobj, ts->attr_group);
555 if (err)
556 return err;
557
558 hwmon = hwmon_device_register(&spi->dev);
559 if (IS_ERR(hwmon)) {
560 sysfs_remove_group(&spi->dev.kobj, ts->attr_group);
561 return PTR_ERR(hwmon);
562 }
563 534
564 ts->hwmon = hwmon;
565 return 0; 535 return 0;
566} 536}
567 537
568static void ads784x_hwmon_unregister(struct spi_device *spi, 538static void ads784x_hwmon_unregister(struct spi_device *spi,
569 struct ads7846 *ts) 539 struct ads7846 *ts)
570{ 540{
571 if (ts->hwmon) { 541 if (ts->hwmon)
572 sysfs_remove_group(&spi->dev.kobj, ts->attr_group);
573 hwmon_device_unregister(ts->hwmon); 542 hwmon_device_unregister(ts->hwmon);
574 }
575} 543}
576 544
577#else 545#else
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 59aa24002c7b..a70400754e92 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/firmware.h> 16#include <linux/firmware.h>
18#include <linux/i2c.h> 17#include <linux/i2c.h>
@@ -1130,7 +1129,7 @@ static void mxt_input_close(struct input_dev *dev)
1130static int mxt_probe(struct i2c_client *client, 1129static int mxt_probe(struct i2c_client *client,
1131 const struct i2c_device_id *id) 1130 const struct i2c_device_id *id)
1132{ 1131{
1133 const struct mxt_platform_data *pdata = client->dev.platform_data; 1132 const struct mxt_platform_data *pdata = dev_get_platdata(&client->dev);
1134 struct mxt_data *data; 1133 struct mxt_data *data;
1135 struct input_dev *input_dev; 1134 struct input_dev *input_dev;
1136 int error; 1135 int error;
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
index bddabc595077..a7c9d6967d1e 100644
--- a/drivers/input/touchscreen/atmel_tsadcc.c
+++ b/drivers/input/touchscreen/atmel_tsadcc.c
@@ -12,7 +12,6 @@
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
14 */ 14 */
15#include <linux/init.h>
16#include <linux/err.h> 15#include <linux/err.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/module.h> 17#include <linux/module.h>
@@ -182,7 +181,7 @@ static int atmel_tsadcc_probe(struct platform_device *pdev)
182 struct atmel_tsadcc *ts_dev; 181 struct atmel_tsadcc *ts_dev;
183 struct input_dev *input_dev; 182 struct input_dev *input_dev;
184 struct resource *res; 183 struct resource *res;
185 struct at91_tsadcc_data *pdata = pdev->dev.platform_data; 184 struct at91_tsadcc_data *pdata = dev_get_platdata(&pdev->dev);
186 int err; 185 int err;
187 unsigned int prsc; 186 unsigned int prsc;
188 unsigned int reg; 187 unsigned int reg;
diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c
index 8c651985a5c4..5bf1aeeea825 100644
--- a/drivers/input/touchscreen/cy8ctmg110_ts.c
+++ b/drivers/input/touchscreen/cy8ctmg110_ts.c
@@ -178,7 +178,7 @@ static irqreturn_t cy8ctmg110_irq_thread(int irq, void *dev_id)
178static int cy8ctmg110_probe(struct i2c_client *client, 178static int cy8ctmg110_probe(struct i2c_client *client,
179 const struct i2c_device_id *id) 179 const struct i2c_device_id *id)
180{ 180{
181 const struct cy8ctmg110_pdata *pdata = client->dev.platform_data; 181 const struct cy8ctmg110_pdata *pdata = dev_get_platdata(&client->dev);
182 struct cy8ctmg110 *ts; 182 struct cy8ctmg110 *ts;
183 struct input_dev *input_dev; 183 struct input_dev *input_dev;
184 int err; 184 int err;
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 4204841cdc49..eee656f77a2e 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -534,7 +534,7 @@ static void cyttsp_close(struct input_dev *dev)
534struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, 534struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
535 struct device *dev, int irq, size_t xfer_buf_size) 535 struct device *dev, int irq, size_t xfer_buf_size)
536{ 536{
537 const struct cyttsp_platform_data *pdata = dev->platform_data; 537 const struct cyttsp_platform_data *pdata = dev_get_platdata(dev);
538 struct cyttsp *ts; 538 struct cyttsp *ts;
539 struct input_dev *input_dev; 539 struct input_dev *input_dev;
540 int error; 540 int error;
@@ -553,7 +553,7 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
553 553
554 ts->dev = dev; 554 ts->dev = dev;
555 ts->input = input_dev; 555 ts->input = input_dev;
556 ts->pdata = dev->platform_data; 556 ts->pdata = dev_get_platdata(dev);
557 ts->bus_ops = bus_ops; 557 ts->bus_ops = bus_ops;
558 ts->irq = irq; 558 ts->irq = irq;
559 559
diff --git a/drivers/input/touchscreen/cyttsp_i2c_common.c b/drivers/input/touchscreen/cyttsp_i2c_common.c
index 1d7b6f154168..ccefa56ca212 100644
--- a/drivers/input/touchscreen/cyttsp_i2c_common.c
+++ b/drivers/input/touchscreen/cyttsp_i2c_common.c
@@ -31,6 +31,8 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/types.h> 32#include <linux/types.h>
33 33
34#include "cyttsp4_core.h"
35
34int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, 36int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf,
35 u16 addr, u8 length, void *values) 37 u16 addr, u8 length, void *values)
36{ 38{
diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c
index 34ad84105e6e..8ccf7bb4028a 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
19#include <linux/input.h> 18#include <linux/input.h>
@@ -299,7 +298,7 @@ static void da9034_touch_close(struct input_dev *dev)
299 298
300static int da9034_touch_probe(struct platform_device *pdev) 299static int da9034_touch_probe(struct platform_device *pdev)
301{ 300{
302 struct da9034_touch_pdata *pdata = pdev->dev.platform_data; 301 struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev);
303 struct da9034_touch *touch; 302 struct da9034_touch *touch;
304 struct input_dev *input_dev; 303 struct input_dev *input_dev;
305 int ret; 304 int ret;
diff --git a/drivers/input/touchscreen/dynapro.c b/drivers/input/touchscreen/dynapro.c
index 1809677a6513..86237a910876 100644
--- a/drivers/input/touchscreen/dynapro.c
+++ b/drivers/input/touchscreen/dynapro.c
@@ -24,7 +24,6 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/serio.h> 26#include <linux/serio.h>
27#include <linux/init.h>
28 27
29#define DRIVER_DESC "Dynapro serial touchscreen driver" 28#define DRIVER_DESC "Dynapro serial touchscreen driver"
30 29
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 83fa1b15a97f..412a85ec9ba5 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -623,8 +623,9 @@ static int edt_ft5x06_ts_reset(struct i2c_client *client,
623 623
624 if (gpio_is_valid(reset_pin)) { 624 if (gpio_is_valid(reset_pin)) {
625 /* this pulls reset down, enabling the low active reset */ 625 /* this pulls reset down, enabling the low active reset */
626 error = gpio_request_one(reset_pin, GPIOF_OUT_INIT_LOW, 626 error = devm_gpio_request_one(&client->dev, reset_pin,
627 "edt-ft5x06 reset"); 627 GPIOF_OUT_INIT_LOW,
628 "edt-ft5x06 reset");
628 if (error) { 629 if (error) {
629 dev_err(&client->dev, 630 dev_err(&client->dev,
630 "Failed to request GPIO %d as reset pin, error %d\n", 631 "Failed to request GPIO %d as reset pin, error %d\n",
@@ -705,7 +706,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
705 const struct i2c_device_id *id) 706 const struct i2c_device_id *id)
706{ 707{
707 const struct edt_ft5x06_platform_data *pdata = 708 const struct edt_ft5x06_platform_data *pdata =
708 client->dev.platform_data; 709 dev_get_platdata(&client->dev);
709 struct edt_ft5x06_ts_data *tsdata; 710 struct edt_ft5x06_ts_data *tsdata;
710 struct input_dev *input; 711 struct input_dev *input;
711 int error; 712 int error;
@@ -723,8 +724,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
723 return error; 724 return error;
724 725
725 if (gpio_is_valid(pdata->irq_pin)) { 726 if (gpio_is_valid(pdata->irq_pin)) {
726 error = gpio_request_one(pdata->irq_pin, 727 error = devm_gpio_request_one(&client->dev, pdata->irq_pin,
727 GPIOF_IN, "edt-ft5x06 irq"); 728 GPIOF_IN, "edt-ft5x06 irq");
728 if (error) { 729 if (error) {
729 dev_err(&client->dev, 730 dev_err(&client->dev,
730 "Failed to request GPIO %d, error %d\n", 731 "Failed to request GPIO %d, error %d\n",
@@ -733,12 +734,16 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
733 } 734 }
734 } 735 }
735 736
736 tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL); 737 tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL);
737 input = input_allocate_device(); 738 if (!tsdata) {
738 if (!tsdata || !input) {
739 dev_err(&client->dev, "failed to allocate driver data.\n"); 739 dev_err(&client->dev, "failed to allocate driver data.\n");
740 error = -ENOMEM; 740 return -ENOMEM;
741 goto err_free_mem; 741 }
742
743 input = devm_input_allocate_device(&client->dev);
744 if (!input) {
745 dev_err(&client->dev, "failed to allocate input device.\n");
746 return -ENOMEM;
742 } 747 }
743 748
744 mutex_init(&tsdata->mutex); 749 mutex_init(&tsdata->mutex);
@@ -749,7 +754,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
749 error = edt_ft5x06_ts_identify(client, tsdata->name, fw_version); 754 error = edt_ft5x06_ts_identify(client, tsdata->name, fw_version);
750 if (error) { 755 if (error) {
751 dev_err(&client->dev, "touchscreen probe failed\n"); 756 dev_err(&client->dev, "touchscreen probe failed\n");
752 goto err_free_mem; 757 return error;
753 } 758 }
754 759
755 edt_ft5x06_ts_get_defaults(tsdata, pdata); 760 edt_ft5x06_ts_get_defaults(tsdata, pdata);
@@ -776,27 +781,30 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
776 error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, 0); 781 error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, 0);
777 if (error) { 782 if (error) {
778 dev_err(&client->dev, "Unable to init MT slots.\n"); 783 dev_err(&client->dev, "Unable to init MT slots.\n");
779 goto err_free_mem; 784 return error;
780 } 785 }
781 786
782 input_set_drvdata(input, tsdata); 787 input_set_drvdata(input, tsdata);
783 i2c_set_clientdata(client, tsdata); 788 i2c_set_clientdata(client, tsdata);
784 789
785 error = request_threaded_irq(client->irq, NULL, edt_ft5x06_ts_isr, 790 error = devm_request_threaded_irq(&client->dev, client->irq,
786 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 791 NULL, edt_ft5x06_ts_isr,
787 client->name, tsdata); 792 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
793 client->name, tsdata);
788 if (error) { 794 if (error) {
789 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 795 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
790 goto err_free_mem; 796 return error;
791 } 797 }
792 798
793 error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group); 799 error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group);
794 if (error) 800 if (error)
795 goto err_free_irq; 801 return error;
796 802
797 error = input_register_device(input); 803 error = input_register_device(input);
798 if (error) 804 if (error) {
799 goto err_remove_attrs; 805 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
806 return error;
807 }
800 808
801 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); 809 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
802 device_init_wakeup(&client->dev, 1); 810 device_init_wakeup(&client->dev, 1);
@@ -806,40 +814,15 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
806 pdata->irq_pin, pdata->reset_pin); 814 pdata->irq_pin, pdata->reset_pin);
807 815
808 return 0; 816 return 0;
809
810err_remove_attrs:
811 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
812err_free_irq:
813 free_irq(client->irq, tsdata);
814err_free_mem:
815 input_free_device(input);
816 kfree(tsdata);
817
818 if (gpio_is_valid(pdata->irq_pin))
819 gpio_free(pdata->irq_pin);
820
821 return error;
822} 817}
823 818
824static int edt_ft5x06_ts_remove(struct i2c_client *client) 819static int edt_ft5x06_ts_remove(struct i2c_client *client)
825{ 820{
826 const struct edt_ft5x06_platform_data *pdata =
827 dev_get_platdata(&client->dev);
828 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); 821 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
829 822
830 edt_ft5x06_ts_teardown_debugfs(tsdata); 823 edt_ft5x06_ts_teardown_debugfs(tsdata);
831 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group); 824 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
832 825
833 free_irq(client->irq, tsdata);
834 input_unregister_device(tsdata->input);
835
836 if (gpio_is_valid(pdata->irq_pin))
837 gpio_free(pdata->irq_pin);
838 if (gpio_is_valid(pdata->reset_pin))
839 gpio_free(pdata->reset_pin);
840
841 kfree(tsdata);
842
843 return 0; 826 return 0;
844} 827}
845 828
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 1ce3d29ffca5..b1884ddd7a84 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -157,7 +157,7 @@ static void eeti_ts_close(struct input_dev *dev)
157static int eeti_ts_probe(struct i2c_client *client, 157static int eeti_ts_probe(struct i2c_client *client,
158 const struct i2c_device_id *idp) 158 const struct i2c_device_id *idp)
159{ 159{
160 struct eeti_ts_platform_data *pdata = client->dev.platform_data; 160 struct eeti_ts_platform_data *pdata = dev_get_platdata(&client->dev);
161 struct eeti_ts_priv *priv; 161 struct eeti_ts_priv *priv;
162 struct input_dev *input; 162 struct input_dev *input;
163 unsigned int irq_flags; 163 unsigned int irq_flags;
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 054d22583248..e6bcb13680b2 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -18,7 +18,6 @@
18*/ 18*/
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/i2c.h> 21#include <linux/i2c.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/input.h> 23#include <linux/input.h>
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 957423d1471d..8051a4b704ea 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -22,7 +22,6 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/serio.h> 24#include <linux/serio.h>
25#include <linux/init.h>
26#include <linux/ctype.h> 25#include <linux/ctype.h>
27 26
28#define DRIVER_DESC "Elo serial touchscreen driver" 27#define DRIVER_DESC "Elo serial touchscreen driver"
diff --git a/drivers/input/touchscreen/fujitsu_ts.c b/drivers/input/touchscreen/fujitsu_ts.c
index 10794ddbdf58..d0e46a7e183b 100644
--- a/drivers/input/touchscreen/fujitsu_ts.c
+++ b/drivers/input/touchscreen/fujitsu_ts.c
@@ -16,7 +16,6 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/input.h> 17#include <linux/input.h>
18#include <linux/serio.h> 18#include <linux/serio.h>
19#include <linux/init.h>
20 19
21#define DRIVER_DESC "Fujitsu serial touchscreen driver" 20#define DRIVER_DESC "Fujitsu serial touchscreen driver"
22 21
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
index 41c71766bf18..e2ee62615273 100644
--- a/drivers/input/touchscreen/gunze.c
+++ b/drivers/input/touchscreen/gunze.c
@@ -32,7 +32,6 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/input.h> 33#include <linux/input.h>
34#include <linux/serio.h> 34#include <linux/serio.h>
35#include <linux/init.h>
36 35
37#define DRIVER_DESC "Gunze AHL-51S touchscreen driver" 36#define DRIVER_DESC "Gunze AHL-51S touchscreen driver"
38 37
diff --git a/drivers/input/touchscreen/hampshire.c b/drivers/input/touchscreen/hampshire.c
index 0cc47ea98acf..ecb1e0e01328 100644
--- a/drivers/input/touchscreen/hampshire.c
+++ b/drivers/input/touchscreen/hampshire.c
@@ -23,7 +23,6 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/serio.h> 25#include <linux/serio.h>
26#include <linux/init.h>
27 26
28#define DRIVER_DESC "Hampshire serial touchscreen driver" 27#define DRIVER_DESC "Hampshire serial touchscreen driver"
29 28
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 1418bdda61bb..2a5089139818 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -184,7 +184,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
184 const struct i2c_device_id *id) 184 const struct i2c_device_id *id)
185{ 185{
186 struct device *dev = &client->dev; 186 struct device *dev = &client->dev;
187 const struct ili210x_platform_data *pdata = dev->platform_data; 187 const struct ili210x_platform_data *pdata = dev_get_platdata(dev);
188 struct ili210x *priv; 188 struct ili210x *priv;
189 struct input_dev *input; 189 struct input_dev *input;
190 struct panel_info panel; 190 struct panel_info panel;
diff --git a/drivers/input/touchscreen/inexio.c b/drivers/input/touchscreen/inexio.c
index a29c99c32245..adb80b65a259 100644
--- a/drivers/input/touchscreen/inexio.c
+++ b/drivers/input/touchscreen/inexio.c
@@ -23,7 +23,6 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/serio.h> 25#include <linux/serio.h>
26#include <linux/init.h>
27 26
28#define DRIVER_DESC "iNexio serial touchscreen driver" 27#define DRIVER_DESC "iNexio serial touchscreen driver"
29 28
diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c
index e30d837dae2f..4f6b156144e9 100644
--- a/drivers/input/touchscreen/intel-mid-touch.c
+++ b/drivers/input/touchscreen/intel-mid-touch.c
@@ -27,7 +27,6 @@
27 */ 27 */
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/input.h> 30#include <linux/input.h>
32#include <linux/interrupt.h> 31#include <linux/interrupt.h>
33#include <linux/err.h> 32#include <linux/err.h>
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c
index e463a79ffecc..7324c5c0fb86 100644
--- a/drivers/input/touchscreen/jornada720_ts.c
+++ b/drivers/input/touchscreen/jornada720_ts.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/init.h>
18#include <linux/input.h> 17#include <linux/input.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
index 9101ee529c92..2058253b55d9 100644
--- a/drivers/input/touchscreen/lpc32xx_ts.c
+++ b/drivers/input/touchscreen/lpc32xx_ts.c
@@ -15,7 +15,6 @@
15 */ 15 */
16 16
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/init.h>
19#include <linux/input.h> 18#include <linux/input.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
21#include <linux/module.h> 20#include <linux/module.h>
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index 7d2b2136e5ad..0786010d7ed0 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -25,7 +25,6 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/irq.h> 29#include <linux/irq.h>
31#include <linux/interrupt.h> 30#include <linux/interrupt.h>
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c
index 9f84fcd08732..a68ec142ee9a 100644
--- a/drivers/input/touchscreen/max11801_ts.c
+++ b/drivers/input/touchscreen/max11801_ts.c
@@ -33,7 +33,6 @@
33 */ 33 */
34 34
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/init.h>
37#include <linux/i2c.h> 36#include <linux/i2c.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
39#include <linux/input.h> 38#include <linux/input.h>
diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c
index f9f4e0c56eda..647e36f5930e 100644
--- a/drivers/input/touchscreen/mcs5000_ts.c
+++ b/drivers/input/touchscreen/mcs5000_ts.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/i2c.h> 17#include <linux/i2c.h>
19#include <linux/i2c/mcs.h> 18#include <linux/i2c/mcs.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
@@ -194,7 +193,7 @@ static int mcs5000_ts_probe(struct i2c_client *client,
194 struct input_dev *input_dev; 193 struct input_dev *input_dev;
195 int ret; 194 int ret;
196 195
197 if (!client->dev.platform_data) 196 if (!dev_get_platdata(&client->dev))
198 return -EINVAL; 197 return -EINVAL;
199 198
200 data = kzalloc(sizeof(struct mcs5000_ts_data), GFP_KERNEL); 199 data = kzalloc(sizeof(struct mcs5000_ts_data), GFP_KERNEL);
@@ -207,7 +206,7 @@ static int mcs5000_ts_probe(struct i2c_client *client,
207 206
208 data->client = client; 207 data->client = client;
209 data->input_dev = input_dev; 208 data->input_dev = input_dev;
210 data->platform_data = client->dev.platform_data; 209 data->platform_data = dev_get_platdata(&client->dev);
211 210
212 input_dev->name = "MELPAS MCS-5000 Touchscreen"; 211 input_dev->name = "MELPAS MCS-5000 Touchscreen";
213 input_dev->id.bustype = BUS_I2C; 212 input_dev->id.bustype = BUS_I2C;
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 1443532fe6c4..8a598c065391 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/delay.h> 11#include <linux/delay.h>
13#include <linux/of.h> 12#include <linux/of.h>
14#include <linux/i2c.h> 13#include <linux/i2c.h>
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
index eb66b7c37c2f..9b5552a26169 100644
--- a/drivers/input/touchscreen/mtouch.c
+++ b/drivers/input/touchscreen/mtouch.c
@@ -21,7 +21,6 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/serio.h> 23#include <linux/serio.h>
24#include <linux/init.h>
25 24
26#define DRIVER_DESC "MicroTouch serial touchscreen driver" 25#define DRIVER_DESC "MicroTouch serial touchscreen driver"
27 26
diff --git a/drivers/input/touchscreen/pcap_ts.c b/drivers/input/touchscreen/pcap_ts.c
index f22e04dd4e16..cff2376817e5 100644
--- a/drivers/input/touchscreen/pcap_ts.c
+++ b/drivers/input/touchscreen/pcap_ts.c
@@ -11,7 +11,6 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/fs.h> 14#include <linux/fs.h>
16#include <linux/string.h> 15#include <linux/string.h>
17#include <linux/slab.h> 16#include <linux/slab.h>
diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c
index b49f0b836925..417d87379265 100644
--- a/drivers/input/touchscreen/penmount.c
+++ b/drivers/input/touchscreen/penmount.c
@@ -21,7 +21,6 @@
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/input/mt.h> 22#include <linux/input/mt.h>
23#include <linux/serio.h> 23#include <linux/serio.h>
24#include <linux/init.h>
25 24
26#define DRIVER_DESC "PenMount serial touchscreen driver" 25#define DRIVER_DESC "PenMount serial touchscreen driver"
27 26
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 6cc6b36663ff..02392d2061d6 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -128,7 +128,8 @@ static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
128static int pixcir_i2c_ts_probe(struct i2c_client *client, 128static int pixcir_i2c_ts_probe(struct i2c_client *client,
129 const struct i2c_device_id *id) 129 const struct i2c_device_id *id)
130{ 130{
131 const struct pixcir_ts_platform_data *pdata = client->dev.platform_data; 131 const struct pixcir_ts_platform_data *pdata =
132 dev_get_platdata(&client->dev);
132 struct pixcir_i2c_ts_data *tsdata; 133 struct pixcir_i2c_ts_data *tsdata;
133 struct input_dev *input; 134 struct input_dev *input;
134 int error; 135 int error;
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index b061af2c8376..19cb247dbb86 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/init.h>
32#include <linux/delay.h> 31#include <linux/delay.h>
33#include <linux/interrupt.h> 32#include <linux/interrupt.h>
34#include <linux/platform_device.h> 33#include <linux/platform_device.h>
@@ -251,7 +250,7 @@ static int s3c2410ts_probe(struct platform_device *pdev)
251 250
252 ts.dev = dev; 251 ts.dev = dev;
253 252
254 info = pdev->dev.platform_data; 253 info = dev_get_platdata(&pdev->dev);
255 if (!info) { 254 if (!info) {
256 dev_err(dev, "no platform data, cannot attach\n"); 255 dev_err(dev, "no platform data, cannot attach\n");
257 return -EINVAL; 256 return -EINVAL;
@@ -392,7 +391,7 @@ static int s3c2410ts_suspend(struct device *dev)
392static int s3c2410ts_resume(struct device *dev) 391static int s3c2410ts_resume(struct device *dev)
393{ 392{
394 struct platform_device *pdev = to_platform_device(dev); 393 struct platform_device *pdev = to_platform_device(dev);
395 struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; 394 struct s3c2410_ts_mach_info *info = dev_get_platdata(&pdev->dev);
396 395
397 clk_enable(ts.clock); 396 clk_enable(ts.clock);
398 enable_irq(ts.irq_tc); 397 enable_irq(ts.irq_tc);
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 2f03b2f289dd..5c342b3139e8 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -154,7 +154,7 @@ static int st1232_ts_probe(struct i2c_client *client,
154 const struct i2c_device_id *id) 154 const struct i2c_device_id *id)
155{ 155{
156 struct st1232_ts_data *ts; 156 struct st1232_ts_data *ts;
157 struct st1232_pdata *pdata = client->dev.platform_data; 157 struct st1232_pdata *pdata = dev_get_platdata(&client->dev);
158 struct input_dev *input_dev; 158 struct input_dev *input_dev;
159 int error; 159 int error;
160 160
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 59e81b00f244..42ce31afa259 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -15,7 +15,6 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/init.h>
19#include <linux/device.h> 18#include <linux/device.h>
20#include <linux/of.h> 19#include <linux/of.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 2ca5a7bee04e..4e793a17361f 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16 16
17#include <linux/init.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/err.h> 18#include <linux/err.h>
20#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/input/touchscreen/touchit213.c b/drivers/input/touchscreen/touchit213.c
index 5f29e5b8e1c1..c27cf8f3d1ca 100644
--- a/drivers/input/touchscreen/touchit213.c
+++ b/drivers/input/touchscreen/touchit213.c
@@ -21,7 +21,6 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/serio.h> 23#include <linux/serio.h>
24#include <linux/init.h>
25 24
26#define DRIVER_DESC "Sahara TouchIT-213 serial touchscreen driver" 25#define DRIVER_DESC "Sahara TouchIT-213 serial touchscreen driver"
27 26
diff --git a/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c
index 8a2887daf194..4000e5205407 100644
--- a/drivers/input/touchscreen/touchright.c
+++ b/drivers/input/touchscreen/touchright.c
@@ -20,7 +20,6 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/serio.h> 22#include <linux/serio.h>
23#include <linux/init.h>
24 23
25#define DRIVER_DESC "Touchright serial touchscreen driver" 24#define DRIVER_DESC "Touchright serial touchscreen driver"
26 25
diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c
index 588cdcb839dd..ba90f447df75 100644
--- a/drivers/input/touchscreen/touchwin.c
+++ b/drivers/input/touchscreen/touchwin.c
@@ -27,7 +27,6 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/serio.h> 29#include <linux/serio.h>
30#include <linux/init.h>
31 30
32#define DRIVER_DESC "Touchwindow serial touchscreen driver" 31#define DRIVER_DESC "Touchwindow serial touchscreen driver"
33 32
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 811353353917..550adcbbfc23 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -571,7 +571,7 @@ static void tsc2005_setup_spi_xfer(struct tsc2005 *ts)
571 571
572static int tsc2005_probe(struct spi_device *spi) 572static int tsc2005_probe(struct spi_device *spi)
573{ 573{
574 const struct tsc2005_platform_data *pdata = spi->dev.platform_data; 574 const struct tsc2005_platform_data *pdata = dev_get_platdata(&spi->dev);
575 struct tsc2005 *ts; 575 struct tsc2005 *ts;
576 struct input_dev *input_dev; 576 struct input_dev *input_dev;
577 unsigned int max_x, max_y, max_p; 577 unsigned int max_x, max_y, max_p;
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 0b67ba476b4c..1bf9906b5a3f 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -26,6 +26,9 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c/tsc2007.h> 28#include <linux/i2c/tsc2007.h>
29#include <linux/of_device.h>
30#include <linux/of.h>
31#include <linux/of_gpio.h>
29 32
30#define TSC2007_MEASURE_TEMP0 (0x0 << 4) 33#define TSC2007_MEASURE_TEMP0 (0x0 << 4)
31#define TSC2007_MEASURE_AUX (0x2 << 4) 34#define TSC2007_MEASURE_AUX (0x2 << 4)
@@ -72,15 +75,18 @@ struct tsc2007 {
72 u16 model; 75 u16 model;
73 u16 x_plate_ohms; 76 u16 x_plate_ohms;
74 u16 max_rt; 77 u16 max_rt;
75 unsigned long poll_delay;
76 unsigned long poll_period; 78 unsigned long poll_period;
79 int fuzzx;
80 int fuzzy;
81 int fuzzz;
77 82
83 unsigned gpio;
78 int irq; 84 int irq;
79 85
80 wait_queue_head_t wait; 86 wait_queue_head_t wait;
81 bool stopped; 87 bool stopped;
82 88
83 int (*get_pendown_state)(void); 89 int (*get_pendown_state)(struct device *);
84 void (*clear_penirq)(void); 90 void (*clear_penirq)(void);
85}; 91};
86 92
@@ -161,7 +167,7 @@ static bool tsc2007_is_pen_down(struct tsc2007 *ts)
161 if (!ts->get_pendown_state) 167 if (!ts->get_pendown_state)
162 return true; 168 return true;
163 169
164 return ts->get_pendown_state(); 170 return ts->get_pendown_state(&ts->client->dev);
165} 171}
166 172
167static irqreturn_t tsc2007_soft_irq(int irq, void *handle) 173static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
@@ -178,7 +184,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
178 184
179 rt = tsc2007_calculate_pressure(ts, &tc); 185 rt = tsc2007_calculate_pressure(ts, &tc);
180 186
181 if (rt == 0 && !ts->get_pendown_state) { 187 if (!rt && !ts->get_pendown_state) {
182 /* 188 /*
183 * If pressure reported is 0 and we don't have 189 * If pressure reported is 0 and we don't have
184 * callback to check pendown state, we have to 190 * callback to check pendown state, we have to
@@ -228,7 +234,7 @@ static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
228{ 234{
229 struct tsc2007 *ts = handle; 235 struct tsc2007 *ts = handle;
230 236
231 if (!ts->get_pendown_state || likely(ts->get_pendown_state())) 237 if (tsc2007_is_pen_down(ts))
232 return IRQ_WAKE_THREAD; 238 return IRQ_WAKE_THREAD;
233 239
234 if (ts->clear_penirq) 240 if (ts->clear_penirq)
@@ -273,49 +279,134 @@ static void tsc2007_close(struct input_dev *input_dev)
273 tsc2007_stop(ts); 279 tsc2007_stop(ts);
274} 280}
275 281
276static int tsc2007_probe(struct i2c_client *client, 282#ifdef CONFIG_OF
277 const struct i2c_device_id *id) 283static int tsc2007_get_pendown_state_gpio(struct device *dev)
278{ 284{
279 struct tsc2007 *ts; 285 struct i2c_client *client = to_i2c_client(dev);
280 struct tsc2007_platform_data *pdata = client->dev.platform_data; 286 struct tsc2007 *ts = i2c_get_clientdata(client);
281 struct input_dev *input_dev; 287
282 int err; 288 return !gpio_get_value(ts->gpio);
289}
290
291static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
292{
293 struct device_node *np = client->dev.of_node;
294 u32 val32;
295 u64 val64;
283 296
284 if (!pdata) { 297 if (!np) {
285 dev_err(&client->dev, "platform data is required!\n"); 298 dev_err(&client->dev, "missing device tree data\n");
286 return -EINVAL; 299 return -EINVAL;
287 } 300 }
288 301
289 if (!i2c_check_functionality(client->adapter, 302 if (!of_property_read_u32(np, "ti,max-rt", &val32))
290 I2C_FUNC_SMBUS_READ_WORD_DATA)) 303 ts->max_rt = val32;
291 return -EIO; 304 else
305 ts->max_rt = MAX_12BIT;
306
307 if (!of_property_read_u32(np, "ti,fuzzx", &val32))
308 ts->fuzzx = val32;
309
310 if (!of_property_read_u32(np, "ti,fuzzy", &val32))
311 ts->fuzzy = val32;
312
313 if (!of_property_read_u32(np, "ti,fuzzz", &val32))
314 ts->fuzzz = val32;
315
316 if (!of_property_read_u64(np, "ti,poll-period", &val64))
317 ts->poll_period = val64;
318 else
319 ts->poll_period = 1;
292 320
293 ts = kzalloc(sizeof(struct tsc2007), GFP_KERNEL); 321 if (!of_property_read_u32(np, "ti,x-plate-ohms", &val32)) {
294 input_dev = input_allocate_device(); 322 ts->x_plate_ohms = val32;
295 if (!ts || !input_dev) { 323 } else {
296 err = -ENOMEM; 324 dev_err(&client->dev, "missing ti,x-plate-ohms devicetree property.");
297 goto err_free_mem; 325 return -EINVAL;
298 } 326 }
299 327
300 ts->client = client; 328 ts->gpio = of_get_gpio(np, 0);
301 ts->irq = client->irq; 329 if (gpio_is_valid(ts->gpio))
302 ts->input = input_dev; 330 ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
303 init_waitqueue_head(&ts->wait); 331 else
332 dev_warn(&client->dev,
333 "GPIO not specified in DT (of_get_gpio returned %d)\n",
334 ts->gpio);
335
336 return 0;
337}
338#else
339static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
340{
341 dev_err(&client->dev, "platform data is required!\n");
342 return -EINVAL;
343}
344#endif
304 345
346static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
347 const struct tsc2007_platform_data *pdata,
348 const struct i2c_device_id *id)
349{
305 ts->model = pdata->model; 350 ts->model = pdata->model;
306 ts->x_plate_ohms = pdata->x_plate_ohms; 351 ts->x_plate_ohms = pdata->x_plate_ohms;
307 ts->max_rt = pdata->max_rt ? : MAX_12BIT; 352 ts->max_rt = pdata->max_rt ? : MAX_12BIT;
308 ts->poll_delay = pdata->poll_delay ? : 1;
309 ts->poll_period = pdata->poll_period ? : 1; 353 ts->poll_period = pdata->poll_period ? : 1;
310 ts->get_pendown_state = pdata->get_pendown_state; 354 ts->get_pendown_state = pdata->get_pendown_state;
311 ts->clear_penirq = pdata->clear_penirq; 355 ts->clear_penirq = pdata->clear_penirq;
356 ts->fuzzx = pdata->fuzzx;
357 ts->fuzzy = pdata->fuzzy;
358 ts->fuzzz = pdata->fuzzz;
312 359
313 if (pdata->x_plate_ohms == 0) { 360 if (pdata->x_plate_ohms == 0) {
314 dev_err(&client->dev, "x_plate_ohms is not set up in platform data"); 361 dev_err(&client->dev, "x_plate_ohms is not set up in platform data");
315 err = -EINVAL; 362 return -EINVAL;
316 goto err_free_mem;
317 } 363 }
318 364
365 return 0;
366}
367
368static void tsc2007_call_exit_platform_hw(void *data)
369{
370 struct device *dev = data;
371 const struct tsc2007_platform_data *pdata = dev_get_platdata(dev);
372
373 pdata->exit_platform_hw();
374}
375
376static int tsc2007_probe(struct i2c_client *client,
377 const struct i2c_device_id *id)
378{
379 const struct tsc2007_platform_data *pdata = dev_get_platdata(&client->dev);
380 struct tsc2007 *ts;
381 struct input_dev *input_dev;
382 int err;
383
384 if (!i2c_check_functionality(client->adapter,
385 I2C_FUNC_SMBUS_READ_WORD_DATA))
386 return -EIO;
387
388 ts = devm_kzalloc(&client->dev, sizeof(struct tsc2007), GFP_KERNEL);
389 if (!ts)
390 return -ENOMEM;
391
392 if (pdata)
393 err = tsc2007_probe_pdev(client, ts, pdata, id);
394 else
395 err = tsc2007_probe_dt(client, ts);
396 if (err)
397 return err;
398
399 input_dev = devm_input_allocate_device(&client->dev);
400 if (!input_dev)
401 return -ENOMEM;
402
403 i2c_set_clientdata(client, ts);
404
405 ts->client = client;
406 ts->irq = client->irq;
407 ts->input = input_dev;
408 init_waitqueue_head(&ts->wait);
409
319 snprintf(ts->phys, sizeof(ts->phys), 410 snprintf(ts->phys, sizeof(ts->phys),
320 "%s/input0", dev_name(&client->dev)); 411 "%s/input0", dev_name(&client->dev));
321 412
@@ -331,53 +422,46 @@ static int tsc2007_probe(struct i2c_client *client,
331 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 422 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
332 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 423 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
333 424
334 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0); 425 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
335 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0); 426 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
336 input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 427 input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
337 pdata->fuzzz, 0); 428 ts->fuzzz, 0);
429
430 if (pdata) {
431 if (pdata->exit_platform_hw) {
432 err = devm_add_action(&client->dev,
433 tsc2007_call_exit_platform_hw,
434 &client->dev);
435 if (err) {
436 dev_err(&client->dev,
437 "Failed to register exit_platform_hw action, %d\n",
438 err);
439 return err;
440 }
441 }
338 442
339 if (pdata->init_platform_hw) 443 if (pdata->init_platform_hw)
340 pdata->init_platform_hw(); 444 pdata->init_platform_hw();
445 }
341 446
342 err = request_threaded_irq(ts->irq, tsc2007_hard_irq, tsc2007_soft_irq, 447 err = devm_request_threaded_irq(&client->dev, ts->irq,
343 IRQF_ONESHOT, client->dev.driver->name, ts); 448 tsc2007_hard_irq, tsc2007_soft_irq,
344 if (err < 0) { 449 IRQF_ONESHOT,
345 dev_err(&client->dev, "irq %d busy?\n", ts->irq); 450 client->dev.driver->name, ts);
346 goto err_free_mem; 451 if (err) {
452 dev_err(&client->dev, "Failed to request irq %d: %d\n",
453 ts->irq, err);
454 return err;
347 } 455 }
348 456
349 tsc2007_stop(ts); 457 tsc2007_stop(ts);
350 458
351 err = input_register_device(input_dev); 459 err = input_register_device(input_dev);
352 if (err) 460 if (err) {
353 goto err_free_irq; 461 dev_err(&client->dev,
354 462 "Failed to register input device: %d\n", err);
355 i2c_set_clientdata(client, ts); 463 return err;
356 464 }
357 return 0;
358
359 err_free_irq:
360 free_irq(ts->irq, ts);
361 if (pdata->exit_platform_hw)
362 pdata->exit_platform_hw();
363 err_free_mem:
364 input_free_device(input_dev);
365 kfree(ts);
366 return err;
367}
368
369static int tsc2007_remove(struct i2c_client *client)
370{
371 struct tsc2007 *ts = i2c_get_clientdata(client);
372 struct tsc2007_platform_data *pdata = client->dev.platform_data;
373
374 free_irq(ts->irq, ts);
375
376 if (pdata->exit_platform_hw)
377 pdata->exit_platform_hw();
378
379 input_unregister_device(ts->input);
380 kfree(ts);
381 465
382 return 0; 466 return 0;
383} 467}
@@ -389,14 +473,22 @@ static const struct i2c_device_id tsc2007_idtable[] = {
389 473
390MODULE_DEVICE_TABLE(i2c, tsc2007_idtable); 474MODULE_DEVICE_TABLE(i2c, tsc2007_idtable);
391 475
476#ifdef CONFIG_OF
477static const struct of_device_id tsc2007_of_match[] = {
478 { .compatible = "ti,tsc2007" },
479 { /* sentinel */ }
480};
481MODULE_DEVICE_TABLE(of, tsc2007_of_match);
482#endif
483
392static struct i2c_driver tsc2007_driver = { 484static struct i2c_driver tsc2007_driver = {
393 .driver = { 485 .driver = {
394 .owner = THIS_MODULE, 486 .owner = THIS_MODULE,
395 .name = "tsc2007" 487 .name = "tsc2007",
488 .of_match_table = of_match_ptr(tsc2007_of_match),
396 }, 489 },
397 .id_table = tsc2007_idtable, 490 .id_table = tsc2007_idtable,
398 .probe = tsc2007_probe, 491 .probe = tsc2007_probe,
399 .remove = tsc2007_remove,
400}; 492};
401 493
402module_i2c_driver(tsc2007_driver); 494module_i2c_driver(tsc2007_driver);
diff --git a/drivers/input/touchscreen/tsc40.c b/drivers/input/touchscreen/tsc40.c
index eb96f168fb9d..29687872cb94 100644
--- a/drivers/input/touchscreen/tsc40.c
+++ b/drivers/input/touchscreen/tsc40.c
@@ -11,7 +11,6 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/input.h> 12#include <linux/input.h>
13#include <linux/serio.h> 13#include <linux/serio.h>
14#include <linux/init.h>
15 14
16#define PACKET_LENGTH 5 15#define PACKET_LENGTH 5
17struct tsc_ser { 16struct tsc_ser {
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 1271f97b4079..b46c55cd1bbb 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
24#include <linux/sched.h> 23#include <linux/sched.h>
25#include <linux/wait.h> 24#include <linux/wait.h>
@@ -320,7 +319,7 @@ static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb,
320 319
321static int ucb1400_ts_probe(struct platform_device *pdev) 320static int ucb1400_ts_probe(struct platform_device *pdev)
322{ 321{
323 struct ucb1400_ts *ucb = pdev->dev.platform_data; 322 struct ucb1400_ts *ucb = dev_get_platdata(&pdev->dev);
324 int error, x_res, y_res; 323 int error, x_res, y_res;
325 u16 fcsr; 324 u16 fcsr;
326 325
@@ -399,7 +398,7 @@ err:
399 398
400static int ucb1400_ts_remove(struct platform_device *pdev) 399static int ucb1400_ts_remove(struct platform_device *pdev)
401{ 400{
402 struct ucb1400_ts *ucb = pdev->dev.platform_data; 401 struct ucb1400_ts *ucb = dev_get_platdata(&pdev->dev);
403 402
404 free_irq(ucb->irq, ucb); 403 free_irq(ucb->irq, ucb);
405 input_unregister_device(ucb->ts_idev); 404 input_unregister_device(ucb->ts_idev);
@@ -410,7 +409,7 @@ static int ucb1400_ts_remove(struct platform_device *pdev)
410#ifdef CONFIG_PM_SLEEP 409#ifdef CONFIG_PM_SLEEP
411static int ucb1400_ts_suspend(struct device *dev) 410static int ucb1400_ts_suspend(struct device *dev)
412{ 411{
413 struct ucb1400_ts *ucb = dev->platform_data; 412 struct ucb1400_ts *ucb = dev_get_platdata(dev);
414 struct input_dev *idev = ucb->ts_idev; 413 struct input_dev *idev = ucb->ts_idev;
415 414
416 mutex_lock(&idev->mutex); 415 mutex_lock(&idev->mutex);
@@ -424,7 +423,7 @@ static int ucb1400_ts_suspend(struct device *dev)
424 423
425static int ucb1400_ts_resume(struct device *dev) 424static int ucb1400_ts_resume(struct device *dev)
426{ 425{
427 struct ucb1400_ts *ucb = dev->platform_data; 426 struct ucb1400_ts *ucb = dev_get_platdata(dev);
428 struct input_dev *idev = ucb->ts_idev; 427 struct input_dev *idev = ucb->ts_idev;
429 428
430 mutex_lock(&idev->mutex); 429 mutex_lock(&idev->mutex);
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 5f87bed05467..a0966331a89b 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -51,7 +51,6 @@
51#include <linux/slab.h> 51#include <linux/slab.h>
52#include <linux/input.h> 52#include <linux/input.h>
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h>
55#include <linux/usb.h> 54#include <linux/usb.h>
56#include <linux/usb/input.h> 55#include <linux/usb/input.h>
57#include <linux/hid.h> 56#include <linux/hid.h>
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index 9a83be6b6584..2792ca397dd0 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -18,7 +18,6 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/input/mt.h> 19#include <linux/input/mt.h>
20#include <linux/serio.h> 20#include <linux/serio.h>
21#include <linux/init.h>
22#include <linux/ctype.h> 21#include <linux/ctype.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
24 23
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c
index 6be2eb6a153a..1b953a066b2c 100644
--- a/drivers/input/touchscreen/wm831x-ts.c
+++ b/drivers/input/touchscreen/wm831x-ts.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/string.h> 16#include <linux/string.h>
18#include <linux/pm.h> 17#include <linux/pm.h>
19#include <linux/input.h> 18#include <linux/input.h>
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 7e45c9f6e6b7..d0ef91fc87d1 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -584,7 +584,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
584static int wm97xx_probe(struct device *dev) 584static int wm97xx_probe(struct device *dev)
585{ 585{
586 struct wm97xx *wm; 586 struct wm97xx *wm;
587 struct wm97xx_pdata *pdata = dev->platform_data; 587 struct wm97xx_pdata *pdata = dev_get_platdata(dev);
588 int ret = 0, id = 0; 588 int ret = 0, id = 0;
589 589
590 wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL); 590 wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index aa127ba392a4..2175f3419002 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -279,7 +279,8 @@ static int zforce_start(struct zforce_ts *ts)
279 goto error; 279 goto error;
280 } 280 }
281 281
282 if (zforce_setconfig(ts, SETCONFIG_DUALTOUCH)) { 282 ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH);
283 if (ret) {
283 dev_err(&client->dev, "Unable to set config\n"); 284 dev_err(&client->dev, "Unable to set config\n");
284 goto error; 285 goto error;
285 } 286 }
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c
index bf0869a7a78e..e2ccd683de6e 100644
--- a/drivers/input/touchscreen/zylonite-wm97xx.c
+++ b/drivers/input/touchscreen/zylonite-wm97xx.c
@@ -20,7 +20,6 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/gpio.h> 24#include <linux/gpio.h>
26#include <linux/irq.h> 25#include <linux/irq.h>
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index 506a9f7af51e..4f35b6ad3889 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -7,16 +7,14 @@ struct tsc2007_platform_data {
7 u16 model; /* 2007. */ 7 u16 model; /* 2007. */
8 u16 x_plate_ohms; /* must be non-zero value */ 8 u16 x_plate_ohms; /* must be non-zero value */
9 u16 max_rt; /* max. resistance above which samples are ignored */ 9 u16 max_rt; /* max. resistance above which samples are ignored */
10 unsigned long poll_delay; /* delay (in ms) after pen-down event
11 before polling starts */
12 unsigned long poll_period; /* time (in ms) between samples */ 10 unsigned long poll_period; /* time (in ms) between samples */
13 int fuzzx; /* fuzz factor for X, Y and pressure axes */ 11 int fuzzx; /* fuzz factor for X, Y and pressure axes */
14 int fuzzy; 12 int fuzzy;
15 int fuzzz; 13 int fuzzz;
16 14
17 int (*get_pendown_state)(void); 15 int (*get_pendown_state)(struct device *);
18 void (*clear_penirq)(void); /* If needed, clear 2nd level 16 /* If needed, clear 2nd level interrupt source */
19 interrupt source */ 17 void (*clear_penirq)(void);
20 int (*init_platform_hw)(void); 18 int (*init_platform_hw)(void);
21 void (*exit_platform_hw)(void); 19 void (*exit_platform_hw)(void);
22}; 20};
diff --git a/include/linux/platform_data/keypad-ep93xx.h b/include/linux/platform_data/keypad-ep93xx.h
index 1e2f4e97f428..adccee25b162 100644
--- a/include/linux/platform_data/keypad-ep93xx.h
+++ b/include/linux/platform_data/keypad-ep93xx.h
@@ -1,9 +1,5 @@
1/* 1#ifndef __KEYPAD_EP93XX_H
2 * arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h 2#define __KEYPAD_EP93XX_H
3 */
4
5#ifndef __ASM_ARCH_EP93XX_KEYPAD_H
6#define __ASM_ARCH_EP93XX_KEYPAD_H
7 3
8struct matrix_keymap_data; 4struct matrix_keymap_data;
9 5
@@ -32,4 +28,4 @@ struct ep93xx_keypad_platform_data {
32#define EP93XX_MATRIX_ROWS (8) 28#define EP93XX_MATRIX_ROWS (8)
33#define EP93XX_MATRIX_COLS (8) 29#define EP93XX_MATRIX_COLS (8)
34 30
35#endif /* __ASM_ARCH_EP93XX_KEYPAD_H */ 31#endif /* __KEYPAD_EP93XX_H */
diff --git a/include/linux/platform_data/keypad-omap.h b/include/linux/platform_data/keypad-omap.h
index a6b21eddb212..c3a3abae98f0 100644
--- a/include/linux/platform_data/keypad-omap.h
+++ b/include/linux/platform_data/keypad-omap.h
@@ -1,14 +1,12 @@
1/* 1/*
2 * arch/arm/plat-omap/include/mach/keypad.h
3 *
4 * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com> 2 * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
9 */ 7 */
10#ifndef ASMARM_ARCH_KEYPAD_H 8#ifndef __KEYPAD_OMAP_H
11#define ASMARM_ARCH_KEYPAD_H 9#define __KEYPAD_OMAP_H
12 10
13#ifndef CONFIG_ARCH_OMAP1 11#ifndef CONFIG_ARCH_OMAP1
14#warning Please update the board to use matrix-keypad driver 12#warning Please update the board to use matrix-keypad driver