aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-16 14:10:56 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-16 14:10:56 -0400
commit13fe7056bebb4015c6231a07a1be4d3aebbfe979 (patch)
tree8aefa59a61c081c402bc85f2b47c17e1374eabdd /drivers/input
parented9800100f1a70154c11cfa0ccc0b9ff51e3436a (diff)
parent100294cee9a98bfd4d6cb2d1c8a8aef0e959b0c4 (diff)
Merge branch 'next' into for-linus
Prepare input updates for 4.19 merge window.
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/evbug.c4
-rw-r--r--drivers/input/evdev.c16
-rw-r--r--drivers/input/gameport/emu10k1-gp.c4
-rw-r--r--drivers/input/gameport/lightning.c4
-rw-r--r--drivers/input/gameport/ns558.c4
-rw-r--r--drivers/input/input.c16
-rw-r--r--drivers/input/joystick/a3d.c4
-rw-r--r--drivers/input/joystick/adi.c4
-rw-r--r--drivers/input/joystick/amijoy.c4
-rw-r--r--drivers/input/joystick/analog.c4
-rw-r--r--drivers/input/joystick/cobra.c4
-rw-r--r--drivers/input/joystick/db9.c9
-rw-r--r--drivers/input/joystick/gamecon.c4
-rw-r--r--drivers/input/joystick/gf2k.c4
-rw-r--r--drivers/input/joystick/grip.c4
-rw-r--r--drivers/input/joystick/guillemot.c4
-rw-r--r--drivers/input/joystick/iforce/iforce-ff.c8
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c30
-rw-r--r--drivers/input/joystick/iforce/iforce-packets.c16
-rw-r--r--drivers/input/joystick/iforce/iforce-serio.c4
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c4
-rw-r--r--drivers/input/joystick/iforce/iforce.h6
-rw-r--r--drivers/input/joystick/interact.c4
-rw-r--r--drivers/input/joystick/joydump.c4
-rw-r--r--drivers/input/joystick/magellan.c4
-rw-r--r--drivers/input/joystick/pxrc.c166
-rw-r--r--drivers/input/joystick/sidewinder.c4
-rw-r--r--drivers/input/joystick/spaceball.c4
-rw-r--r--drivers/input/joystick/spaceorb.c4
-rw-r--r--drivers/input/joystick/stinger.c4
-rw-r--r--drivers/input/joystick/tmdc.c4
-rw-r--r--drivers/input/joystick/turbografx.c4
-rw-r--r--drivers/input/joystick/warrior.c4
-rw-r--r--drivers/input/keyboard/adp5589-keys.c1
-rw-r--r--drivers/input/keyboard/amikbd.c4
-rw-r--r--drivers/input/keyboard/atakbd.c4
-rw-r--r--drivers/input/keyboard/cros_ec_keyb.c69
-rw-r--r--drivers/input/keyboard/gpio_keys.c8
-rw-r--r--drivers/input/keyboard/imx_keypad.c12
-rw-r--r--drivers/input/keyboard/newtonkbd.c4
-rw-r--r--drivers/input/keyboard/snvs_pwrkey.c15
-rw-r--r--drivers/input/keyboard/stowaway.c4
-rw-r--r--drivers/input/keyboard/sunkbd.c4
-rw-r--r--drivers/input/keyboard/xtkbd.c4
-rw-r--r--drivers/input/misc/keyspan_remote.c2
-rw-r--r--drivers/input/misc/pm8941-pwrkey.c70
-rw-r--r--drivers/input/misc/powermate.c2
-rw-r--r--drivers/input/misc/xen-kbdfront.c183
-rw-r--r--drivers/input/misc/yealink.c4
-rw-r--r--drivers/input/mouse/appletouch.c7
-rw-r--r--drivers/input/mouse/cyapa_gen5.c1
-rw-r--r--drivers/input/mouse/cyapa_gen6.c1
-rw-r--r--drivers/input/mouse/elantech.c2
-rw-r--r--drivers/input/mouse/inport.c4
-rw-r--r--drivers/input/mouse/logibm.c4
-rw-r--r--drivers/input/mouse/pc110pad.c4
-rw-r--r--drivers/input/mouse/sermouse.c8
-rw-r--r--drivers/input/serio/ct82c710.c4
-rw-r--r--drivers/input/serio/i8042.c3
-rw-r--r--drivers/input/serio/q40kbd.c4
-rw-r--r--drivers/input/serio/rpckbd.c4
-rw-r--r--drivers/input/serio/serio.c4
-rw-r--r--drivers/input/tablet/aiptek.c2
-rw-r--r--drivers/input/touchscreen/Kconfig12
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c223
-rw-r--r--drivers/input/touchscreen/bu21029_ts.c484
-rw-r--r--drivers/input/touchscreen/eeti_ts.c37
-rw-r--r--drivers/input/touchscreen/egalax_ts.c5
-rw-r--r--drivers/input/touchscreen/elo.c1
-rw-r--r--drivers/input/touchscreen/fsl-imx25-tcq.c21
-rw-r--r--drivers/input/touchscreen/gunze.c4
-rw-r--r--drivers/input/touchscreen/imx6ul_tsc.c14
-rw-r--r--drivers/input/touchscreen/raydium_i2c_ts.c4
-rw-r--r--drivers/input/touchscreen/wdt87xx_i2c.c2
75 files changed, 988 insertions, 629 deletions
diff --git a/drivers/input/evbug.c b/drivers/input/evbug.c
index cd4e6679d61a..5419c1c1f621 100644
--- a/drivers/input/evbug.c
+++ b/drivers/input/evbug.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index c81c79d01d93..370206f987f9 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -481,7 +481,7 @@ static int evdev_release(struct inode *inode, struct file *file)
481 evdev_detach_client(evdev, client); 481 evdev_detach_client(evdev, client);
482 482
483 for (i = 0; i < EV_CNT; ++i) 483 for (i = 0; i < EV_CNT; ++i)
484 kfree(client->evmasks[i]); 484 bitmap_free(client->evmasks[i]);
485 485
486 kvfree(client); 486 kvfree(client);
487 487
@@ -925,17 +925,15 @@ static int evdev_handle_get_val(struct evdev_client *client,
925{ 925{
926 int ret; 926 int ret;
927 unsigned long *mem; 927 unsigned long *mem;
928 size_t len;
929 928
930 len = BITS_TO_LONGS(maxbit) * sizeof(unsigned long); 929 mem = bitmap_alloc(maxbit, GFP_KERNEL);
931 mem = kmalloc(len, GFP_KERNEL);
932 if (!mem) 930 if (!mem)
933 return -ENOMEM; 931 return -ENOMEM;
934 932
935 spin_lock_irq(&dev->event_lock); 933 spin_lock_irq(&dev->event_lock);
936 spin_lock(&client->buffer_lock); 934 spin_lock(&client->buffer_lock);
937 935
938 memcpy(mem, bits, len); 936 bitmap_copy(mem, bits, maxbit);
939 937
940 spin_unlock(&dev->event_lock); 938 spin_unlock(&dev->event_lock);
941 939
@@ -947,7 +945,7 @@ static int evdev_handle_get_val(struct evdev_client *client,
947 if (ret < 0) 945 if (ret < 0)
948 evdev_queue_syn_dropped(client); 946 evdev_queue_syn_dropped(client);
949 947
950 kfree(mem); 948 bitmap_free(mem);
951 949
952 return ret; 950 return ret;
953} 951}
@@ -1003,13 +1001,13 @@ static int evdev_set_mask(struct evdev_client *client,
1003 if (!cnt) 1001 if (!cnt)
1004 return 0; 1002 return 0;
1005 1003
1006 mask = kcalloc(sizeof(unsigned long), BITS_TO_LONGS(cnt), GFP_KERNEL); 1004 mask = bitmap_zalloc(cnt, GFP_KERNEL);
1007 if (!mask) 1005 if (!mask)
1008 return -ENOMEM; 1006 return -ENOMEM;
1009 1007
1010 error = bits_from_user(mask, cnt - 1, codes_size, codes, compat); 1008 error = bits_from_user(mask, cnt - 1, codes_size, codes, compat);
1011 if (error < 0) { 1009 if (error < 0) {
1012 kfree(mask); 1010 bitmap_free(mask);
1013 return error; 1011 return error;
1014 } 1012 }
1015 1013
@@ -1018,7 +1016,7 @@ static int evdev_set_mask(struct evdev_client *client,
1018 client->evmasks[type] = mask; 1016 client->evmasks[type] = mask;
1019 spin_unlock_irqrestore(&client->buffer_lock, flags); 1017 spin_unlock_irqrestore(&client->buffer_lock, flags);
1020 1018
1021 kfree(oldmask); 1019 bitmap_free(oldmask);
1022 1020
1023 return 0; 1021 return 0;
1024} 1022}
diff --git a/drivers/input/gameport/emu10k1-gp.c b/drivers/input/gameport/emu10k1-gp.c
index 2909e9561cf3..afdc20ca0e24 100644
--- a/drivers/input/gameport/emu10k1-gp.c
+++ b/drivers/input/gameport/emu10k1-gp.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <asm/io.h> 25#include <asm/io.h>
diff --git a/drivers/input/gameport/lightning.c b/drivers/input/gameport/lightning.c
index 85d6ee09f11f..c6e74c7945cb 100644
--- a/drivers/input/gameport/lightning.c
+++ b/drivers/input/gameport/lightning.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <asm/io.h> 25#include <asm/io.h>
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
index 7c217848613e..6437645858f9 100644
--- a/drivers/input/gameport/ns558.c
+++ b/drivers/input/gameport/ns558.c
@@ -21,10 +21,6 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
28 */ 24 */
29 25
30#include <asm/io.h> 26#include <asm/io.h>
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 6365c1958264..3304aaaffe87 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -480,11 +480,19 @@ EXPORT_SYMBOL(input_inject_event);
480 */ 480 */
481void input_alloc_absinfo(struct input_dev *dev) 481void input_alloc_absinfo(struct input_dev *dev)
482{ 482{
483 if (!dev->absinfo) 483 if (dev->absinfo)
484 dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), 484 return;
485 GFP_KERNEL);
486 485
487 WARN(!dev->absinfo, "%s(): kcalloc() failed?\n", __func__); 486 dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), GFP_KERNEL);
487 if (!dev->absinfo) {
488 dev_err(dev->dev.parent ?: &dev->dev,
489 "%s: unable to allocate memory\n", __func__);
490 /*
491 * We will handle this allocation failure in
492 * input_register_device() when we refuse to register input
493 * device with ABS bits but without absinfo.
494 */
495 }
488} 496}
489EXPORT_SYMBOL(input_alloc_absinfo); 497EXPORT_SYMBOL(input_alloc_absinfo);
490 498
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index 55efdfc7eb62..98307039a534 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 15a71acb6997..f466c0d34247 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index c65b5fa69f1e..2b82a838c511 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/types.h> 25#include <linux/types.h>
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index c79dbcb4d146..2b445c8d3fcd 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index ae3ee24a2368..14cb956beac4 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index de0dd4756c84..804b1b80a8be 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -263,6 +259,7 @@ static unsigned char db9_saturn_read_packet(struct parport *port, unsigned char
263 db9_saturn_write_sub(port, type, 3, powered, 0); 259 db9_saturn_write_sub(port, type, 3, powered, 0);
264 return data[0] = 0xe3; 260 return data[0] = 0xe3;
265 } 261 }
262 /* else: fall through */
266 default: 263 default:
267 return data[0]; 264 return data[0];
268 } 265 }
@@ -282,11 +279,14 @@ static int db9_saturn_report(unsigned char id, unsigned char data[60], struct in
282 switch (data[j]) { 279 switch (data[j]) {
283 case 0x16: /* multi controller (analog 4 axis) */ 280 case 0x16: /* multi controller (analog 4 axis) */
284 input_report_abs(dev, db9_abs[5], data[j + 6]); 281 input_report_abs(dev, db9_abs[5], data[j + 6]);
282 /* fall through */
285 case 0x15: /* mission stick (analog 3 axis) */ 283 case 0x15: /* mission stick (analog 3 axis) */
286 input_report_abs(dev, db9_abs[3], data[j + 4]); 284 input_report_abs(dev, db9_abs[3], data[j + 4]);
287 input_report_abs(dev, db9_abs[4], data[j + 5]); 285 input_report_abs(dev, db9_abs[4], data[j + 5]);
286 /* fall through */
288 case 0x13: /* racing controller (analog 1 axis) */ 287 case 0x13: /* racing controller (analog 1 axis) */
289 input_report_abs(dev, db9_abs[2], data[j + 3]); 288 input_report_abs(dev, db9_abs[2], data[j + 3]);
289 /* fall through */
290 case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */ 290 case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */
291 case 0x02: /* digital pad (digital 2 axis + buttons) */ 291 case 0x02: /* digital pad (digital 2 axis + buttons) */
292 input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); 292 input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64));
@@ -380,6 +380,7 @@ static void db9_timer(struct timer_list *t)
380 input_report_abs(dev2, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); 380 input_report_abs(dev2, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1));
381 input_report_abs(dev2, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); 381 input_report_abs(dev2, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1));
382 input_report_key(dev2, BTN_TRIGGER, ~data & DB9_FIRE1); 382 input_report_key(dev2, BTN_TRIGGER, ~data & DB9_FIRE1);
383 /* fall through */
383 384
384 case DB9_MULTI_0802: 385 case DB9_MULTI_0802:
385 386
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 4e10ffdf8a36..d62e73dd9f7f 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -24,10 +24,6 @@
24 * You should have received a copy of the GNU General Public License 24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software 25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 * Should you need to contact me, the author, you can do so either by
29 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
31 */ 27 */
32 28
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index 0f519db64748..50a60065ab14 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index eac9c5b8d73e..e10395ba62bc 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index a9ac2f9cfce0..43ff817d80ac 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c
index 0de9a0943a9e..3536d5f5ad18 100644
--- a/drivers/input/joystick/iforce/iforce-ff.c
+++ b/drivers/input/joystick/iforce/iforce-ff.c
@@ -19,10 +19,6 @@
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */ 22 */
27 23
28#include "iforce.h" 24#include "iforce.h"
@@ -56,7 +52,7 @@ static int make_magnitude_modifier(struct iforce* iforce,
56 52
57 iforce_send_packet(iforce, FF_CMD_MAGNITUDE, data); 53 iforce_send_packet(iforce, FF_CMD_MAGNITUDE, data);
58 54
59 iforce_dump_packet("magnitude: ", FF_CMD_MAGNITUDE, data); 55 iforce_dump_packet(iforce, "magnitude", FF_CMD_MAGNITUDE, data);
60 return 0; 56 return 0;
61} 57}
62 58
@@ -178,7 +174,7 @@ static int make_condition_modifier(struct iforce* iforce,
178 data[9] = (100 * lsat) >> 16; 174 data[9] = (100 * lsat) >> 16;
179 175
180 iforce_send_packet(iforce, FF_CMD_CONDITION, data); 176 iforce_send_packet(iforce, FF_CMD_CONDITION, data);
181 iforce_dump_packet("condition", FF_CMD_CONDITION, data); 177 iforce_dump_packet(iforce, "condition", FF_CMD_CONDITION, data);
182 178
183 return 0; 179 return 0;
184} 180}
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index daeeb4c7e3b0..58d5cfe46526 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -19,10 +19,6 @@
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */ 22 */
27 23
28#include "iforce.h" 24#include "iforce.h"
@@ -33,21 +29,14 @@ MODULE_LICENSE("GPL");
33 29
34static signed short btn_joystick[] = 30static signed short btn_joystick[] =
35{ BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, 31{ BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE,
36 BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_A, BTN_B, BTN_C, -1 }; 32 BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_A,
37 33 BTN_B, BTN_C, BTN_DEAD, -1 };
38static signed short btn_avb_pegasus[] =
39{ BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE,
40 BTN_BASE2, BTN_BASE3, BTN_BASE4, -1 };
41 34
42static signed short btn_wheel[] = 35static signed short btn_joystick_avb[] =
43{ BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE,
44 BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_A, BTN_B, BTN_C, -1 };
45
46static signed short btn_avb_tw[] =
47{ BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, 36{ BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE,
48 BTN_BASE2, BTN_BASE3, BTN_BASE4, -1 }; 37 BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_DEAD, -1 };
49 38
50static signed short btn_avb_wheel[] = 39static signed short btn_wheel[] =
51{ BTN_GEAR_DOWN, BTN_GEAR_UP, BTN_BASE, BTN_BASE2, BTN_BASE3, 40{ BTN_GEAR_DOWN, BTN_GEAR_UP, BTN_BASE, BTN_BASE2, BTN_BASE3,
52 BTN_BASE4, BTN_BASE5, BTN_BASE6, -1 }; 41 BTN_BASE4, BTN_BASE5, BTN_BASE6, -1 };
53 42
@@ -73,9 +62,9 @@ static struct iforce_device iforce_device[] = {
73 { 0x044f, 0xa01c, "Thrustmaster Motor Sport GT", btn_wheel, abs_wheel, ff_iforce }, 62 { 0x044f, 0xa01c, "Thrustmaster Motor Sport GT", btn_wheel, abs_wheel, ff_iforce },
74 { 0x046d, 0xc281, "Logitech WingMan Force", btn_joystick, abs_joystick, ff_iforce }, 63 { 0x046d, 0xc281, "Logitech WingMan Force", btn_joystick, abs_joystick, ff_iforce },
75 { 0x046d, 0xc291, "Logitech WingMan Formula Force", btn_wheel, abs_wheel, ff_iforce }, 64 { 0x046d, 0xc291, "Logitech WingMan Formula Force", btn_wheel, abs_wheel, ff_iforce },
76 { 0x05ef, 0x020a, "AVB Top Shot Pegasus", btn_avb_pegasus, abs_avb_pegasus, ff_iforce }, 65 { 0x05ef, 0x020a, "AVB Top Shot Pegasus", btn_joystick_avb, abs_avb_pegasus, ff_iforce },
77 { 0x05ef, 0x8884, "AVB Mag Turbo Force", btn_avb_wheel, abs_wheel, ff_iforce }, 66 { 0x05ef, 0x8884, "AVB Mag Turbo Force", btn_wheel, abs_wheel, ff_iforce },
78 { 0x05ef, 0x8888, "AVB Top Shot Force Feedback Racing Wheel", btn_avb_tw, abs_wheel, ff_iforce }, //? 67 { 0x05ef, 0x8888, "AVB Top Shot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //?
79 { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //? 68 { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //?
80 { 0x061c, 0xc084, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, 69 { 0x061c, 0xc084, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce },
81 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? 70 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //?
@@ -360,7 +349,7 @@ int iforce_init_device(struct iforce *iforce)
360 349
361 for (i = 0; c[i]; i++) 350 for (i = 0; c[i]; i++)
362 if (!iforce_get_id_packet(iforce, c + i)) 351 if (!iforce_get_id_packet(iforce, c + i))
363 iforce_dump_packet("info", iforce->ecmd, iforce->edata); 352 iforce_dump_packet(iforce, "info", iforce->ecmd, iforce->edata);
364 353
365/* 354/*
366 * Disable spring, enable force feedback. 355 * Disable spring, enable force feedback.
@@ -388,7 +377,6 @@ int iforce_init_device(struct iforce *iforce)
388 377
389 for (i = 0; iforce->type->btn[i] >= 0; i++) 378 for (i = 0; iforce->type->btn[i] >= 0; i++)
390 set_bit(iforce->type->btn[i], input_dev->keybit); 379 set_bit(iforce->type->btn[i], input_dev->keybit);
391 set_bit(BTN_DEAD, input_dev->keybit);
392 380
393 for (i = 0; iforce->type->abs[i] >= 0; i++) { 381 for (i = 0; iforce->type->abs[i] >= 0; i++) {
394 382
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index 08f98f2eaf88..c10169f4554e 100644
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -19,10 +19,6 @@
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */ 22 */
27 23
28#include "iforce.h" 24#include "iforce.h"
@@ -33,14 +29,10 @@ static struct {
33} iforce_hat_to_axis[16] = {{ 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}}; 29} iforce_hat_to_axis[16] = {{ 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
34 30
35 31
36void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data) 32void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data)
37{ 33{
38 int i; 34 dev_dbg(iforce->dev->dev.parent, "%s %s cmd = %04x, data = %*ph\n",
39 35 __func__, msg, cmd, LO(cmd), data);
40 printk(KERN_DEBUG __FILE__ ": %s cmd = %04x, data = ", msg, cmd);
41 for (i = 0; i < LO(cmd); i++)
42 printk("%02x ", data[i]);
43 printk("\n");
44} 36}
45 37
46/* 38/*
@@ -255,7 +247,7 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
255 iforce->cr.bRequest = packet[0]; 247 iforce->cr.bRequest = packet[0];
256 iforce->ctrl->dev = iforce->usbdev; 248 iforce->ctrl->dev = iforce->usbdev;
257 249
258 status = usb_submit_urb(iforce->ctrl, GFP_ATOMIC); 250 status = usb_submit_urb(iforce->ctrl, GFP_KERNEL);
259 if (status) { 251 if (status) {
260 dev_err(&iforce->intf->dev, 252 dev_err(&iforce->intf->dev,
261 "usb_submit_urb failed %d\n", status); 253 "usb_submit_urb failed %d\n", status);
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
index 154e827b559b..f4ba4a751fe0 100644
--- a/drivers/input/joystick/iforce/iforce-serio.c
+++ b/drivers/input/joystick/iforce/iforce-serio.c
@@ -19,10 +19,6 @@
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */ 22 */
27 23
28#include "iforce.h" 24#include "iforce.h"
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index e8724f1a4a25..78073259c9a1 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -19,10 +19,6 @@
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */ 22 */
27 23
28#include "iforce.h" 24#include "iforce.h"
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
index 96ae4f5bd0eb..0e9d01f8bcb6 100644
--- a/drivers/input/joystick/iforce/iforce.h
+++ b/drivers/input/joystick/iforce/iforce.h
@@ -19,10 +19,6 @@
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */ 22 */
27 23
28#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -158,7 +154,7 @@ int iforce_init_device(struct iforce *iforce);
158int iforce_control_playback(struct iforce*, u16 id, unsigned int); 154int iforce_control_playback(struct iforce*, u16 id, unsigned int);
159void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data); 155void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data);
160int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); 156int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data);
161void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data) ; 157void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data);
162int iforce_get_id_packet(struct iforce *iforce, char *packet); 158int iforce_get_id_packet(struct iforce *iforce, char *packet);
163 159
164/* iforce-ff.c */ 160/* iforce-ff.c */
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index 17c2c800743c..598788b3da62 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
index d1c6e4846a4a..2ea05ade4d4e 100644
--- a/drivers/input/joystick/joydump.c
+++ b/drivers/input/joystick/joydump.c
@@ -21,10 +21,6 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
28 */ 24 */
29 25
30#include <linux/module.h> 26#include <linux/module.h>
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index a9d0e3edca94..95a34ab34fc3 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/input/joystick/pxrc.c b/drivers/input/joystick/pxrc.c
index 07a0dbd3ced2..ea2bf5951d67 100644
--- a/drivers/input/joystick/pxrc.c
+++ b/drivers/input/joystick/pxrc.c
@@ -3,7 +3,6 @@
3 * Driver for Phoenix RC Flight Controller Adapter 3 * Driver for Phoenix RC Flight Controller Adapter
4 * 4 *
5 * Copyright (C) 2018 Marcus Folkesson <marcus.folkesson@gmail.com> 5 * Copyright (C) 2018 Marcus Folkesson <marcus.folkesson@gmail.com>
6 *
7 */ 6 */
8 7
9#include <linux/kernel.h> 8#include <linux/kernel.h>
@@ -16,31 +15,22 @@
16#include <linux/mutex.h> 15#include <linux/mutex.h>
17#include <linux/input.h> 16#include <linux/input.h>
18 17
19#define PXRC_VENDOR_ID (0x1781) 18#define PXRC_VENDOR_ID 0x1781
20#define PXRC_PRODUCT_ID (0x0898) 19#define PXRC_PRODUCT_ID 0x0898
21
22static const struct usb_device_id pxrc_table[] = {
23 { USB_DEVICE(PXRC_VENDOR_ID, PXRC_PRODUCT_ID) },
24 { }
25};
26MODULE_DEVICE_TABLE(usb, pxrc_table);
27 20
28struct pxrc { 21struct pxrc {
29 struct input_dev *input; 22 struct input_dev *input;
30 struct usb_device *udev;
31 struct usb_interface *intf; 23 struct usb_interface *intf;
32 struct urb *urb; 24 struct urb *urb;
33 struct mutex pm_mutex; 25 struct mutex pm_mutex;
34 bool is_open; 26 bool is_open;
35 __u8 epaddr;
36 char phys[64]; 27 char phys[64];
37 unsigned char *data;
38 size_t bsize;
39}; 28};
40 29
41static void pxrc_usb_irq(struct urb *urb) 30static void pxrc_usb_irq(struct urb *urb)
42{ 31{
43 struct pxrc *pxrc = urb->context; 32 struct pxrc *pxrc = urb->context;
33 u8 *data = urb->transfer_buffer;
44 int error; 34 int error;
45 35
46 switch (urb->status) { 36 switch (urb->status) {
@@ -68,15 +58,15 @@ static void pxrc_usb_irq(struct urb *urb)
68 } 58 }
69 59
70 if (urb->actual_length == 8) { 60 if (urb->actual_length == 8) {
71 input_report_abs(pxrc->input, ABS_X, pxrc->data[0]); 61 input_report_abs(pxrc->input, ABS_X, data[0]);
72 input_report_abs(pxrc->input, ABS_Y, pxrc->data[2]); 62 input_report_abs(pxrc->input, ABS_Y, data[2]);
73 input_report_abs(pxrc->input, ABS_RX, pxrc->data[3]); 63 input_report_abs(pxrc->input, ABS_RX, data[3]);
74 input_report_abs(pxrc->input, ABS_RY, pxrc->data[4]); 64 input_report_abs(pxrc->input, ABS_RY, data[4]);
75 input_report_abs(pxrc->input, ABS_RUDDER, pxrc->data[5]); 65 input_report_abs(pxrc->input, ABS_RUDDER, data[5]);
76 input_report_abs(pxrc->input, ABS_THROTTLE, pxrc->data[6]); 66 input_report_abs(pxrc->input, ABS_THROTTLE, data[6]);
77 input_report_abs(pxrc->input, ABS_MISC, pxrc->data[7]); 67 input_report_abs(pxrc->input, ABS_MISC, data[7]);
78 68
79 input_report_key(pxrc->input, BTN_A, pxrc->data[1]); 69 input_report_key(pxrc->input, BTN_A, data[1]);
80 } 70 }
81 71
82exit: 72exit:
@@ -120,61 +110,73 @@ static void pxrc_close(struct input_dev *input)
120 mutex_unlock(&pxrc->pm_mutex); 110 mutex_unlock(&pxrc->pm_mutex);
121} 111}
122 112
123static int pxrc_usb_init(struct pxrc *pxrc) 113static void pxrc_free_urb(void *_pxrc)
124{ 114{
115 struct pxrc *pxrc = _pxrc;
116
117 usb_free_urb(pxrc->urb);
118}
119
120static int pxrc_probe(struct usb_interface *intf,
121 const struct usb_device_id *id)
122{
123 struct usb_device *udev = interface_to_usbdev(intf);
124 struct pxrc *pxrc;
125 struct usb_endpoint_descriptor *epirq; 125 struct usb_endpoint_descriptor *epirq;
126 unsigned int pipe; 126 size_t xfer_size;
127 int retval; 127 void *xfer_buf;
128 int error;
128 129
129 /* Set up the endpoint information */ 130 /*
130 /* This device only has an interrupt endpoint */ 131 * Locate the endpoint information. This device only has an
131 retval = usb_find_common_endpoints(pxrc->intf->cur_altsetting, 132 * interrupt endpoint.
132 NULL, NULL, &epirq, NULL); 133 */
133 if (retval) { 134 error = usb_find_common_endpoints(intf->cur_altsetting,
134 dev_err(&pxrc->intf->dev, 135 NULL, NULL, &epirq, NULL);
135 "Could not find endpoint\n"); 136 if (error) {
136 goto error; 137 dev_err(&intf->dev, "Could not find endpoint\n");
138 return error;
137 } 139 }
138 140
139 pxrc->bsize = usb_endpoint_maxp(epirq); 141 pxrc = devm_kzalloc(&intf->dev, sizeof(*pxrc), GFP_KERNEL);
140 pxrc->epaddr = epirq->bEndpointAddress; 142 if (!pxrc)
141 pxrc->data = devm_kmalloc(&pxrc->intf->dev, pxrc->bsize, GFP_KERNEL); 143 return -ENOMEM;
142 if (!pxrc->data) {
143 retval = -ENOMEM;
144 goto error;
145 }
146 144
147 usb_set_intfdata(pxrc->intf, pxrc); 145 mutex_init(&pxrc->pm_mutex);
148 usb_make_path(pxrc->udev, pxrc->phys, sizeof(pxrc->phys)); 146 pxrc->intf = intf;
149 strlcat(pxrc->phys, "/input0", sizeof(pxrc->phys));
150 147
151 pxrc->urb = usb_alloc_urb(0, GFP_KERNEL); 148 usb_set_intfdata(pxrc->intf, pxrc);
152 if (!pxrc->urb) {
153 retval = -ENOMEM;
154 goto error;
155 }
156 149
157 pipe = usb_rcvintpipe(pxrc->udev, pxrc->epaddr), 150 xfer_size = usb_endpoint_maxp(epirq);
158 usb_fill_int_urb(pxrc->urb, pxrc->udev, pipe, pxrc->data, pxrc->bsize, 151 xfer_buf = devm_kmalloc(&intf->dev, xfer_size, GFP_KERNEL);
159 pxrc_usb_irq, pxrc, 1); 152 if (!xfer_buf)
153 return -ENOMEM;
160 154
161error: 155 pxrc->urb = usb_alloc_urb(0, GFP_KERNEL);
162 return retval; 156 if (!pxrc->urb)
157 return -ENOMEM;
163 158
159 error = devm_add_action_or_reset(&intf->dev, pxrc_free_urb, pxrc);
160 if (error)
161 return error;
164 162
165} 163 usb_fill_int_urb(pxrc->urb, udev,
164 usb_rcvintpipe(udev, epirq->bEndpointAddress),
165 xfer_buf, xfer_size, pxrc_usb_irq, pxrc, 1);
166 166
167static int pxrc_input_init(struct pxrc *pxrc) 167 pxrc->input = devm_input_allocate_device(&intf->dev);
168{ 168 if (!pxrc->input) {
169 pxrc->input = devm_input_allocate_device(&pxrc->intf->dev); 169 dev_err(&intf->dev, "couldn't allocate input device\n");
170 if (pxrc->input == NULL) {
171 dev_err(&pxrc->intf->dev, "couldn't allocate input device\n");
172 return -ENOMEM; 170 return -ENOMEM;
173 } 171 }
174 172
175 pxrc->input->name = "PXRC Flight Controller Adapter"; 173 pxrc->input->name = "PXRC Flight Controller Adapter";
174
175 usb_make_path(udev, pxrc->phys, sizeof(pxrc->phys));
176 strlcat(pxrc->phys, "/input0", sizeof(pxrc->phys));
176 pxrc->input->phys = pxrc->phys; 177 pxrc->input->phys = pxrc->phys;
177 usb_to_input_id(pxrc->udev, &pxrc->input->id); 178
179 usb_to_input_id(udev, &pxrc->input->id);
178 180
179 pxrc->input->open = pxrc_open; 181 pxrc->input->open = pxrc_open;
180 pxrc->input->close = pxrc_close; 182 pxrc->input->close = pxrc_close;
@@ -190,46 +192,16 @@ static int pxrc_input_init(struct pxrc *pxrc)
190 192
191 input_set_drvdata(pxrc->input, pxrc); 193 input_set_drvdata(pxrc->input, pxrc);
192 194
193 return input_register_device(pxrc->input); 195 error = input_register_device(pxrc->input);
194} 196 if (error)
195 197 return error;
196static int pxrc_probe(struct usb_interface *intf,
197 const struct usb_device_id *id)
198{
199 struct pxrc *pxrc;
200 int retval;
201
202 pxrc = devm_kzalloc(&intf->dev, sizeof(*pxrc), GFP_KERNEL);
203 if (!pxrc)
204 return -ENOMEM;
205
206 mutex_init(&pxrc->pm_mutex);
207 pxrc->udev = usb_get_dev(interface_to_usbdev(intf));
208 pxrc->intf = intf;
209
210 retval = pxrc_usb_init(pxrc);
211 if (retval)
212 goto error;
213
214 retval = pxrc_input_init(pxrc);
215 if (retval)
216 goto err_free_urb;
217 198
218 return 0; 199 return 0;
219
220err_free_urb:
221 usb_free_urb(pxrc->urb);
222
223error:
224 return retval;
225} 200}
226 201
227static void pxrc_disconnect(struct usb_interface *intf) 202static void pxrc_disconnect(struct usb_interface *intf)
228{ 203{
229 struct pxrc *pxrc = usb_get_intfdata(intf); 204 /* All driver resources are devm-managed. */
230
231 usb_free_urb(pxrc->urb);
232 usb_set_intfdata(intf, NULL);
233} 205}
234 206
235static int pxrc_suspend(struct usb_interface *intf, pm_message_t message) 207static int pxrc_suspend(struct usb_interface *intf, pm_message_t message)
@@ -284,6 +256,12 @@ static int pxrc_reset_resume(struct usb_interface *intf)
284 return pxrc_resume(intf); 256 return pxrc_resume(intf);
285} 257}
286 258
259static const struct usb_device_id pxrc_table[] = {
260 { USB_DEVICE(PXRC_VENDOR_ID, PXRC_PRODUCT_ID) },
261 { }
262};
263MODULE_DEVICE_TABLE(usb, pxrc_table);
264
287static struct usb_driver pxrc_driver = { 265static struct usb_driver pxrc_driver = {
288 .name = "pxrc", 266 .name = "pxrc",
289 .probe = pxrc_probe, 267 .probe = pxrc_probe,
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 5e602a6852b7..f46bf4d41972 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index bb3faeff8cac..ffb9c1f495b6 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -24,10 +24,6 @@
24 * You should have received a copy of the GNU General Public License 24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software 25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 * Should you need to contact me, the author, you can do so either by
29 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
31 */ 27 */
32 28
33#include <linux/kernel.h> 29#include <linux/kernel.h>
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index 05da0ed514e2..20540ee71d7f 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index cb10e7b097ae..ba8579435d6c 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -21,10 +21,6 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
28 */ 24 */
29 25
30#include <linux/kernel.h> 26#include <linux/kernel.h>
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 7e17cde464f0..6f4a01cfe79f 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/delay.h> 28#include <linux/delay.h>
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index e2685753e460..bf2f9925e416 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index ef5391ba4470..b60cab168e2a 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/kernel.h> 25#include <linux/kernel.h>
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index 32d94c63dc33..2835fba71c33 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -885,6 +885,7 @@ static int adp5589_probe(struct i2c_client *client,
885 switch (id->driver_data) { 885 switch (id->driver_data) {
886 case ADP5585_02: 886 case ADP5585_02:
887 kpad->support_row5 = true; 887 kpad->support_row5 = true;
888 /* fall through */
888 case ADP5585_01: 889 case ADP5585_01:
889 kpad->is_adp5585 = true; 890 kpad->is_adp5585 = true;
890 kpad->var = &const_adp5585; 891 kpad->var = &const_adp5585;
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index e04a3b4e55d6..420e33c49e58 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/module.h> 28#include <linux/module.h>
diff --git a/drivers/input/keyboard/atakbd.c b/drivers/input/keyboard/atakbd.c
index f1235831283d..6f62da2909ec 100644
--- a/drivers/input/keyboard/atakbd.c
+++ b/drivers/input/keyboard/atakbd.c
@@ -34,10 +34,6 @@
34 * You should have received a copy of the GNU General Public License 34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software 35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 *
38 * Should you need to contact me, the author, you can do so either by
39 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
40 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
41 */ 37 */
42 38
43#include <linux/module.h> 39#include <linux/module.h>
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 489ddd37bd4e..81be6f781f0b 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -1,25 +1,15 @@
1/* 1// SPDX-License-Identifier: GPL-2.0
2 * ChromeOS EC keyboard driver 2// ChromeOS EC keyboard driver
3 * 3//
4 * Copyright (C) 2012 Google, Inc 4// Copyright (C) 2012 Google, Inc.
5 * 5//
6 * This software is licensed under the terms of the GNU General Public 6// This driver uses the ChromeOS EC byte-level message-based protocol for
7 * License version 2, as published by the Free Software Foundation, and 7// communicating the keyboard state (which keys are pressed) from a keyboard EC
8 * may be copied, distributed, and modified under those terms. 8// to the AP over some bus (such as i2c, lpc, spi). The EC does debouncing,
9 * 9// but everything else (including deghosting) is done here. The main
10 * This program is distributed in the hope that it will be useful, 10// motivation for this is to keep the EC firmware as simple as possible, since
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11// it cannot be easily upgraded and EC flash/IRAM space is relatively
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// expensive.
13 * GNU General Public License for more details.
14 *
15 * This driver uses the Chrome OS EC byte-level message-based protocol for
16 * communicating the keyboard state (which keys are pressed) from a keyboard EC
17 * to the AP over some bus (such as i2c, lpc, spi). The EC does debouncing,
18 * but everything else (including deghosting) is done here. The main
19 * motivation for this is to keep the EC firmware as simple as possible, since
20 * it cannot be easily upgraded and EC flash/IRAM space is relatively
21 * expensive.
22 */
23 13
24#include <linux/module.h> 14#include <linux/module.h>
25#include <linux/bitops.h> 15#include <linux/bitops.h>
@@ -170,9 +160,6 @@ static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev,
170 int col, row; 160 int col, row;
171 int new_state; 161 int new_state;
172 int old_state; 162 int old_state;
173 int num_cols;
174
175 num_cols = len;
176 163
177 if (ckdev->ghost_filter && cros_ec_keyb_has_ghosting(ckdev, kb_state)) { 164 if (ckdev->ghost_filter && cros_ec_keyb_has_ghosting(ckdev, kb_state)) {
178 /* 165 /*
@@ -242,19 +229,17 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
242 u32 val; 229 u32 val;
243 unsigned int ev_type; 230 unsigned int ev_type;
244 231
232 /*
233 * If not wake enabled, discard key state changes during
234 * suspend. Switches will be re-checked in
235 * cros_ec_keyb_resume() to be sure nothing is lost.
236 */
237 if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
238 return NOTIFY_OK;
239
245 switch (ckdev->ec->event_data.event_type) { 240 switch (ckdev->ec->event_data.event_type) {
246 case EC_MKBP_EVENT_KEY_MATRIX: 241 case EC_MKBP_EVENT_KEY_MATRIX:
247 if (device_may_wakeup(ckdev->dev)) { 242 pm_wakeup_event(ckdev->dev, 0);
248 pm_wakeup_event(ckdev->dev, 0);
249 } else {
250 /*
251 * If keyboard is not wake enabled, discard key state
252 * changes during suspend. Switches will be re-checked
253 * in cros_ec_keyb_resume() to be sure nothing is lost.
254 */
255 if (queued_during_suspend)
256 return NOTIFY_OK;
257 }
258 243
259 if (ckdev->ec->event_size != ckdev->cols) { 244 if (ckdev->ec->event_size != ckdev->cols) {
260 dev_err(ckdev->dev, 245 dev_err(ckdev->dev,
@@ -268,10 +253,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
268 break; 253 break;
269 254
270 case EC_MKBP_EVENT_SYSRQ: 255 case EC_MKBP_EVENT_SYSRQ:
271 if (device_may_wakeup(ckdev->dev)) 256 pm_wakeup_event(ckdev->dev, 0);
272 pm_wakeup_event(ckdev->dev, 0);
273 else if (queued_during_suspend)
274 return NOTIFY_OK;
275 257
276 val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq); 258 val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq);
277 dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val); 259 dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val);
@@ -280,10 +262,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
280 262
281 case EC_MKBP_EVENT_BUTTON: 263 case EC_MKBP_EVENT_BUTTON:
282 case EC_MKBP_EVENT_SWITCH: 264 case EC_MKBP_EVENT_SWITCH:
283 if (device_may_wakeup(ckdev->dev)) 265 pm_wakeup_event(ckdev->dev, 0);
284 pm_wakeup_event(ckdev->dev, 0);
285 else if (queued_during_suspend)
286 return NOTIFY_OK;
287 266
288 if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { 267 if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
289 val = get_unaligned_le32( 268 val = get_unaligned_le32(
@@ -683,6 +662,6 @@ static struct platform_driver cros_ec_keyb_driver = {
683 662
684module_platform_driver(cros_ec_keyb_driver); 663module_platform_driver(cros_ec_keyb_driver);
685 664
686MODULE_LICENSE("GPL"); 665MODULE_LICENSE("GPL v2");
687MODULE_DESCRIPTION("ChromeOS EC keyboard driver"); 666MODULE_DESCRIPTION("ChromeOS EC keyboard driver");
688MODULE_ALIAS("platform:cros-ec-keyb"); 667MODULE_ALIAS("platform:cros-ec-keyb");
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 052e37675086..492a971b95b5 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -196,7 +196,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
196 ssize_t ret; 196 ssize_t ret;
197 int i; 197 int i;
198 198
199 bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL); 199 bits = bitmap_zalloc(n_events, GFP_KERNEL);
200 if (!bits) 200 if (!bits)
201 return -ENOMEM; 201 return -ENOMEM;
202 202
@@ -216,7 +216,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
216 buf[ret++] = '\n'; 216 buf[ret++] = '\n';
217 buf[ret] = '\0'; 217 buf[ret] = '\0';
218 218
219 kfree(bits); 219 bitmap_free(bits);
220 220
221 return ret; 221 return ret;
222} 222}
@@ -240,7 +240,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
240 ssize_t error; 240 ssize_t error;
241 int i; 241 int i;
242 242
243 bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL); 243 bits = bitmap_zalloc(n_events, GFP_KERNEL);
244 if (!bits) 244 if (!bits)
245 return -ENOMEM; 245 return -ENOMEM;
246 246
@@ -284,7 +284,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
284 mutex_unlock(&ddata->disable_lock); 284 mutex_unlock(&ddata->disable_lock);
285 285
286out: 286out:
287 kfree(bits); 287 bitmap_free(bits);
288 return error; 288 return error;
289} 289}
290 290
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 25d61d8d4fc4..539cb670de41 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -1,11 +1,7 @@
1/* 1// SPDX-License-Identifier: GPL-2.0
2 * Driver for the IMX keypad port. 2//
3 * Copyright (C) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> 3// Driver for the IMX keypad port.
4 * 4// Copyright (C) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9 5
10#include <linux/clk.h> 6#include <linux/clk.h>
11#include <linux/delay.h> 7#include <linux/delay.h>
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
index fb9b8e23ab93..de26e2df0ad5 100644
--- a/drivers/input/keyboard/newtonkbd.c
+++ b/drivers/input/keyboard/newtonkbd.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <j.cormack@doc.ic.ac.uk>, or by paper mail:
26 * Justin Cormack, 68 Dartmouth Park Road, London NW5 1SN, UK.
27 */ 23 */
28 24
29#include <linux/slab.h> 25#include <linux/slab.h>
diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index 53c768b95939..effb63205d3d 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -1,14 +1,7 @@
1/* 1// SPDX-License-Identifier: GPL-2.0+
2 * Driver for the IMX SNVS ON/OFF Power Key 2//
3 * Copyright (C) 2015 Freescale Semiconductor, Inc. All Rights Reserved. 3// Driver for the IMX SNVS ON/OFF Power Key
4 * 4// Copyright (C) 2015 Freescale Semiconductor, Inc. All Rights Reserved.
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12 5
13#include <linux/device.h> 6#include <linux/device.h>
14#include <linux/err.h> 7#include <linux/err.h>
diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c
index 8b6de9a692dc..15a5e74dbe91 100644
--- a/drivers/input/keyboard/stowaway.c
+++ b/drivers/input/keyboard/stowaway.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <marek.vasut@gmail.com>, or by paper mail:
29 * Marek Vasut, Liskovecka 559, Frydek-Mistek, 738 01 Czech Republic
30 */ 26 */
31 27
32#include <linux/slab.h> 28#include <linux/slab.h>
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index c95707ea2656..ad5d7f94f95a 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index 8f64b9ded8d0..f7598114b962 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/slab.h> 25#include <linux/slab.h>
diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c
index 67482b248b2d..a8937ceac66a 100644
--- a/drivers/input/misc/keyspan_remote.c
+++ b/drivers/input/misc/keyspan_remote.c
@@ -466,7 +466,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
466 remote->in_endpoint = endpoint; 466 remote->in_endpoint = endpoint;
467 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ 467 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
468 468
469 remote->in_buffer = usb_alloc_coherent(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma); 469 remote->in_buffer = usb_alloc_coherent(udev, RECV_SIZE, GFP_KERNEL, &remote->in_dma);
470 if (!remote->in_buffer) { 470 if (!remote->in_buffer) {
471 error = -ENOMEM; 471 error = -ENOMEM;
472 goto fail1; 472 goto fail1;
diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
index 18ad956454f1..48153e0ca19a 100644
--- a/drivers/input/misc/pm8941-pwrkey.c
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -20,6 +20,7 @@
20#include <linux/log2.h> 20#include <linux/log2.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/of_device.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/reboot.h> 25#include <linux/reboot.h>
25#include <linux/regmap.h> 26#include <linux/regmap.h>
@@ -28,6 +29,7 @@
28 29
29#define PON_RT_STS 0x10 30#define PON_RT_STS 0x10
30#define PON_KPDPWR_N_SET BIT(0) 31#define PON_KPDPWR_N_SET BIT(0)
32#define PON_RESIN_N_SET BIT(1)
31 33
32#define PON_PS_HOLD_RST_CTL 0x5a 34#define PON_PS_HOLD_RST_CTL 0x5a
33#define PON_PS_HOLD_RST_CTL2 0x5b 35#define PON_PS_HOLD_RST_CTL2 0x5b
@@ -38,10 +40,15 @@
38 40
39#define PON_PULL_CTL 0x70 41#define PON_PULL_CTL 0x70
40#define PON_KPDPWR_PULL_UP BIT(1) 42#define PON_KPDPWR_PULL_UP BIT(1)
43#define PON_RESIN_PULL_UP BIT(0)
41 44
42#define PON_DBC_CTL 0x71 45#define PON_DBC_CTL 0x71
43#define PON_DBC_DELAY_MASK 0x7 46#define PON_DBC_DELAY_MASK 0x7
44 47
48struct pm8941_data {
49 unsigned int pull_up_bit;
50 unsigned int status_bit;
51};
45 52
46struct pm8941_pwrkey { 53struct pm8941_pwrkey {
47 struct device *dev; 54 struct device *dev;
@@ -52,6 +59,9 @@ struct pm8941_pwrkey {
52 59
53 unsigned int revision; 60 unsigned int revision;
54 struct notifier_block reboot_notifier; 61 struct notifier_block reboot_notifier;
62
63 u32 code;
64 const struct pm8941_data *data;
55}; 65};
56 66
57static int pm8941_reboot_notify(struct notifier_block *nb, 67static int pm8941_reboot_notify(struct notifier_block *nb,
@@ -124,7 +134,8 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data)
124 if (error) 134 if (error)
125 return IRQ_HANDLED; 135 return IRQ_HANDLED;
126 136
127 input_report_key(pwrkey->input, KEY_POWER, !!(sts & PON_KPDPWR_N_SET)); 137 input_report_key(pwrkey->input, pwrkey->code,
138 sts & pwrkey->data->status_bit);
128 input_sync(pwrkey->input); 139 input_sync(pwrkey->input);
129 140
130 return IRQ_HANDLED; 141 return IRQ_HANDLED;
@@ -157,6 +168,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
157{ 168{
158 struct pm8941_pwrkey *pwrkey; 169 struct pm8941_pwrkey *pwrkey;
159 bool pull_up; 170 bool pull_up;
171 struct device *parent;
160 u32 req_delay; 172 u32 req_delay;
161 int error; 173 int error;
162 174
@@ -175,12 +187,30 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
175 return -ENOMEM; 187 return -ENOMEM;
176 188
177 pwrkey->dev = &pdev->dev; 189 pwrkey->dev = &pdev->dev;
190 pwrkey->data = of_device_get_match_data(&pdev->dev);
178 191
179 pwrkey->regmap = dev_get_regmap(pdev->dev.parent, NULL); 192 parent = pdev->dev.parent;
193 pwrkey->regmap = dev_get_regmap(parent, NULL);
180 if (!pwrkey->regmap) { 194 if (!pwrkey->regmap) {
181 dev_err(&pdev->dev, "failed to locate regmap\n"); 195 /*
182 return -ENODEV; 196 * We failed to get regmap for parent. Let's see if we are
197 * a child of pon node and read regmap and reg from its
198 * parent.
199 */
200 pwrkey->regmap = dev_get_regmap(parent->parent, NULL);
201 if (!pwrkey->regmap) {
202 dev_err(&pdev->dev, "failed to locate regmap\n");
203 return -ENODEV;
204 }
205
206 error = of_property_read_u32(parent->of_node,
207 "reg", &pwrkey->baseaddr);
208 } else {
209 error = of_property_read_u32(pdev->dev.of_node, "reg",
210 &pwrkey->baseaddr);
183 } 211 }
212 if (error)
213 return error;
184 214
185 pwrkey->irq = platform_get_irq(pdev, 0); 215 pwrkey->irq = platform_get_irq(pdev, 0);
186 if (pwrkey->irq < 0) { 216 if (pwrkey->irq < 0) {
@@ -188,11 +218,6 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
188 return pwrkey->irq; 218 return pwrkey->irq;
189 } 219 }
190 220
191 error = of_property_read_u32(pdev->dev.of_node, "reg",
192 &pwrkey->baseaddr);
193 if (error)
194 return error;
195
196 error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2, 221 error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2,
197 &pwrkey->revision); 222 &pwrkey->revision);
198 if (error) { 223 if (error) {
@@ -200,13 +225,21 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
200 return error; 225 return error;
201 } 226 }
202 227
228 error = of_property_read_u32(pdev->dev.of_node, "linux,code",
229 &pwrkey->code);
230 if (error) {
231 dev_dbg(&pdev->dev,
232 "no linux,code assuming power (%d)\n", error);
233 pwrkey->code = KEY_POWER;
234 }
235
203 pwrkey->input = devm_input_allocate_device(&pdev->dev); 236 pwrkey->input = devm_input_allocate_device(&pdev->dev);
204 if (!pwrkey->input) { 237 if (!pwrkey->input) {
205 dev_dbg(&pdev->dev, "unable to allocate input device\n"); 238 dev_dbg(&pdev->dev, "unable to allocate input device\n");
206 return -ENOMEM; 239 return -ENOMEM;
207 } 240 }
208 241
209 input_set_capability(pwrkey->input, EV_KEY, KEY_POWER); 242 input_set_capability(pwrkey->input, EV_KEY, pwrkey->code);
210 243
211 pwrkey->input->name = "pm8941_pwrkey"; 244 pwrkey->input->name = "pm8941_pwrkey";
212 pwrkey->input->phys = "pm8941_pwrkey/input0"; 245 pwrkey->input->phys = "pm8941_pwrkey/input0";
@@ -225,8 +258,8 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
225 258
226 error = regmap_update_bits(pwrkey->regmap, 259 error = regmap_update_bits(pwrkey->regmap,
227 pwrkey->baseaddr + PON_PULL_CTL, 260 pwrkey->baseaddr + PON_PULL_CTL,
228 PON_KPDPWR_PULL_UP, 261 pwrkey->data->pull_up_bit,
229 pull_up ? PON_KPDPWR_PULL_UP : 0); 262 pull_up ? pwrkey->data->pull_up_bit : 0);
230 if (error) { 263 if (error) {
231 dev_err(&pdev->dev, "failed to set pull: %d\n", error); 264 dev_err(&pdev->dev, "failed to set pull: %d\n", error);
232 return error; 265 return error;
@@ -271,8 +304,19 @@ static int pm8941_pwrkey_remove(struct platform_device *pdev)
271 return 0; 304 return 0;
272} 305}
273 306
307static const struct pm8941_data pwrkey_data = {
308 .pull_up_bit = PON_KPDPWR_PULL_UP,
309 .status_bit = PON_KPDPWR_N_SET,
310};
311
312static const struct pm8941_data resin_data = {
313 .pull_up_bit = PON_RESIN_PULL_UP,
314 .status_bit = PON_RESIN_N_SET,
315};
316
274static const struct of_device_id pm8941_pwr_key_id_table[] = { 317static const struct of_device_id pm8941_pwr_key_id_table[] = {
275 { .compatible = "qcom,pm8941-pwrkey" }, 318 { .compatible = "qcom,pm8941-pwrkey", .data = &pwrkey_data },
319 { .compatible = "qcom,pm8941-resin", .data = &resin_data },
276 { } 320 { }
277}; 321};
278MODULE_DEVICE_TABLE(of, pm8941_pwr_key_id_table); 322MODULE_DEVICE_TABLE(of, pm8941_pwr_key_id_table);
diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c
index 5c8c79623c87..e8de3aaf9f63 100644
--- a/drivers/input/misc/powermate.c
+++ b/drivers/input/misc/powermate.c
@@ -277,7 +277,7 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig
277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm) 277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm)
278{ 278{
279 pm->data = usb_alloc_coherent(udev, POWERMATE_PAYLOAD_SIZE_MAX, 279 pm->data = usb_alloc_coherent(udev, POWERMATE_PAYLOAD_SIZE_MAX,
280 GFP_ATOMIC, &pm->data_dma); 280 GFP_KERNEL, &pm->data_dma);
281 if (!pm->data) 281 if (!pm->data)
282 return -1; 282 return -1;
283 283
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index d91f3b1c5375..594f72e39639 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -63,6 +63,9 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *);
63static void xenkbd_handle_motion_event(struct xenkbd_info *info, 63static void xenkbd_handle_motion_event(struct xenkbd_info *info,
64 struct xenkbd_motion *motion) 64 struct xenkbd_motion *motion)
65{ 65{
66 if (unlikely(!info->ptr))
67 return;
68
66 input_report_rel(info->ptr, REL_X, motion->rel_x); 69 input_report_rel(info->ptr, REL_X, motion->rel_x);
67 input_report_rel(info->ptr, REL_Y, motion->rel_y); 70 input_report_rel(info->ptr, REL_Y, motion->rel_y);
68 if (motion->rel_z) 71 if (motion->rel_z)
@@ -73,6 +76,9 @@ static void xenkbd_handle_motion_event(struct xenkbd_info *info,
73static void xenkbd_handle_position_event(struct xenkbd_info *info, 76static void xenkbd_handle_position_event(struct xenkbd_info *info,
74 struct xenkbd_position *pos) 77 struct xenkbd_position *pos)
75{ 78{
79 if (unlikely(!info->ptr))
80 return;
81
76 input_report_abs(info->ptr, ABS_X, pos->abs_x); 82 input_report_abs(info->ptr, ABS_X, pos->abs_x);
77 input_report_abs(info->ptr, ABS_Y, pos->abs_y); 83 input_report_abs(info->ptr, ABS_Y, pos->abs_y);
78 if (pos->rel_z) 84 if (pos->rel_z)
@@ -97,6 +103,9 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
97 return; 103 return;
98 } 104 }
99 105
106 if (unlikely(!dev))
107 return;
108
100 input_event(dev, EV_KEY, key->keycode, value); 109 input_event(dev, EV_KEY, key->keycode, value);
101 input_sync(dev); 110 input_sync(dev);
102} 111}
@@ -192,7 +201,7 @@ static int xenkbd_probe(struct xenbus_device *dev,
192 const struct xenbus_device_id *id) 201 const struct xenbus_device_id *id)
193{ 202{
194 int ret, i; 203 int ret, i;
195 unsigned int abs, touch; 204 bool with_mtouch, with_kbd, with_ptr;
196 struct xenkbd_info *info; 205 struct xenkbd_info *info;
197 struct input_dev *kbd, *ptr, *mtouch; 206 struct input_dev *kbd, *ptr, *mtouch;
198 207
@@ -211,106 +220,127 @@ static int xenkbd_probe(struct xenbus_device *dev,
211 if (!info->page) 220 if (!info->page)
212 goto error_nomem; 221 goto error_nomem;
213 222
214 /* Set input abs params to match backend screen res */ 223 /*
215 abs = xenbus_read_unsigned(dev->otherend, 224 * The below are reverse logic, e.g. if the feature is set, then
216 XENKBD_FIELD_FEAT_ABS_POINTER, 0); 225 * do not expose the corresponding virtual device.
217 ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend, 226 */
218 XENKBD_FIELD_WIDTH, 227 with_kbd = !xenbus_read_unsigned(dev->otherend,
219 ptr_size[KPARAM_X]); 228 XENKBD_FIELD_FEAT_DSBL_KEYBRD, 0);
220 ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend, 229
221 XENKBD_FIELD_HEIGHT, 230 with_ptr = !xenbus_read_unsigned(dev->otherend,
222 ptr_size[KPARAM_Y]); 231 XENKBD_FIELD_FEAT_DSBL_POINTER, 0);
223 if (abs) {
224 ret = xenbus_write(XBT_NIL, dev->nodename,
225 XENKBD_FIELD_REQ_ABS_POINTER, "1");
226 if (ret) {
227 pr_warn("xenkbd: can't request abs-pointer\n");
228 abs = 0;
229 }
230 }
231 232
232 touch = xenbus_read_unsigned(dev->nodename, 233 /* Direct logic: if set, then create multi-touch device. */
233 XENKBD_FIELD_FEAT_MTOUCH, 0); 234 with_mtouch = xenbus_read_unsigned(dev->otherend,
234 if (touch) { 235 XENKBD_FIELD_FEAT_MTOUCH, 0);
236 if (with_mtouch) {
235 ret = xenbus_write(XBT_NIL, dev->nodename, 237 ret = xenbus_write(XBT_NIL, dev->nodename,
236 XENKBD_FIELD_REQ_MTOUCH, "1"); 238 XENKBD_FIELD_REQ_MTOUCH, "1");
237 if (ret) { 239 if (ret) {
238 pr_warn("xenkbd: can't request multi-touch"); 240 pr_warn("xenkbd: can't request multi-touch");
239 touch = 0; 241 with_mtouch = 0;
240 } 242 }
241 } 243 }
242 244
243 /* keyboard */ 245 /* keyboard */
244 kbd = input_allocate_device(); 246 if (with_kbd) {
245 if (!kbd) 247 kbd = input_allocate_device();
246 goto error_nomem; 248 if (!kbd)
247 kbd->name = "Xen Virtual Keyboard"; 249 goto error_nomem;
248 kbd->phys = info->phys; 250 kbd->name = "Xen Virtual Keyboard";
249 kbd->id.bustype = BUS_PCI; 251 kbd->phys = info->phys;
250 kbd->id.vendor = 0x5853; 252 kbd->id.bustype = BUS_PCI;
251 kbd->id.product = 0xffff; 253 kbd->id.vendor = 0x5853;
252 254 kbd->id.product = 0xffff;
253 __set_bit(EV_KEY, kbd->evbit); 255
254 for (i = KEY_ESC; i < KEY_UNKNOWN; i++) 256 __set_bit(EV_KEY, kbd->evbit);
255 __set_bit(i, kbd->keybit); 257 for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
256 for (i = KEY_OK; i < KEY_MAX; i++) 258 __set_bit(i, kbd->keybit);
257 __set_bit(i, kbd->keybit); 259 for (i = KEY_OK; i < KEY_MAX; i++)
258 260 __set_bit(i, kbd->keybit);
259 ret = input_register_device(kbd); 261
260 if (ret) { 262 ret = input_register_device(kbd);
261 input_free_device(kbd); 263 if (ret) {
262 xenbus_dev_fatal(dev, ret, "input_register_device(kbd)"); 264 input_free_device(kbd);
263 goto error; 265 xenbus_dev_fatal(dev, ret,
266 "input_register_device(kbd)");
267 goto error;
268 }
269 info->kbd = kbd;
264 } 270 }
265 info->kbd = kbd;
266 271
267 /* pointing device */ 272 /* pointing device */
268 ptr = input_allocate_device(); 273 if (with_ptr) {
269 if (!ptr) 274 unsigned int abs;
270 goto error_nomem; 275
271 ptr->name = "Xen Virtual Pointer"; 276 /* Set input abs params to match backend screen res */
272 ptr->phys = info->phys; 277 abs = xenbus_read_unsigned(dev->otherend,
273 ptr->id.bustype = BUS_PCI; 278 XENKBD_FIELD_FEAT_ABS_POINTER, 0);
274 ptr->id.vendor = 0x5853; 279 ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend,
275 ptr->id.product = 0xfffe; 280 XENKBD_FIELD_WIDTH,
276 281 ptr_size[KPARAM_X]);
277 if (abs) { 282 ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend,
278 __set_bit(EV_ABS, ptr->evbit); 283 XENKBD_FIELD_HEIGHT,
279 input_set_abs_params(ptr, ABS_X, 0, ptr_size[KPARAM_X], 0, 0); 284 ptr_size[KPARAM_Y]);
280 input_set_abs_params(ptr, ABS_Y, 0, ptr_size[KPARAM_Y], 0, 0); 285 if (abs) {
281 } else { 286 ret = xenbus_write(XBT_NIL, dev->nodename,
282 input_set_capability(ptr, EV_REL, REL_X); 287 XENKBD_FIELD_REQ_ABS_POINTER, "1");
283 input_set_capability(ptr, EV_REL, REL_Y); 288 if (ret) {
284 } 289 pr_warn("xenkbd: can't request abs-pointer\n");
285 input_set_capability(ptr, EV_REL, REL_WHEEL); 290 abs = 0;
291 }
292 }
286 293
287 __set_bit(EV_KEY, ptr->evbit); 294 ptr = input_allocate_device();
288 for (i = BTN_LEFT; i <= BTN_TASK; i++) 295 if (!ptr)
289 __set_bit(i, ptr->keybit); 296 goto error_nomem;
297 ptr->name = "Xen Virtual Pointer";
298 ptr->phys = info->phys;
299 ptr->id.bustype = BUS_PCI;
300 ptr->id.vendor = 0x5853;
301 ptr->id.product = 0xfffe;
302
303 if (abs) {
304 __set_bit(EV_ABS, ptr->evbit);
305 input_set_abs_params(ptr, ABS_X, 0,
306 ptr_size[KPARAM_X], 0, 0);
307 input_set_abs_params(ptr, ABS_Y, 0,
308 ptr_size[KPARAM_Y], 0, 0);
309 } else {
310 input_set_capability(ptr, EV_REL, REL_X);
311 input_set_capability(ptr, EV_REL, REL_Y);
312 }
313 input_set_capability(ptr, EV_REL, REL_WHEEL);
290 314
291 ret = input_register_device(ptr); 315 __set_bit(EV_KEY, ptr->evbit);
292 if (ret) { 316 for (i = BTN_LEFT; i <= BTN_TASK; i++)
293 input_free_device(ptr); 317 __set_bit(i, ptr->keybit);
294 xenbus_dev_fatal(dev, ret, "input_register_device(ptr)"); 318
295 goto error; 319 ret = input_register_device(ptr);
320 if (ret) {
321 input_free_device(ptr);
322 xenbus_dev_fatal(dev, ret,
323 "input_register_device(ptr)");
324 goto error;
325 }
326 info->ptr = ptr;
296 } 327 }
297 info->ptr = ptr;
298 328
299 /* multi-touch device */ 329 /* multi-touch device */
300 if (touch) { 330 if (with_mtouch) {
301 int num_cont, width, height; 331 int num_cont, width, height;
302 332
303 mtouch = input_allocate_device(); 333 mtouch = input_allocate_device();
304 if (!mtouch) 334 if (!mtouch)
305 goto error_nomem; 335 goto error_nomem;
306 336
307 num_cont = xenbus_read_unsigned(info->xbdev->nodename, 337 num_cont = xenbus_read_unsigned(info->xbdev->otherend,
308 XENKBD_FIELD_MT_NUM_CONTACTS, 338 XENKBD_FIELD_MT_NUM_CONTACTS,
309 1); 339 1);
310 width = xenbus_read_unsigned(info->xbdev->nodename, 340 width = xenbus_read_unsigned(info->xbdev->otherend,
311 XENKBD_FIELD_MT_WIDTH, 341 XENKBD_FIELD_MT_WIDTH,
312 XENFB_WIDTH); 342 XENFB_WIDTH);
313 height = xenbus_read_unsigned(info->xbdev->nodename, 343 height = xenbus_read_unsigned(info->xbdev->otherend,
314 XENKBD_FIELD_MT_HEIGHT, 344 XENKBD_FIELD_MT_HEIGHT,
315 XENFB_HEIGHT); 345 XENFB_HEIGHT);
316 346
@@ -346,6 +376,11 @@ static int xenkbd_probe(struct xenbus_device *dev,
346 info->mtouch = mtouch; 376 info->mtouch = mtouch;
347 } 377 }
348 378
379 if (!(with_kbd || with_ptr || with_mtouch)) {
380 ret = -ENXIO;
381 goto error;
382 }
383
349 ret = xenkbd_connect_backend(dev, info); 384 ret = xenkbd_connect_backend(dev, info);
350 if (ret < 0) 385 if (ret < 0)
351 goto error; 386 goto error;
diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
index f0c9bf87b4e3..1365cd94ed9b 100644
--- a/drivers/input/misc/yealink.c
+++ b/drivers/input/misc/yealink.c
@@ -894,12 +894,12 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
894 894
895 /* allocate usb buffers */ 895 /* allocate usb buffers */
896 yld->irq_data = usb_alloc_coherent(udev, USB_PKT_LEN, 896 yld->irq_data = usb_alloc_coherent(udev, USB_PKT_LEN,
897 GFP_ATOMIC, &yld->irq_dma); 897 GFP_KERNEL, &yld->irq_dma);
898 if (yld->irq_data == NULL) 898 if (yld->irq_data == NULL)
899 return usb_cleanup(yld, -ENOMEM); 899 return usb_cleanup(yld, -ENOMEM);
900 900
901 yld->ctl_data = usb_alloc_coherent(udev, USB_PKT_LEN, 901 yld->ctl_data = usb_alloc_coherent(udev, USB_PKT_LEN,
902 GFP_ATOMIC, &yld->ctl_dma); 902 GFP_KERNEL, &yld->ctl_dma);
903 if (!yld->ctl_data) 903 if (!yld->ctl_data)
904 return usb_cleanup(yld, -ENOMEM); 904 return usb_cleanup(yld, -ENOMEM);
905 905
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index 032d27983b6c..f1e66e257cff 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -472,6 +472,7 @@ static int atp_status_check(struct urb *urb)
472 dev->info->datalen, dev->urb->actual_length); 472 dev->info->datalen, dev->urb->actual_length);
473 dev->overflow_warned = true; 473 dev->overflow_warned = true;
474 } 474 }
475 /* fall through */
475 case -ECONNRESET: 476 case -ECONNRESET:
476 case -ENOENT: 477 case -ENOENT:
477 case -ESHUTDOWN: 478 case -ESHUTDOWN:
@@ -810,7 +811,7 @@ static int atp_open(struct input_dev *input)
810{ 811{
811 struct atp *dev = input_get_drvdata(input); 812 struct atp *dev = input_get_drvdata(input);
812 813
813 if (usb_submit_urb(dev->urb, GFP_ATOMIC)) 814 if (usb_submit_urb(dev->urb, GFP_KERNEL))
814 return -EIO; 815 return -EIO;
815 816
816 dev->open = true; 817 dev->open = true;
@@ -976,7 +977,7 @@ static int atp_recover(struct atp *dev)
976 if (error) 977 if (error)
977 return error; 978 return error;
978 979
979 if (dev->open && usb_submit_urb(dev->urb, GFP_ATOMIC)) 980 if (dev->open && usb_submit_urb(dev->urb, GFP_KERNEL))
980 return -EIO; 981 return -EIO;
981 982
982 return 0; 983 return 0;
@@ -994,7 +995,7 @@ static int atp_resume(struct usb_interface *iface)
994{ 995{
995 struct atp *dev = usb_get_intfdata(iface); 996 struct atp *dev = usb_get_intfdata(iface);
996 997
997 if (dev->open && usb_submit_urb(dev->urb, GFP_ATOMIC)) 998 if (dev->open && usb_submit_urb(dev->urb, GFP_KERNEL))
998 return -EIO; 999 return -EIO;
999 1000
1000 return 0; 1001 return 0;
diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c
index 5775d40b3d53..14239fbd72cf 100644
--- a/drivers/input/mouse/cyapa_gen5.c
+++ b/drivers/input/mouse/cyapa_gen5.c
@@ -2554,6 +2554,7 @@ static int cyapa_gen5_do_operational_check(struct cyapa *cyapa)
2554 } 2554 }
2555 2555
2556 cyapa->state = CYAPA_STATE_GEN5_APP; 2556 cyapa->state = CYAPA_STATE_GEN5_APP;
2557 /* fall through */
2557 2558
2558 case CYAPA_STATE_GEN5_APP: 2559 case CYAPA_STATE_GEN5_APP:
2559 /* 2560 /*
diff --git a/drivers/input/mouse/cyapa_gen6.c b/drivers/input/mouse/cyapa_gen6.c
index 016397850b1b..c1b524ab4623 100644
--- a/drivers/input/mouse/cyapa_gen6.c
+++ b/drivers/input/mouse/cyapa_gen6.c
@@ -680,6 +680,7 @@ static int cyapa_gen6_operational_check(struct cyapa *cyapa)
680 } 680 }
681 681
682 cyapa->state = CYAPA_STATE_GEN6_APP; 682 cyapa->state = CYAPA_STATE_GEN6_APP;
683 /* fall through */
683 684
684 case CYAPA_STATE_GEN6_APP: 685 case CYAPA_STATE_GEN6_APP:
685 /* 686 /*
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index dd85b16dc6f8..44f57cf6675b 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -340,7 +340,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
340 */ 340 */
341 if (packet[3] & 0x80) 341 if (packet[3] & 0x80)
342 fingers = 4; 342 fingers = 4;
343 /* pass through... */ 343 /* fall through */
344 case 1: 344 case 1:
345 /* 345 /*
346 * byte 1: . . . . x11 x10 x9 x8 346 * byte 1: . . . . x11 x10 x9 x8
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c
index 9ce71dfa0de1..b9e68606c44a 100644
--- a/drivers/input/mouse/inport.c
+++ b/drivers/input/mouse/inport.c
@@ -26,10 +26,6 @@
26 * You should have received a copy of the GNU General Public License 26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software 27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * Should you need to contact me, the author, you can do so either by
31 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
32 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
33 */ 29 */
34 30
35#include <linux/module.h> 31#include <linux/module.h>
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c
index 6f165e053f4d..2fd6c84cd5b7 100644
--- a/drivers/input/mouse/logibm.c
+++ b/drivers/input/mouse/logibm.c
@@ -27,10 +27,6 @@
27 * You should have received a copy of the GNU General Public License 27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software 28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 *
31 * Should you need to contact me, the author, you can do so either by
32 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
33 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
34 */ 30 */
35 31
36#include <linux/module.h> 32#include <linux/module.h>
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index 7b02b652e267..b8965e6bc890 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/module.h> 28#include <linux/module.h>
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index 8df526620ebf..3e8fb8136452 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
@@ -143,7 +139,8 @@ static void sermouse_process_ms(struct sermouse *sermouse, signed char data)
143 switch (sermouse->type) { 139 switch (sermouse->type) {
144 140
145 case SERIO_MS: 141 case SERIO_MS:
146 sermouse->type = SERIO_MP; 142 sermouse->type = SERIO_MP;
143 /* fall through */
147 144
148 case SERIO_MP: 145 case SERIO_MP:
149 if ((data >> 2) & 3) break; /* M++ Wireless Extension packet. */ 146 if ((data >> 2) & 3) break; /* M++ Wireless Extension packet. */
@@ -154,6 +151,7 @@ static void sermouse_process_ms(struct sermouse *sermouse, signed char data)
154 case SERIO_MZP: 151 case SERIO_MZP:
155 case SERIO_MZPP: 152 case SERIO_MZPP:
156 input_report_key(dev, BTN_SIDE, (data >> 5) & 1); 153 input_report_key(dev, BTN_SIDE, (data >> 5) & 1);
154 /* fall through */
157 155
158 case SERIO_MZ: 156 case SERIO_MZ:
159 input_report_key(dev, BTN_MIDDLE, (data >> 4) & 1); 157 input_report_key(dev, BTN_MIDDLE, (data >> 4) & 1);
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
index 9c54c43c9749..2d1e2993b5a8 100644
--- a/drivers/input/serio/ct82c710.c
+++ b/drivers/input/serio/ct82c710.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 824f4c1c1f31..b8bc71569349 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -573,6 +573,9 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
573 port = &i8042_ports[port_no]; 573 port = &i8042_ports[port_no];
574 serio = port->exists ? port->serio : NULL; 574 serio = port->exists ? port->serio : NULL;
575 575
576 if (irq && serio)
577 pm_wakeup_event(&serio->dev, 0);
578
576 filter_dbg(port->driver_bound, data, "<- i8042 (interrupt, %d, %d%s%s)\n", 579 filter_dbg(port->driver_bound, data, "<- i8042 (interrupt, %d, %d%s%s)\n",
577 port_no, irq, 580 port_no, irq,
578 dfl & SERIO_PARITY ? ", bad parity" : "", 581 dfl & SERIO_PARITY ? ", bad parity" : "",
diff --git a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
index d0fccc8ec259..fbb6b33845fa 100644
--- a/drivers/input/serio/q40kbd.c
+++ b/drivers/input/serio/q40kbd.c
@@ -23,10 +23,6 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
30 */ 26 */
31 27
32#include <linux/module.h> 28#include <linux/module.h>
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index 8cf964736902..a308d7811427 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -21,10 +21,6 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
28 */ 24 */
29 25
30#include <linux/module.h> 26#include <linux/module.h>
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 24a90c8db5b3..2e1fb0649260 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 545fa6e89035..c82cd5079d0e 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1712,7 +1712,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1712 } 1712 }
1713 1713
1714 aiptek->data = usb_alloc_coherent(usbdev, AIPTEK_PACKET_LENGTH, 1714 aiptek->data = usb_alloc_coherent(usbdev, AIPTEK_PACKET_LENGTH,
1715 GFP_ATOMIC, &aiptek->data_dma); 1715 GFP_KERNEL, &aiptek->data_dma);
1716 if (!aiptek->data) { 1716 if (!aiptek->data) {
1717 dev_warn(&intf->dev, "cannot allocate usb buffer\n"); 1717 dev_warn(&intf->dev, "cannot allocate usb buffer\n");
1718 goto fail1; 1718 goto fail1;
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 32267c1afebc..5374bd573e66 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -151,6 +151,18 @@ config TOUCHSCREEN_BU21013
151 To compile this driver as a module, choose M here: the 151 To compile this driver as a module, choose M here: the
152 module will be called bu21013_ts. 152 module will be called bu21013_ts.
153 153
154config TOUCHSCREEN_BU21029
155 tristate "Rohm BU21029 based touch panel controllers"
156 depends on I2C
157 help
158 Say Y here if you have a Rohm BU21029 touchscreen controller
159 connected to your system.
160
161 If unsure, say N.
162
163 To compile this driver as a module, choose M here: the
164 module will be called bu21029_ts.
165
154config TOUCHSCREEN_CHIPONE_ICN8318 166config TOUCHSCREEN_CHIPONE_ICN8318
155 tristate "chipone icn8318 touchscreen controller" 167 tristate "chipone icn8318 touchscreen controller"
156 depends on GPIOLIB || COMPILE_TEST 168 depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index fd4fd32fb73f..c2175163152d 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_TOUCHSCREEN_AR1021_I2C) += ar1021_i2c.o
18obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o 18obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
19obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o 19obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o
20obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o 20obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
21obj-$(CONFIG_TOUCHSCREEN_BU21029) += bu21029_ts.o
21obj-$(CONFIG_TOUCHSCREEN_CHIPONE_ICN8318) += chipone_icn8318.o 22obj-$(CONFIG_TOUCHSCREEN_CHIPONE_ICN8318) += chipone_icn8318.o
22obj-$(CONFIG_TOUCHSCREEN_CHIPONE_ICN8505) += chipone_icn8505.o 23obj-$(CONFIG_TOUCHSCREEN_CHIPONE_ICN8505) += chipone_icn8505.o
23obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o 24obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 54fe190fd4bc..3232af5dcf89 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -75,6 +75,7 @@
75#define MXT_SPT_DIGITIZER_T43 43 75#define MXT_SPT_DIGITIZER_T43 43
76#define MXT_SPT_MESSAGECOUNT_T44 44 76#define MXT_SPT_MESSAGECOUNT_T44 44
77#define MXT_SPT_CTECONFIG_T46 46 77#define MXT_SPT_CTECONFIG_T46 46
78#define MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71 71
78#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100 79#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100
79 80
80/* MXT_GEN_MESSAGE_T5 object */ 81/* MXT_GEN_MESSAGE_T5 object */
@@ -88,12 +89,12 @@
88#define MXT_COMMAND_DIAGNOSTIC 5 89#define MXT_COMMAND_DIAGNOSTIC 5
89 90
90/* Define for T6 status byte */ 91/* Define for T6 status byte */
91#define MXT_T6_STATUS_RESET (1 << 7) 92#define MXT_T6_STATUS_RESET BIT(7)
92#define MXT_T6_STATUS_OFL (1 << 6) 93#define MXT_T6_STATUS_OFL BIT(6)
93#define MXT_T6_STATUS_SIGERR (1 << 5) 94#define MXT_T6_STATUS_SIGERR BIT(5)
94#define MXT_T6_STATUS_CAL (1 << 4) 95#define MXT_T6_STATUS_CAL BIT(4)
95#define MXT_T6_STATUS_CFGERR (1 << 3) 96#define MXT_T6_STATUS_CFGERR BIT(3)
96#define MXT_T6_STATUS_COMSERR (1 << 2) 97#define MXT_T6_STATUS_COMSERR BIT(2)
97 98
98/* MXT_GEN_POWER_T7 field */ 99/* MXT_GEN_POWER_T7 field */
99struct t7_config { 100struct t7_config {
@@ -112,14 +113,14 @@ struct t7_config {
112#define MXT_T9_RANGE 18 113#define MXT_T9_RANGE 18
113 114
114/* MXT_TOUCH_MULTI_T9 status */ 115/* MXT_TOUCH_MULTI_T9 status */
115#define MXT_T9_UNGRIP (1 << 0) 116#define MXT_T9_UNGRIP BIT(0)
116#define MXT_T9_SUPPRESS (1 << 1) 117#define MXT_T9_SUPPRESS BIT(1)
117#define MXT_T9_AMP (1 << 2) 118#define MXT_T9_AMP BIT(2)
118#define MXT_T9_VECTOR (1 << 3) 119#define MXT_T9_VECTOR BIT(3)
119#define MXT_T9_MOVE (1 << 4) 120#define MXT_T9_MOVE BIT(4)
120#define MXT_T9_RELEASE (1 << 5) 121#define MXT_T9_RELEASE BIT(5)
121#define MXT_T9_PRESS (1 << 6) 122#define MXT_T9_PRESS BIT(6)
122#define MXT_T9_DETECT (1 << 7) 123#define MXT_T9_DETECT BIT(7)
123 124
124struct t9_range { 125struct t9_range {
125 __le16 x; 126 __le16 x;
@@ -127,9 +128,9 @@ struct t9_range {
127} __packed; 128} __packed;
128 129
129/* MXT_TOUCH_MULTI_T9 orient */ 130/* MXT_TOUCH_MULTI_T9 orient */
130#define MXT_T9_ORIENT_SWITCH (1 << 0) 131#define MXT_T9_ORIENT_SWITCH BIT(0)
131#define MXT_T9_ORIENT_INVERTX (1 << 1) 132#define MXT_T9_ORIENT_INVERTX BIT(1)
132#define MXT_T9_ORIENT_INVERTY (1 << 2) 133#define MXT_T9_ORIENT_INVERTY BIT(2)
133 134
134/* MXT_SPT_COMMSCONFIG_T18 */ 135/* MXT_SPT_COMMSCONFIG_T18 */
135#define MXT_COMMS_CTRL 0 136#define MXT_COMMS_CTRL 0
@@ -214,7 +215,7 @@ enum t100_type {
214#define MXT_FRAME_CRC_PASS 0x04 215#define MXT_FRAME_CRC_PASS 0x04
215#define MXT_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */ 216#define MXT_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */
216#define MXT_BOOT_STATUS_MASK 0x3f 217#define MXT_BOOT_STATUS_MASK 0x3f
217#define MXT_BOOT_EXTENDED_ID (1 << 5) 218#define MXT_BOOT_EXTENDED_ID BIT(5)
218#define MXT_BOOT_ID_MASK 0x1f 219#define MXT_BOOT_ID_MASK 0x1f
219 220
220/* Touchscreen absolute values */ 221/* Touchscreen absolute values */
@@ -276,6 +277,19 @@ enum mxt_suspend_mode {
276 MXT_SUSPEND_T9_CTRL = 1, 277 MXT_SUSPEND_T9_CTRL = 1,
277}; 278};
278 279
280/* Config update context */
281struct mxt_cfg {
282 u8 *raw;
283 size_t raw_size;
284 off_t raw_pos;
285
286 u8 *mem;
287 size_t mem_size;
288 int start_ofs;
289
290 struct mxt_info info;
291};
292
279/* Each client has this additional data */ 293/* Each client has this additional data */
280struct mxt_data { 294struct mxt_data {
281 struct i2c_client *client; 295 struct i2c_client *client;
@@ -317,6 +331,7 @@ struct mxt_data {
317 u8 T6_reportid; 331 u8 T6_reportid;
318 u16 T6_address; 332 u16 T6_address;
319 u16 T7_address; 333 u16 T7_address;
334 u16 T71_address;
320 u8 T9_reportid_min; 335 u8 T9_reportid_min;
321 u8 T9_reportid_max; 336 u8 T9_reportid_max;
322 u8 T19_reportid; 337 u8 T19_reportid;
@@ -382,6 +397,7 @@ static bool mxt_object_readable(unsigned int type)
382 case MXT_SPT_USERDATA_T38: 397 case MXT_SPT_USERDATA_T38:
383 case MXT_SPT_DIGITIZER_T43: 398 case MXT_SPT_DIGITIZER_T43:
384 case MXT_SPT_CTECONFIG_T46: 399 case MXT_SPT_CTECONFIG_T46:
400 case MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71:
385 return true; 401 return true;
386 default: 402 default:
387 return false; 403 return false;
@@ -712,13 +728,13 @@ static void mxt_proc_t6_messages(struct mxt_data *data, u8 *msg)
712 u8 status = msg[1]; 728 u8 status = msg[1];
713 u32 crc = msg[2] | (msg[3] << 8) | (msg[4] << 16); 729 u32 crc = msg[2] | (msg[3] << 8) | (msg[4] << 16);
714 730
715 complete(&data->crc_completion);
716
717 if (crc != data->config_crc) { 731 if (crc != data->config_crc) {
718 data->config_crc = crc; 732 data->config_crc = crc;
719 dev_dbg(dev, "T6 Config Checksum: 0x%06X\n", crc); 733 dev_dbg(dev, "T6 Config Checksum: 0x%06X\n", crc);
720 } 734 }
721 735
736 complete(&data->crc_completion);
737
722 /* Detect reset */ 738 /* Detect reset */
723 if (status & MXT_T6_STATUS_RESET) 739 if (status & MXT_T6_STATUS_RESET)
724 complete(&data->reset_completion); 740 complete(&data->reset_completion);
@@ -827,6 +843,10 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
827 mxt_input_sync(data); 843 mxt_input_sync(data);
828 } 844 }
829 845
846 /* if active, pressure must be non-zero */
847 if (!amplitude)
848 amplitude = MXT_PRESSURE_DEFAULT;
849
830 /* Touch active */ 850 /* Touch active */
831 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 1); 851 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 1);
832 input_report_abs(input_dev, ABS_MT_POSITION_X, x); 852 input_report_abs(input_dev, ABS_MT_POSITION_X, x);
@@ -1279,12 +1299,7 @@ static u32 mxt_calculate_crc(u8 *base, off_t start_off, off_t end_off)
1279 return crc; 1299 return crc;
1280} 1300}
1281 1301
1282static int mxt_prepare_cfg_mem(struct mxt_data *data, 1302static int mxt_prepare_cfg_mem(struct mxt_data *data, struct mxt_cfg *cfg)
1283 const struct firmware *cfg,
1284 unsigned int data_pos,
1285 unsigned int cfg_start_ofs,
1286 u8 *config_mem,
1287 size_t config_mem_size)
1288{ 1303{
1289 struct device *dev = &data->client->dev; 1304 struct device *dev = &data->client->dev;
1290 struct mxt_object *object; 1305 struct mxt_object *object;
@@ -1295,9 +1310,9 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data,
1295 u16 reg; 1310 u16 reg;
1296 u8 val; 1311 u8 val;
1297 1312
1298 while (data_pos < cfg->size) { 1313 while (cfg->raw_pos < cfg->raw_size) {
1299 /* Read type, instance, length */ 1314 /* Read type, instance, length */
1300 ret = sscanf(cfg->data + data_pos, "%x %x %x%n", 1315 ret = sscanf(cfg->raw + cfg->raw_pos, "%x %x %x%n",
1301 &type, &instance, &size, &offset); 1316 &type, &instance, &size, &offset);
1302 if (ret == 0) { 1317 if (ret == 0) {
1303 /* EOF */ 1318 /* EOF */
@@ -1306,20 +1321,20 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data,
1306 dev_err(dev, "Bad format: failed to parse object\n"); 1321 dev_err(dev, "Bad format: failed to parse object\n");
1307 return -EINVAL; 1322 return -EINVAL;
1308 } 1323 }
1309 data_pos += offset; 1324 cfg->raw_pos += offset;
1310 1325
1311 object = mxt_get_object(data, type); 1326 object = mxt_get_object(data, type);
1312 if (!object) { 1327 if (!object) {
1313 /* Skip object */ 1328 /* Skip object */
1314 for (i = 0; i < size; i++) { 1329 for (i = 0; i < size; i++) {
1315 ret = sscanf(cfg->data + data_pos, "%hhx%n", 1330 ret = sscanf(cfg->raw + cfg->raw_pos, "%hhx%n",
1316 &val, &offset); 1331 &val, &offset);
1317 if (ret != 1) { 1332 if (ret != 1) {
1318 dev_err(dev, "Bad format in T%d at %d\n", 1333 dev_err(dev, "Bad format in T%d at %d\n",
1319 type, i); 1334 type, i);
1320 return -EINVAL; 1335 return -EINVAL;
1321 } 1336 }
1322 data_pos += offset; 1337 cfg->raw_pos += offset;
1323 } 1338 }
1324 continue; 1339 continue;
1325 } 1340 }
@@ -1354,7 +1369,7 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data,
1354 reg = object->start_address + mxt_obj_size(object) * instance; 1369 reg = object->start_address + mxt_obj_size(object) * instance;
1355 1370
1356 for (i = 0; i < size; i++) { 1371 for (i = 0; i < size; i++) {
1357 ret = sscanf(cfg->data + data_pos, "%hhx%n", 1372 ret = sscanf(cfg->raw + cfg->raw_pos, "%hhx%n",
1358 &val, 1373 &val,
1359 &offset); 1374 &offset);
1360 if (ret != 1) { 1375 if (ret != 1) {
@@ -1362,15 +1377,15 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data,
1362 type, i); 1377 type, i);
1363 return -EINVAL; 1378 return -EINVAL;
1364 } 1379 }
1365 data_pos += offset; 1380 cfg->raw_pos += offset;
1366 1381
1367 if (i > mxt_obj_size(object)) 1382 if (i > mxt_obj_size(object))
1368 continue; 1383 continue;
1369 1384
1370 byte_offset = reg + i - cfg_start_ofs; 1385 byte_offset = reg + i - cfg->start_ofs;
1371 1386
1372 if (byte_offset >= 0 && byte_offset < config_mem_size) { 1387 if (byte_offset >= 0 && byte_offset < cfg->mem_size) {
1373 *(config_mem + byte_offset) = val; 1388 *(cfg->mem + byte_offset) = val;
1374 } else { 1389 } else {
1375 dev_err(dev, "Bad object: reg:%d, T%d, ofs=%d\n", 1390 dev_err(dev, "Bad object: reg:%d, T%d, ofs=%d\n",
1376 reg, object->type, byte_offset); 1391 reg, object->type, byte_offset);
@@ -1382,22 +1397,21 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data,
1382 return 0; 1397 return 0;
1383} 1398}
1384 1399
1385static int mxt_upload_cfg_mem(struct mxt_data *data, unsigned int cfg_start, 1400static int mxt_upload_cfg_mem(struct mxt_data *data, struct mxt_cfg *cfg)
1386 u8 *config_mem, size_t config_mem_size)
1387{ 1401{
1388 unsigned int byte_offset = 0; 1402 unsigned int byte_offset = 0;
1389 int error; 1403 int error;
1390 1404
1391 /* Write configuration as blocks */ 1405 /* Write configuration as blocks */
1392 while (byte_offset < config_mem_size) { 1406 while (byte_offset < cfg->mem_size) {
1393 unsigned int size = config_mem_size - byte_offset; 1407 unsigned int size = cfg->mem_size - byte_offset;
1394 1408
1395 if (size > MXT_MAX_BLOCK_WRITE) 1409 if (size > MXT_MAX_BLOCK_WRITE)
1396 size = MXT_MAX_BLOCK_WRITE; 1410 size = MXT_MAX_BLOCK_WRITE;
1397 1411
1398 error = __mxt_write_reg(data->client, 1412 error = __mxt_write_reg(data->client,
1399 cfg_start + byte_offset, 1413 cfg->start_ofs + byte_offset,
1400 size, config_mem + byte_offset); 1414 size, cfg->mem + byte_offset);
1401 if (error) { 1415 if (error) {
1402 dev_err(&data->client->dev, 1416 dev_err(&data->client->dev,
1403 "Config write error, ret=%d\n", error); 1417 "Config write error, ret=%d\n", error);
@@ -1431,65 +1445,75 @@ static int mxt_init_t7_power_cfg(struct mxt_data *data);
1431 * <SIZE> - 2-byte object size as hex 1445 * <SIZE> - 2-byte object size as hex
1432 * <CONTENTS> - array of <SIZE> 1-byte hex values 1446 * <CONTENTS> - array of <SIZE> 1-byte hex values
1433 */ 1447 */
1434static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg) 1448static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw)
1435{ 1449{
1436 struct device *dev = &data->client->dev; 1450 struct device *dev = &data->client->dev;
1437 struct mxt_info cfg_info; 1451 struct mxt_cfg cfg;
1438 int ret; 1452 int ret;
1439 int offset; 1453 int offset;
1440 int data_pos;
1441 int i; 1454 int i;
1442 int cfg_start_ofs;
1443 u32 info_crc, config_crc, calculated_crc; 1455 u32 info_crc, config_crc, calculated_crc;
1444 u8 *config_mem; 1456 u16 crc_start = 0;
1445 size_t config_mem_size; 1457
1458 /* Make zero terminated copy of the OBP_RAW file */
1459 cfg.raw = kmemdup_nul(fw->data, fw->size, GFP_KERNEL);
1460 if (!cfg.raw)
1461 return -ENOMEM;
1462
1463 cfg.raw_size = fw->size;
1446 1464
1447 mxt_update_crc(data, MXT_COMMAND_REPORTALL, 1); 1465 mxt_update_crc(data, MXT_COMMAND_REPORTALL, 1);
1448 1466
1449 if (strncmp(cfg->data, MXT_CFG_MAGIC, strlen(MXT_CFG_MAGIC))) { 1467 if (strncmp(cfg.raw, MXT_CFG_MAGIC, strlen(MXT_CFG_MAGIC))) {
1450 dev_err(dev, "Unrecognised config file\n"); 1468 dev_err(dev, "Unrecognised config file\n");
1451 return -EINVAL; 1469 ret = -EINVAL;
1470 goto release_raw;
1452 } 1471 }
1453 1472
1454 data_pos = strlen(MXT_CFG_MAGIC); 1473 cfg.raw_pos = strlen(MXT_CFG_MAGIC);
1455 1474
1456 /* Load information block and check */ 1475 /* Load information block and check */
1457 for (i = 0; i < sizeof(struct mxt_info); i++) { 1476 for (i = 0; i < sizeof(struct mxt_info); i++) {
1458 ret = sscanf(cfg->data + data_pos, "%hhx%n", 1477 ret = sscanf(cfg.raw + cfg.raw_pos, "%hhx%n",
1459 (unsigned char *)&cfg_info + i, 1478 (unsigned char *)&cfg.info + i,
1460 &offset); 1479 &offset);
1461 if (ret != 1) { 1480 if (ret != 1) {
1462 dev_err(dev, "Bad format\n"); 1481 dev_err(dev, "Bad format\n");
1463 return -EINVAL; 1482 ret = -EINVAL;
1483 goto release_raw;
1464 } 1484 }
1465 1485
1466 data_pos += offset; 1486 cfg.raw_pos += offset;
1467 } 1487 }
1468 1488
1469 if (cfg_info.family_id != data->info->family_id) { 1489 if (cfg.info.family_id != data->info->family_id) {
1470 dev_err(dev, "Family ID mismatch!\n"); 1490 dev_err(dev, "Family ID mismatch!\n");
1471 return -EINVAL; 1491 ret = -EINVAL;
1492 goto release_raw;
1472 } 1493 }
1473 1494
1474 if (cfg_info.variant_id != data->info->variant_id) { 1495 if (cfg.info.variant_id != data->info->variant_id) {
1475 dev_err(dev, "Variant ID mismatch!\n"); 1496 dev_err(dev, "Variant ID mismatch!\n");
1476 return -EINVAL; 1497 ret = -EINVAL;
1498 goto release_raw;
1477 } 1499 }
1478 1500
1479 /* Read CRCs */ 1501 /* Read CRCs */
1480 ret = sscanf(cfg->data + data_pos, "%x%n", &info_crc, &offset); 1502 ret = sscanf(cfg.raw + cfg.raw_pos, "%x%n", &info_crc, &offset);
1481 if (ret != 1) { 1503 if (ret != 1) {
1482 dev_err(dev, "Bad format: failed to parse Info CRC\n"); 1504 dev_err(dev, "Bad format: failed to parse Info CRC\n");
1483 return -EINVAL; 1505 ret = -EINVAL;
1506 goto release_raw;
1484 } 1507 }
1485 data_pos += offset; 1508 cfg.raw_pos += offset;
1486 1509
1487 ret = sscanf(cfg->data + data_pos, "%x%n", &config_crc, &offset); 1510 ret = sscanf(cfg.raw + cfg.raw_pos, "%x%n", &config_crc, &offset);
1488 if (ret != 1) { 1511 if (ret != 1) {
1489 dev_err(dev, "Bad format: failed to parse Config CRC\n"); 1512 dev_err(dev, "Bad format: failed to parse Config CRC\n");
1490 return -EINVAL; 1513 ret = -EINVAL;
1514 goto release_raw;
1491 } 1515 }
1492 data_pos += offset; 1516 cfg.raw_pos += offset;
1493 1517
1494 /* 1518 /*
1495 * The Info Block CRC is calculated over mxt_info and the object 1519 * The Info Block CRC is calculated over mxt_info and the object
@@ -1515,39 +1539,39 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
1515 } 1539 }
1516 1540
1517 /* Malloc memory to store configuration */ 1541 /* Malloc memory to store configuration */
1518 cfg_start_ofs = MXT_OBJECT_START + 1542 cfg.start_ofs = MXT_OBJECT_START +
1519 data->info->object_num * sizeof(struct mxt_object) + 1543 data->info->object_num * sizeof(struct mxt_object) +
1520 MXT_INFO_CHECKSUM_SIZE; 1544 MXT_INFO_CHECKSUM_SIZE;
1521 config_mem_size = data->mem_size - cfg_start_ofs; 1545 cfg.mem_size = data->mem_size - cfg.start_ofs;
1522 config_mem = kzalloc(config_mem_size, GFP_KERNEL); 1546 cfg.mem = kzalloc(cfg.mem_size, GFP_KERNEL);
1523 if (!config_mem) { 1547 if (!cfg.mem) {
1524 dev_err(dev, "Failed to allocate memory\n"); 1548 ret = -ENOMEM;
1525 return -ENOMEM; 1549 goto release_raw;
1526 } 1550 }
1527 1551
1528 ret = mxt_prepare_cfg_mem(data, cfg, data_pos, cfg_start_ofs, 1552 ret = mxt_prepare_cfg_mem(data, &cfg);
1529 config_mem, config_mem_size);
1530 if (ret) 1553 if (ret)
1531 goto release_mem; 1554 goto release_mem;
1532 1555
1533 /* Calculate crc of the received configs (not the raw config file) */ 1556 /* Calculate crc of the received configs (not the raw config file) */
1534 if (data->T7_address < cfg_start_ofs) { 1557 if (data->T71_address)
1535 dev_err(dev, "Bad T7 address, T7addr = %x, config offset %x\n", 1558 crc_start = data->T71_address;
1536 data->T7_address, cfg_start_ofs); 1559 else if (data->T7_address)
1537 ret = 0; 1560 crc_start = data->T7_address;
1538 goto release_mem; 1561 else
1539 } 1562 dev_warn(dev, "Could not find CRC start\n");
1540 1563
1541 calculated_crc = mxt_calculate_crc(config_mem, 1564 if (crc_start > cfg.start_ofs) {
1542 data->T7_address - cfg_start_ofs, 1565 calculated_crc = mxt_calculate_crc(cfg.mem,
1543 config_mem_size); 1566 crc_start - cfg.start_ofs,
1567 cfg.mem_size);
1544 1568
1545 if (config_crc > 0 && config_crc != calculated_crc) 1569 if (config_crc > 0 && config_crc != calculated_crc)
1546 dev_warn(dev, "Config CRC error, calculated=%06X, file=%06X\n", 1570 dev_warn(dev, "Config CRC in file inconsistent, calculated=%06X, file=%06X\n",
1547 calculated_crc, config_crc); 1571 calculated_crc, config_crc);
1572 }
1548 1573
1549 ret = mxt_upload_cfg_mem(data, cfg_start_ofs, 1574 ret = mxt_upload_cfg_mem(data, &cfg);
1550 config_mem, config_mem_size);
1551 if (ret) 1575 if (ret)
1552 goto release_mem; 1576 goto release_mem;
1553 1577
@@ -1562,8 +1586,10 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
1562 /* T7 config may have changed */ 1586 /* T7 config may have changed */
1563 mxt_init_t7_power_cfg(data); 1587 mxt_init_t7_power_cfg(data);
1564 1588
1589release_raw:
1590 kfree(cfg.raw);
1565release_mem: 1591release_mem:
1566 kfree(config_mem); 1592 kfree(cfg.mem);
1567 return ret; 1593 return ret;
1568} 1594}
1569 1595
@@ -1591,6 +1617,7 @@ static void mxt_free_object_table(struct mxt_data *data)
1591 data->T5_msg_size = 0; 1617 data->T5_msg_size = 0;
1592 data->T6_reportid = 0; 1618 data->T6_reportid = 0;
1593 data->T7_address = 0; 1619 data->T7_address = 0;
1620 data->T71_address = 0;
1594 data->T9_reportid_min = 0; 1621 data->T9_reportid_min = 0;
1595 data->T9_reportid_max = 0; 1622 data->T9_reportid_max = 0;
1596 data->T19_reportid = 0; 1623 data->T19_reportid = 0;
@@ -1656,12 +1683,16 @@ static int mxt_parse_object_table(struct mxt_data *data,
1656 case MXT_GEN_POWER_T7: 1683 case MXT_GEN_POWER_T7:
1657 data->T7_address = object->start_address; 1684 data->T7_address = object->start_address;
1658 break; 1685 break;
1686 case MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71:
1687 data->T71_address = object->start_address;
1688 break;
1659 case MXT_TOUCH_MULTI_T9: 1689 case MXT_TOUCH_MULTI_T9:
1660 data->multitouch = MXT_TOUCH_MULTI_T9; 1690 data->multitouch = MXT_TOUCH_MULTI_T9;
1691 /* Only handle messages from first T9 instance */
1661 data->T9_reportid_min = min_id; 1692 data->T9_reportid_min = min_id;
1662 data->T9_reportid_max = max_id; 1693 data->T9_reportid_max = min_id +
1663 data->num_touchids = object->num_report_ids 1694 object->num_report_ids - 1;
1664 * mxt_obj_instances(object); 1695 data->num_touchids = object->num_report_ids;
1665 break; 1696 break;
1666 case MXT_SPT_MESSAGECOUNT_T44: 1697 case MXT_SPT_MESSAGECOUNT_T44:
1667 data->T44_address = object->start_address; 1698 data->T44_address = object->start_address;
@@ -1981,10 +2012,8 @@ static int mxt_initialize_input_device(struct mxt_data *data)
1981 2012
1982 /* Register input device */ 2013 /* Register input device */
1983 input_dev = input_allocate_device(); 2014 input_dev = input_allocate_device();
1984 if (!input_dev) { 2015 if (!input_dev)
1985 dev_err(dev, "Failed to allocate memory\n");
1986 return -ENOMEM; 2016 return -ENOMEM;
1987 }
1988 2017
1989 input_dev->name = "Atmel maXTouch Touchscreen"; 2018 input_dev->name = "Atmel maXTouch Touchscreen";
1990 input_dev->phys = data->phys; 2019 input_dev->phys = data->phys;
@@ -2055,12 +2084,6 @@ static int mxt_initialize_input_device(struct mxt_data *data)
2055 } 2084 }
2056 2085
2057 if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && 2086 if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
2058 data->t100_aux_ampl) {
2059 input_set_abs_params(input_dev, ABS_MT_PRESSURE,
2060 0, 255, 0, 0);
2061 }
2062
2063 if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
2064 data->t100_aux_vect) { 2087 data->t100_aux_vect) {
2065 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 2088 input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
2066 0, 255, 0, 0); 2089 0, 255, 0, 0);
diff --git a/drivers/input/touchscreen/bu21029_ts.c b/drivers/input/touchscreen/bu21029_ts.c
new file mode 100644
index 000000000000..49a8d4bbca3a
--- /dev/null
+++ b/drivers/input/touchscreen/bu21029_ts.c
@@ -0,0 +1,484 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Rohm BU21029 touchscreen controller driver
4 *
5 * Copyright (C) 2015-2018 Bosch Sicherheitssysteme GmbH
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/delay.h>
13#include <linux/gpio/consumer.h>
14#include <linux/i2c.h>
15#include <linux/input.h>
16#include <linux/input/touchscreen.h>
17#include <linux/interrupt.h>
18#include <linux/irq.h>
19#include <linux/module.h>
20#include <linux/regulator/consumer.h>
21#include <linux/timer.h>
22
23/*
24 * HW_ID1 Register (PAGE=0, ADDR=0x0E, Reset value=0x02, Read only)
25 * +--------+--------+--------+--------+--------+--------+--------+--------+
26 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
27 * +--------+--------+--------+--------+--------+--------+--------+--------+
28 * | HW_IDH |
29 * +--------+--------+--------+--------+--------+--------+--------+--------+
30 * HW_ID2 Register (PAGE=0, ADDR=0x0F, Reset value=0x29, Read only)
31 * +--------+--------+--------+--------+--------+--------+--------+--------+
32 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
33 * +--------+--------+--------+--------+--------+--------+--------+--------+
34 * | HW_IDL |
35 * +--------+--------+--------+--------+--------+--------+--------+--------+
36 * HW_IDH: high 8bits of IC's ID
37 * HW_IDL: low 8bits of IC's ID
38 */
39#define BU21029_HWID_REG (0x0E << 3)
40#define SUPPORTED_HWID 0x0229
41
42/*
43 * CFR0 Register (PAGE=0, ADDR=0x00, Reset value=0x20)
44 * +--------+--------+--------+--------+--------+--------+--------+--------+
45 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
46 * +--------+--------+--------+--------+--------+--------+--------+--------+
47 * | 0 | 0 | CALIB | INTRM | 0 | 0 | 0 | 0 |
48 * +--------+--------+--------+--------+--------+--------+--------+--------+
49 * CALIB: 0 = not to use calibration result (*)
50 * 1 = use calibration result
51 * INTRM: 0 = INT output depend on "pen down" (*)
52 * 1 = INT output always "0"
53 */
54#define BU21029_CFR0_REG (0x00 << 3)
55#define CFR0_VALUE 0x00
56
57/*
58 * CFR1 Register (PAGE=0, ADDR=0x01, Reset value=0xA6)
59 * +--------+--------+--------+--------+--------+--------+--------+--------+
60 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
61 * +--------+--------+--------+--------+--------+--------+--------+--------+
62 * | MAV | AVE[2:0] | 0 | SMPL[2:0] |
63 * +--------+--------+--------+--------+--------+--------+--------+--------+
64 * MAV: 0 = median average filter off
65 * 1 = median average filter on (*)
66 * AVE: AVE+1 = number of average samples for MAV,
67 * if AVE>SMPL, then AVE=SMPL (=3)
68 * SMPL: SMPL+1 = number of conversion samples for MAV (=7)
69 */
70#define BU21029_CFR1_REG (0x01 << 3)
71#define CFR1_VALUE 0xA6
72
73/*
74 * CFR2 Register (PAGE=0, ADDR=0x02, Reset value=0x04)
75 * +--------+--------+--------+--------+--------+--------+--------+--------+
76 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
77 * +--------+--------+--------+--------+--------+--------+--------+--------+
78 * | INTVL_TIME[3:0] | TIME_ST_ADC[3:0] |
79 * +--------+--------+--------+--------+--------+--------+--------+--------+
80 * INTVL_TIME: waiting time between completion of conversion
81 * and start of next conversion, only usable in
82 * autoscan mode (=20.480ms)
83 * TIME_ST_ADC: waiting time between application of voltage
84 * to panel and start of A/D conversion (=100us)
85 */
86#define BU21029_CFR2_REG (0x02 << 3)
87#define CFR2_VALUE 0xC9
88
89/*
90 * CFR3 Register (PAGE=0, ADDR=0x0B, Reset value=0x72)
91 * +--------+--------+--------+--------+--------+--------+--------+--------+
92 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
93 * +--------+--------+--------+--------+--------+--------+--------+--------+
94 * | RM8 | STRETCH| PU90K | DUAL | PIDAC_OFS[3:0] |
95 * +--------+--------+--------+--------+--------+--------+--------+--------+
96 * RM8: 0 = coordinate resolution is 12bit (*)
97 * 1 = coordinate resolution is 8bit
98 * STRETCH: 0 = SCL_STRETCH function off
99 * 1 = SCL_STRETCH function on (*)
100 * PU90K: 0 = internal pull-up resistance for touch detection is ~50kohms (*)
101 * 1 = internal pull-up resistance for touch detection is ~90kohms
102 * DUAL: 0 = dual touch detection off (*)
103 * 1 = dual touch detection on
104 * PIDAC_OFS: dual touch detection circuit adjustment, it is not necessary
105 * to change this from initial value
106 */
107#define BU21029_CFR3_REG (0x0B << 3)
108#define CFR3_VALUE 0x42
109
110/*
111 * LDO Register (PAGE=0, ADDR=0x0C, Reset value=0x00)
112 * +--------+--------+--------+--------+--------+--------+--------+--------+
113 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
114 * +--------+--------+--------+--------+--------+--------+--------+--------+
115 * | 0 | PVDD[2:0] | 0 | AVDD[2:0] |
116 * +--------+--------+--------+--------+--------+--------+--------+--------+
117 * PVDD: output voltage of panel output regulator (=2.000V)
118 * AVDD: output voltage of analog circuit regulator (=2.000V)
119 */
120#define BU21029_LDO_REG (0x0C << 3)
121#define LDO_VALUE 0x77
122
123/*
124 * Serial Interface Command Byte 1 (CID=1)
125 * +--------+--------+--------+--------+--------+--------+--------+--------+
126 * | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
127 * +--------+--------+--------+--------+--------+--------+--------+--------+
128 * | 1 | CF | CMSK | PDM | STP |
129 * +--------+--------+--------+--------+--------+--------+--------+--------+
130 * CF: conversion function, see table 3 in datasheet p6 (=0000, automatic scan)
131 * CMSK: 0 = executes convert function (*)
132 * 1 = reads the convert result
133 * PDM: 0 = power down after convert function stops (*)
134 * 1 = keep power on after convert function stops
135 * STP: 1 = abort current conversion and power down, set to "0" automatically
136 */
137#define BU21029_AUTOSCAN 0x80
138
139/*
140 * The timeout value needs to be larger than INTVL_TIME + tConv4 (sample and
141 * conversion time), where tConv4 is calculated by formula:
142 * tPON + tDLY1 + (tTIME_ST_ADC + (tADC * tSMPL) * 2 + tDLY2) * 3
143 * see figure 8 in datasheet p15 for details of each field.
144 */
145#define PEN_UP_TIMEOUT_MS 50
146
147#define STOP_DELAY_MIN_US 50
148#define STOP_DELAY_MAX_US 1000
149#define START_DELAY_MS 2
150#define BUF_LEN 8
151#define SCALE_12BIT (1 << 12)
152#define MAX_12BIT ((1 << 12) - 1)
153#define DRIVER_NAME "bu21029"
154
155struct bu21029_ts_data {
156 struct i2c_client *client;
157 struct input_dev *in_dev;
158 struct timer_list timer;
159 struct regulator *vdd;
160 struct gpio_desc *reset_gpios;
161 u32 x_plate_ohms;
162 struct touchscreen_properties prop;
163};
164
165static void bu21029_touch_report(struct bu21029_ts_data *bu21029, const u8 *buf)
166{
167 u16 x, y, z1, z2;
168 u32 rz;
169 s32 max_pressure = input_abs_get_max(bu21029->in_dev, ABS_PRESSURE);
170
171 /*
172 * compose upper 8 and lower 4 bits into a 12bit value:
173 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
174 * | ByteH | ByteL |
175 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
176 * |b07|b06|b05|b04|b03|b02|b01|b00|b07|b06|b05|b04|b03|b02|b01|b00|
177 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
178 * |v11|v10|v09|v08|v07|v06|v05|v04|v03|v02|v01|v00| 0 | 0 | 0 | 0 |
179 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
180 */
181 x = (buf[0] << 4) | (buf[1] >> 4);
182 y = (buf[2] << 4) | (buf[3] >> 4);
183 z1 = (buf[4] << 4) | (buf[5] >> 4);
184 z2 = (buf[6] << 4) | (buf[7] >> 4);
185
186 if (z1 && z2) {
187 /*
188 * calculate Rz (pressure resistance value) by equation:
189 * Rz = Rx * (x/Q) * ((z2/z1) - 1), where
190 * Rx is x-plate resistance,
191 * Q is the touch screen resolution (8bit = 256, 12bit = 4096)
192 * x, z1, z2 are the measured positions.
193 */
194 rz = z2 - z1;
195 rz *= x;
196 rz *= bu21029->x_plate_ohms;
197 rz /= z1;
198 rz = DIV_ROUND_CLOSEST(rz, SCALE_12BIT);
199 if (rz <= max_pressure) {
200 touchscreen_report_pos(bu21029->in_dev, &bu21029->prop,
201 x, y, false);
202 input_report_abs(bu21029->in_dev, ABS_PRESSURE,
203 max_pressure - rz);
204 input_report_key(bu21029->in_dev, BTN_TOUCH, 1);
205 input_sync(bu21029->in_dev);
206 }
207 }
208}
209
210static void bu21029_touch_release(struct timer_list *t)
211{
212 struct bu21029_ts_data *bu21029 = from_timer(bu21029, t, timer);
213
214 input_report_abs(bu21029->in_dev, ABS_PRESSURE, 0);
215 input_report_key(bu21029->in_dev, BTN_TOUCH, 0);
216 input_sync(bu21029->in_dev);
217}
218
219static irqreturn_t bu21029_touch_soft_irq(int irq, void *data)
220{
221 struct bu21029_ts_data *bu21029 = data;
222 u8 buf[BUF_LEN];
223 int error;
224
225 /*
226 * Read touch data and deassert interrupt (will assert again after
227 * INTVL_TIME + tConv4 for continuous touch)
228 */
229 error = i2c_smbus_read_i2c_block_data(bu21029->client, BU21029_AUTOSCAN,
230 sizeof(buf), buf);
231 if (error < 0)
232 goto out;
233
234 bu21029_touch_report(bu21029, buf);
235
236 /* reset timer for pen up detection */
237 mod_timer(&bu21029->timer,
238 jiffies + msecs_to_jiffies(PEN_UP_TIMEOUT_MS));
239
240out:
241 return IRQ_HANDLED;
242}
243
244static void bu21029_put_chip_in_reset(struct bu21029_ts_data *bu21029)
245{
246 if (bu21029->reset_gpios) {
247 gpiod_set_value_cansleep(bu21029->reset_gpios, 1);
248 usleep_range(STOP_DELAY_MIN_US, STOP_DELAY_MAX_US);
249 }
250}
251
252static int bu21029_start_chip(struct input_dev *dev)
253{
254 struct bu21029_ts_data *bu21029 = input_get_drvdata(dev);
255 struct i2c_client *i2c = bu21029->client;
256 struct {
257 u8 reg;
258 u8 value;
259 } init_table[] = {
260 {BU21029_CFR0_REG, CFR0_VALUE},
261 {BU21029_CFR1_REG, CFR1_VALUE},
262 {BU21029_CFR2_REG, CFR2_VALUE},
263 {BU21029_CFR3_REG, CFR3_VALUE},
264 {BU21029_LDO_REG, LDO_VALUE}
265 };
266 int error, i;
267 __be16 hwid;
268
269 error = regulator_enable(bu21029->vdd);
270 if (error) {
271 dev_err(&i2c->dev, "failed to power up chip: %d", error);
272 return error;
273 }
274
275 /* take chip out of reset */
276 if (bu21029->reset_gpios) {
277 gpiod_set_value_cansleep(bu21029->reset_gpios, 0);
278 msleep(START_DELAY_MS);
279 }
280
281 error = i2c_smbus_read_i2c_block_data(i2c, BU21029_HWID_REG,
282 sizeof(hwid), (u8 *)&hwid);
283 if (error < 0) {
284 dev_err(&i2c->dev, "failed to read HW ID\n");
285 goto err_out;
286 }
287
288 if (be16_to_cpu(hwid) != SUPPORTED_HWID) {
289 dev_err(&i2c->dev,
290 "unsupported HW ID 0x%x\n", be16_to_cpu(hwid));
291 error = -ENODEV;
292 goto err_out;
293 }
294
295 for (i = 0; i < ARRAY_SIZE(init_table); ++i) {
296 error = i2c_smbus_write_byte_data(i2c,
297 init_table[i].reg,
298 init_table[i].value);
299 if (error < 0) {
300 dev_err(&i2c->dev,
301 "failed to write %#02x to register %#02x: %d\n",
302 init_table[i].value, init_table[i].reg,
303 error);
304 goto err_out;
305 }
306 }
307
308 error = i2c_smbus_write_byte(i2c, BU21029_AUTOSCAN);
309 if (error < 0) {
310 dev_err(&i2c->dev, "failed to start autoscan\n");
311 goto err_out;
312 }
313
314 enable_irq(bu21029->client->irq);
315 return 0;
316
317err_out:
318 bu21029_put_chip_in_reset(bu21029);
319 regulator_disable(bu21029->vdd);
320 return error;
321}
322
323static void bu21029_stop_chip(struct input_dev *dev)
324{
325 struct bu21029_ts_data *bu21029 = input_get_drvdata(dev);
326
327 disable_irq(bu21029->client->irq);
328 del_timer_sync(&bu21029->timer);
329
330 bu21029_put_chip_in_reset(bu21029);
331 regulator_disable(bu21029->vdd);
332}
333
334static int bu21029_probe(struct i2c_client *client,
335 const struct i2c_device_id *id)
336{
337 struct bu21029_ts_data *bu21029;
338 struct input_dev *in_dev;
339 int error;
340
341 if (!i2c_check_functionality(client->adapter,
342 I2C_FUNC_SMBUS_WRITE_BYTE |
343 I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
344 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
345 dev_err(&client->dev,
346 "i2c functionality support is not sufficient\n");
347 return -EIO;
348 }
349
350 bu21029 = devm_kzalloc(&client->dev, sizeof(*bu21029), GFP_KERNEL);
351 if (!bu21029)
352 return -ENOMEM;
353
354 error = device_property_read_u32(&client->dev, "rohm,x-plate-ohms",
355 &bu21029->x_plate_ohms);
356 if (error) {
357 dev_err(&client->dev,
358 "invalid 'x-plate-ohms' supplied: %d\n", error);
359 return error;
360 }
361
362 bu21029->vdd = devm_regulator_get(&client->dev, "vdd");
363 if (IS_ERR(bu21029->vdd)) {
364 error = PTR_ERR(bu21029->vdd);
365 if (error != -EPROBE_DEFER)
366 dev_err(&client->dev,
367 "failed to acquire 'vdd' supply: %d\n", error);
368 return error;
369 }
370
371 bu21029->reset_gpios = devm_gpiod_get_optional(&client->dev,
372 "reset", GPIOD_OUT_HIGH);
373 if (IS_ERR(bu21029->reset_gpios)) {
374 error = PTR_ERR(bu21029->reset_gpios);
375 if (error != -EPROBE_DEFER)
376 dev_err(&client->dev,
377 "failed to acquire 'reset' gpio: %d\n", error);
378 return error;
379 }
380
381 in_dev = devm_input_allocate_device(&client->dev);
382 if (!in_dev) {
383 dev_err(&client->dev, "unable to allocate input device\n");
384 return -ENOMEM;
385 }
386
387 bu21029->client = client;
388 bu21029->in_dev = in_dev;
389 timer_setup(&bu21029->timer, bu21029_touch_release, 0);
390
391 in_dev->name = DRIVER_NAME;
392 in_dev->id.bustype = BUS_I2C;
393 in_dev->open = bu21029_start_chip;
394 in_dev->close = bu21029_stop_chip;
395
396 input_set_capability(in_dev, EV_KEY, BTN_TOUCH);
397 input_set_abs_params(in_dev, ABS_X, 0, MAX_12BIT, 0, 0);
398 input_set_abs_params(in_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
399 input_set_abs_params(in_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0);
400 touchscreen_parse_properties(in_dev, false, &bu21029->prop);
401
402 input_set_drvdata(in_dev, bu21029);
403
404 irq_set_status_flags(client->irq, IRQ_NOAUTOEN);
405 error = devm_request_threaded_irq(&client->dev, client->irq,
406 NULL, bu21029_touch_soft_irq,
407 IRQF_ONESHOT, DRIVER_NAME, bu21029);
408 if (error) {
409 dev_err(&client->dev,
410 "unable to request touch irq: %d\n", error);
411 return error;
412 }
413
414 error = input_register_device(in_dev);
415 if (error) {
416 dev_err(&client->dev,
417 "unable to register input device: %d\n", error);
418 return error;
419 }
420
421 i2c_set_clientdata(client, bu21029);
422
423 return 0;
424}
425
426static int __maybe_unused bu21029_suspend(struct device *dev)
427{
428 struct i2c_client *i2c = to_i2c_client(dev);
429 struct bu21029_ts_data *bu21029 = i2c_get_clientdata(i2c);
430
431 if (!device_may_wakeup(dev)) {
432 mutex_lock(&bu21029->in_dev->mutex);
433 if (bu21029->in_dev->users)
434 bu21029_stop_chip(bu21029->in_dev);
435 mutex_unlock(&bu21029->in_dev->mutex);
436 }
437
438 return 0;
439}
440
441static int __maybe_unused bu21029_resume(struct device *dev)
442{
443 struct i2c_client *i2c = to_i2c_client(dev);
444 struct bu21029_ts_data *bu21029 = i2c_get_clientdata(i2c);
445
446 if (!device_may_wakeup(dev)) {
447 mutex_lock(&bu21029->in_dev->mutex);
448 if (bu21029->in_dev->users)
449 bu21029_start_chip(bu21029->in_dev);
450 mutex_unlock(&bu21029->in_dev->mutex);
451 }
452
453 return 0;
454}
455static SIMPLE_DEV_PM_OPS(bu21029_pm_ops, bu21029_suspend, bu21029_resume);
456
457static const struct i2c_device_id bu21029_ids[] = {
458 { DRIVER_NAME, 0 },
459 { /* sentinel */ }
460};
461MODULE_DEVICE_TABLE(i2c, bu21029_ids);
462
463#ifdef CONFIG_OF
464static const struct of_device_id bu21029_of_ids[] = {
465 { .compatible = "rohm,bu21029" },
466 { /* sentinel */ }
467};
468MODULE_DEVICE_TABLE(of, bu21029_of_ids);
469#endif
470
471static struct i2c_driver bu21029_driver = {
472 .driver = {
473 .name = DRIVER_NAME,
474 .of_match_table = of_match_ptr(bu21029_of_ids),
475 .pm = &bu21029_pm_ops,
476 },
477 .id_table = bu21029_ids,
478 .probe = bu21029_probe,
479};
480module_i2c_driver(bu21029_driver);
481
482MODULE_AUTHOR("Zhu Yi <yi.zhu5@cn.bosch.com>");
483MODULE_DESCRIPTION("Rohm BU21029 touchscreen controller driver");
484MODULE_LICENSE("GPL v2");
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 2facad75eb6d..7fe41965c5d1 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * Touch Screen driver for EETI's I2C connected touch screen panels 2 * Touch Screen driver for EETI's I2C connected touch screen panels
3 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> 3 * Copyright (c) 2009,2018 Daniel Mack <daniel@zonque.org>
4 * 4 *
5 * See EETI's software guide for the protocol specification: 5 * See EETI's software guide for the protocol specification:
6 * http://home.eeti.com.tw/web20/eg/guide.htm 6 * http://home.eeti.com.tw/documentation.html
7 * 7 *
8 * Based on migor_ts.c 8 * Based on migor_ts.c
9 * Copyright (c) 2008 Magnus Damm 9 * Copyright (c) 2008 Magnus Damm
@@ -25,28 +25,22 @@
25 */ 25 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/moduleparam.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
30#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/input/touchscreen.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/gpio/consumer.h> 34#include <linux/gpio/consumer.h>
35#include <linux/of.h>
35#include <linux/slab.h> 36#include <linux/slab.h>
36#include <asm/unaligned.h> 37#include <asm/unaligned.h>
37 38
38static bool flip_x;
39module_param(flip_x, bool, 0644);
40MODULE_PARM_DESC(flip_x, "flip x coordinate");
41
42static bool flip_y;
43module_param(flip_y, bool, 0644);
44MODULE_PARM_DESC(flip_y, "flip y coordinate");
45
46struct eeti_ts { 39struct eeti_ts {
47 struct i2c_client *client; 40 struct i2c_client *client;
48 struct input_dev *input; 41 struct input_dev *input;
49 struct gpio_desc *attn_gpio; 42 struct gpio_desc *attn_gpio;
43 struct touchscreen_properties props;
50 bool running; 44 bool running;
51}; 45};
52 46
@@ -73,17 +67,10 @@ static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf)
73 x >>= res - EETI_TS_BITDEPTH; 67 x >>= res - EETI_TS_BITDEPTH;
74 y >>= res - EETI_TS_BITDEPTH; 68 y >>= res - EETI_TS_BITDEPTH;
75 69
76 if (flip_x)
77 x = EETI_MAXVAL - x;
78
79 if (flip_y)
80 y = EETI_MAXVAL - y;
81
82 if (buf[0] & REPORT_BIT_HAS_PRESSURE) 70 if (buf[0] & REPORT_BIT_HAS_PRESSURE)
83 input_report_abs(eeti->input, ABS_PRESSURE, buf[5]); 71 input_report_abs(eeti->input, ABS_PRESSURE, buf[5]);
84 72
85 input_report_abs(eeti->input, ABS_X, x); 73 touchscreen_report_pos(eeti->input, &eeti->props, x, y, false);
86 input_report_abs(eeti->input, ABS_Y, y);
87 input_report_key(eeti->input, BTN_TOUCH, buf[0] & REPORT_BIT_PRESSED); 74 input_report_key(eeti->input, BTN_TOUCH, buf[0] & REPORT_BIT_PRESSED);
88 input_sync(eeti->input); 75 input_sync(eeti->input);
89} 76}
@@ -178,6 +165,8 @@ static int eeti_ts_probe(struct i2c_client *client,
178 input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0); 165 input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0);
179 input_set_abs_params(input, ABS_PRESSURE, 0, 0xff, 0, 0); 166 input_set_abs_params(input, ABS_PRESSURE, 0, 0xff, 0, 0);
180 167
168 touchscreen_parse_properties(input, false, &eeti->props);
169
181 input->name = client->name; 170 input->name = client->name;
182 input->id.bustype = BUS_I2C; 171 input->id.bustype = BUS_I2C;
183 input->open = eeti_ts_open; 172 input->open = eeti_ts_open;
@@ -262,10 +251,18 @@ static const struct i2c_device_id eeti_ts_id[] = {
262}; 251};
263MODULE_DEVICE_TABLE(i2c, eeti_ts_id); 252MODULE_DEVICE_TABLE(i2c, eeti_ts_id);
264 253
254#ifdef CONFIG_OF
255static const struct of_device_id of_eeti_ts_match[] = {
256 { .compatible = "eeti,exc3000-i2c", },
257 { }
258};
259#endif
260
265static struct i2c_driver eeti_ts_driver = { 261static struct i2c_driver eeti_ts_driver = {
266 .driver = { 262 .driver = {
267 .name = "eeti_ts", 263 .name = "eeti_ts",
268 .pm = &eeti_ts_pm, 264 .pm = &eeti_ts_pm,
265 .of_match_table = of_match_ptr(of_eeti_ts_match),
269 }, 266 },
270 .probe = eeti_ts_probe, 267 .probe = eeti_ts_probe,
271 .id_table = eeti_ts_id, 268 .id_table = eeti_ts_id,
@@ -274,5 +271,5 @@ static struct i2c_driver eeti_ts_driver = {
274module_i2c_driver(eeti_ts_driver); 271module_i2c_driver(eeti_ts_driver);
275 272
276MODULE_DESCRIPTION("EETI Touchscreen driver"); 273MODULE_DESCRIPTION("EETI Touchscreen driver");
277MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 274MODULE_AUTHOR("Daniel Mack <daniel@zonque.org>");
278MODULE_LICENSE("GPL"); 275MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 752ae9cf4514..80e69bb8283e 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver for EETI eGalax Multiple Touch Controller 3 * Driver for EETI eGalax Multiple Touch Controller
3 * 4 *
4 * Copyright (C) 2011 Freescale Semiconductor, Inc. 5 * Copyright (C) 2011 Freescale Semiconductor, Inc.
5 * 6 *
6 * based on max11801_ts.c 7 * based on max11801_ts.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13/* EETI eGalax serial touch screen controller is a I2C based multiple 10/* EETI eGalax serial touch screen controller is a I2C based multiple
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 83433e8efff7..7f2942f3cec6 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -352,6 +352,7 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
352 352
353 case 1: /* 6-byte protocol */ 353 case 1: /* 6-byte protocol */
354 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); 354 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0);
355 /* fall through */
355 356
356 case 2: /* 4-byte protocol */ 357 case 2: /* 4-byte protocol */
357 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); 358 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c
index 47fe1f184bbc..1d6c8f490b40 100644
--- a/drivers/input/touchscreen/fsl-imx25-tcq.c
+++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
@@ -1,16 +1,11 @@
1/* 1// SPDX-License-Identifier: GPL-2.0
2 * Copyright (C) 2014-2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de> 2//
3 * 3// Copyright (C) 2014-2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
4 * This program is free software; you can redistribute it and/or modify it under 4// Based on driver from 2011:
5 * the terms of the GNU General Public License version 2 as published by the 5// Juergen Beisert, Pengutronix <kernel@pengutronix.de>
6 * Free Software Foundation. 6//
7 * 7// This is the driver for the imx25 TCQ (Touchscreen Conversion Queue)
8 * Based on driver from 2011: 8// connected to the imx25 ADC.
9 * Juergen Beisert, Pengutronix <kernel@pengutronix.de>
10 *
11 * This is the driver for the imx25 TCQ (Touchscreen Conversion Queue)
12 * connected to the imx25 ADC.
13 */
14 9
15#include <linux/clk.h> 10#include <linux/clk.h>
16#include <linux/device.h> 11#include <linux/device.h>
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
index 481586909d28..054c2537b392 100644
--- a/drivers/input/touchscreen/gunze.c
+++ b/drivers/input/touchscreen/gunze.c
@@ -20,10 +20,6 @@
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
27 */ 23 */
28 24
29#include <linux/errno.h> 25#include <linux/errno.h>
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index ee82a975bfd2..c10fc594f94d 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -1,12 +1,8 @@
1/* 1// SPDX-License-Identifier: GPL-2.0
2 * Freescale i.MX6UL touchscreen controller driver 2//
3 * 3// Freescale i.MX6UL touchscreen controller driver
4 * Copyright (C) 2015 Freescale Semiconductor, Inc. 4//
5 * 5// Copyright (C) 2015 Freescale Semiconductor, Inc.
6 * 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
8 * published by the Free Software Foundation.
9 */
10 6
11#include <linux/errno.h> 7#include <linux/errno.h>
12#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index d1c09e6a2cb6..c89853a36f9e 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -466,7 +466,7 @@ static bool raydium_i2c_boot_trigger(struct i2c_client *client)
466 } 466 }
467 } 467 }
468 468
469 return 0; 469 return false;
470} 470}
471 471
472static bool raydium_i2c_fw_trigger(struct i2c_client *client) 472static bool raydium_i2c_fw_trigger(struct i2c_client *client)
@@ -492,7 +492,7 @@ static bool raydium_i2c_fw_trigger(struct i2c_client *client)
492 } 492 }
493 } 493 }
494 494
495 return 0; 495 return false;
496} 496}
497 497
498static int raydium_i2c_check_path(struct i2c_client *client) 498static int raydium_i2c_check_path(struct i2c_client *client)
diff --git a/drivers/input/touchscreen/wdt87xx_i2c.c b/drivers/input/touchscreen/wdt87xx_i2c.c
index 20f7f3902757..166edeb77776 100644
--- a/drivers/input/touchscreen/wdt87xx_i2c.c
+++ b/drivers/input/touchscreen/wdt87xx_i2c.c
@@ -1142,7 +1142,7 @@ static int __maybe_unused wdt87xx_resume(struct device *dev)
1142 * The chip may have been reset while system is resuming, 1142 * The chip may have been reset while system is resuming,
1143 * give it some time to settle. 1143 * give it some time to settle.
1144 */ 1144 */
1145 mdelay(100); 1145 msleep(100);
1146 1146
1147 error = wdt87xx_send_command(client, VND_CMD_START, 0); 1147 error = wdt87xx_send_command(client, VND_CMD_START, 0);
1148 if (error) 1148 if (error)