Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] i2c-hid: remove mostly useless parameter 'debug'
From: Andy Shevchenko @ 2013-08-07 15:21 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Benjamin Tissoires, linux-input, Jiri Kosina, Mika Westerberg
In-Reply-To: <51FBF71E.1040802@redhat.com>

On Fri, 2013-08-02 at 20:14 +0200, Benjamin Tissoires wrote: 
> On 02/08/13 16:49, Andy Shevchenko wrote:

> > Usually when I see such code I understood it was written in
> > pre-dynamic-debug epoch. So, my point is to switch to dynamic debug and
> > use it efficiently.
> 
> Ok, so if you can guarantee me that adding the proper kernel parameter
> will allow me to retrieve all the i2c-hid logs from the boot, then I'd
> be happy to ack this. However, I have no way to test this right now, so
> I'll need to trust you (that's why I'm asking you to do proper testing).

Just to your information, I noticed that Greg KH did something like I
propose for usb drivers (misc, serial, ...).

So, it would be considered as third party opinion, I guess.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply

* RE: List corruption in hidraw_release in 3.11-rc4
From: Manoj Chourasia @ 2013-08-07 15:06 UTC (permalink / raw)
  To: Jiri Kosina, Peter Wu
  Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	alnovak@suse.cz
In-Reply-To: <alpine.LNX.2.00.1308071533130.10425@pobox.suse.cz>

Hi Peter,

The patch I posted was solving slab memory corruption issue which was occurring because of the race in device disconnect and device release. We found the some of the device data structure being used after free. Later we figure out the patch which was reverted earlier was solving our issue but there was still some slab memory corruption.  That was due to reason that list delete of the device was called after freeing the hidraw. I protect drop_ref by mutex lock and also delete the list before calling drop_ref that solve the issue. If you are seeing memory corruption then the patch could solve your issue.

Regards
-Manoj

-----Original Message-----
From: Jiri Kosina [mailto:jkosina@suse.cz] 
Sent: Wednesday, August 07, 2013 7:04 PM
To: Peter Wu
Cc: linux-input@vger.kernel.org; Manoj Chourasia; linux-kernel@vger.kernel.org; alnovak@suse.cz
Subject: Re: List corruption in hidraw_release in 3.11-rc4

On Wed, 7 Aug 2013, Peter Wu wrote:

> > does the patch below fix the problem you are seeing?
> That one is already in 3.11-rc4 as far as I can see. Also, that code 
> can probably simplified by moving the mutex_unlock after the out 
> label, removing the need to duplicate the mutex_unlock.
> 
> Remember what I said about "no Oopses"? Well, it turned out that 
> several memory structures were damaged which causes a general 
> protection fault in sock_alloc_inode and other places.
> 
> I managed to create a program that can reproduce this bug 100% in a 
> QEMU virtual machine with a Logitech USB receiver passed to it.
> 
> qemu-system-x86_64 -enable-kvm -m 1G -usb -usbdevice host:046d:c52b 
> (pass -kernel, -initrd, -append as needed)
> 
> Copy hidraw-test to initrd, boot QEMU and run `hidraw-test`. Result: 
> instant (= +/- 2 seconds) crash.
> 
> I have applied Manoj's patch[1] on top of 3.11-rc4 which seem to fix the issue. 
> One observation is that the new device is named /dev/hidraw1 instead 
> of /dev/hidraw0. Example:
> 
> f(){ hidraw-test /dev/hidraw$1 usb1;}
> # needed for 3.11-rc4
> f 1; f 1 # crash
> # needed for 3.11-rc4 + patch
> f 1; f 2 # ok
> 
> Regards,
> Peter
> 
>  [1]: http://lkml.org/lkml/2013/7/22/248

That one I am still reviewing ... can I add your Tested-by: to it when I'll be applying it and pushing to Linus?

Thanks.

> --
> /* cc hidraw-test.c -o hidraw-test
>  * hidraw-test /dev/hidraw0 usb1; hidraw-test /dev/hidraw0 usb1;  */ 
> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include 
> <errno.h> #include <string.h> #include <stdlib.h>
> 
> int open_and_write(const char *path, const char *data) {
> 	int sfd, r;
> 
> 	sfd = open(path, O_WRONLY);
> 	if (sfd < 0) {
> 		perror(path);
> 		return 1;
> 	}
> 
> 	r = write(sfd, data, strlen(data));
> 	if (r < 0) {
> 		fprintf(stderr, "write(%s, %s): %s\n",
> 			path, data, strerror(errno));
> 		return 1;
> 	}
> 	close(sfd);
> 	return 0;
> }
> 
> int dork(const char *hiddev, const char *name) {
> 	int fd;
> 	char c;
> 
> 	fd = open(hiddev, O_RDWR | O_NONBLOCK);
> 	if (fd < 0) {
> 		perror("open");
> 		return 1;
> 	}
> 
> 	if (open_and_write("/sys/bus/usb/drivers/usb/unbind", name))
> 		return 1;
> 
> 	// does not make a difference
> 	//sleep(1);
> 
> 	if (open_and_write("/sys/bus/usb/drivers/usb/bind", name))
> 		return 1;
> 
> 	// allow devices to get discovered
> 	sleep(1);
> 
> 	printf("read() = %zi\n", read(fd, &c, 1)); perror("read");
> 	close(fd);
> 	return 0;
> }
> 
> int main(int argc, char **argv) {
> 	if (argc < 3) {
> 		fprintf(stderr, "Usage: %s /dev/hidrawN usbN\n", *argv);
> 		return 1;
> 	}
> 
> 	system("modprobe -v usbhid");
> 	system("modprobe -v hid-logitech-dj");
> 
> 	dork(argv[1], argv[2]);
> 
> 	return 0;
> }
> 

--
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: List corruption in hidraw_release in 3.11-rc4
From: Jiri Kosina @ 2013-08-07 13:34 UTC (permalink / raw)
  To: Peter Wu; +Cc: linux-input, Manoj Chourasia, linux-kernel, alnovak
In-Reply-To: <6207700.eHyYqS01s0@al>

On Wed, 7 Aug 2013, Peter Wu wrote:

> > does the patch below fix the problem you are seeing?
> That one is already in 3.11-rc4 as far as I can see. Also, that code can 
> probably simplified by moving the mutex_unlock after the out label, removing 
> the need to duplicate the mutex_unlock.
> 
> Remember what I said about "no Oopses"? Well, it turned out that several 
> memory structures were damaged which causes a general protection fault in 
> sock_alloc_inode and other places.
> 
> I managed to create a program that can reproduce this bug 100% in a QEMU 
> virtual machine with a Logitech USB receiver passed to it.
> 
> qemu-system-x86_64 -enable-kvm -m 1G -usb -usbdevice host:046d:c52b
> (pass -kernel, -initrd, -append as needed)
> 
> Copy hidraw-test to initrd, boot QEMU and run `hidraw-test`. Result: instant
> (= +/- 2 seconds) crash.
> 
> I have applied Manoj's patch[1] on top of 3.11-rc4 which seem to fix the issue. 
> One observation is that the new device is named /dev/hidraw1 instead of 
> /dev/hidraw0. Example:
> 
> f(){ hidraw-test /dev/hidraw$1 usb1;}
> # needed for 3.11-rc4
> f 1; f 1 # crash
> # needed for 3.11-rc4 + patch
> f 1; f 2 # ok
> 
> Regards,
> Peter
> 
>  [1]: http://lkml.org/lkml/2013/7/22/248

That one I am still reviewing ... can I add your Tested-by: to it when 
I'll be applying it and pushing to Linus?

Thanks.

> --
> /* cc hidraw-test.c -o hidraw-test
>  * hidraw-test /dev/hidraw0 usb1; hidraw-test /dev/hidraw0 usb1;
>  */
> #include <unistd.h>
> #include <fcntl.h>
> #include <stdio.h>
> #include <errno.h>
> #include <string.h>
> #include <stdlib.h>
> 
> int open_and_write(const char *path, const char *data) {
> 	int sfd, r;
> 
> 	sfd = open(path, O_WRONLY);
> 	if (sfd < 0) {
> 		perror(path);
> 		return 1;
> 	}
> 
> 	r = write(sfd, data, strlen(data));
> 	if (r < 0) {
> 		fprintf(stderr, "write(%s, %s): %s\n",
> 			path, data, strerror(errno));
> 		return 1;
> 	}
> 	close(sfd);
> 	return 0;
> }
> 
> int dork(const char *hiddev, const char *name) {
> 	int fd;
> 	char c;
> 
> 	fd = open(hiddev, O_RDWR | O_NONBLOCK);
> 	if (fd < 0) {
> 		perror("open");
> 		return 1;
> 	}
> 
> 	if (open_and_write("/sys/bus/usb/drivers/usb/unbind", name))
> 		return 1;
> 
> 	// does not make a difference
> 	//sleep(1);
> 
> 	if (open_and_write("/sys/bus/usb/drivers/usb/bind", name))
> 		return 1;
> 
> 	// allow devices to get discovered
> 	sleep(1);
> 
> 	printf("read() = %zi\n", read(fd, &c, 1)); perror("read");
> 	close(fd);
> 	return 0;
> }
> 
> int main(int argc, char **argv) {
> 	if (argc < 3) {
> 		fprintf(stderr, "Usage: %s /dev/hidrawN usbN\n", *argv);
> 		return 1;
> 	}
> 
> 	system("modprobe -v usbhid");
> 	system("modprobe -v hid-logitech-dj");
> 
> 	dork(argv[1], argv[2]);
> 
> 	return 0;
> }
> 

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: List corruption in hidraw_release in 3.11-rc4
From: Peter Wu @ 2013-08-07 13:30 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, Manoj Chourasia, linux-kernel, alnovak
In-Reply-To: <alpine.LNX.2.00.1308070258480.10817@pobox.suse.cz>

On Wednesday 07 August 2013 03:01:26 Jiri Kosina wrote:
> On Tue, 6 Aug 2013, Peter Wu wrote:
> > While debugging upowerd (with Logitech Unifying receiver via hidraw),
> > I came across this list corruption warning.
> 
> Peter,
> 
> does the patch below fix the problem you are seeing?
That one is already in 3.11-rc4 as far as I can see. Also, that code can 
probably simplified by moving the mutex_unlock after the out label, removing 
the need to duplicate the mutex_unlock.

Remember what I said about "no Oopses"? Well, it turned out that several 
memory structures were damaged which causes a general protection fault in 
sock_alloc_inode and other places.

I managed to create a program that can reproduce this bug 100% in a QEMU 
virtual machine with a Logitech USB receiver passed to it.

qemu-system-x86_64 -enable-kvm -m 1G -usb -usbdevice host:046d:c52b
(pass -kernel, -initrd, -append as needed)

Copy hidraw-test to initrd, boot QEMU and run `hidraw-test`. Result: instant
(= +/- 2 seconds) crash.

I have applied Manoj's patch[1] on top of 3.11-rc4 which seem to fix the issue. 
One observation is that the new device is named /dev/hidraw1 instead of 
/dev/hidraw0. Example:

f(){ hidraw-test /dev/hidraw$1 usb1;}
# needed for 3.11-rc4
f 1; f 1 # crash
# needed for 3.11-rc4 + patch
f 1; f 2 # ok

Regards,
Peter

 [1]: http://lkml.org/lkml/2013/7/22/248
--
/* cc hidraw-test.c -o hidraw-test
 * hidraw-test /dev/hidraw0 usb1; hidraw-test /dev/hidraw0 usb1;
 */
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>

int open_and_write(const char *path, const char *data) {
	int sfd, r;

	sfd = open(path, O_WRONLY);
	if (sfd < 0) {
		perror(path);
		return 1;
	}

	r = write(sfd, data, strlen(data));
	if (r < 0) {
		fprintf(stderr, "write(%s, %s): %s\n",
			path, data, strerror(errno));
		return 1;
	}
	close(sfd);
	return 0;
}

int dork(const char *hiddev, const char *name) {
	int fd;
	char c;

	fd = open(hiddev, O_RDWR | O_NONBLOCK);
	if (fd < 0) {
		perror("open");
		return 1;
	}

	if (open_and_write("/sys/bus/usb/drivers/usb/unbind", name))
		return 1;

	// does not make a difference
	//sleep(1);

	if (open_and_write("/sys/bus/usb/drivers/usb/bind", name))
		return 1;

	// allow devices to get discovered
	sleep(1);

	printf("read() = %zi\n", read(fd, &c, 1)); perror("read");
	close(fd);
	return 0;
}

int main(int argc, char **argv) {
	if (argc < 3) {
		fprintf(stderr, "Usage: %s /dev/hidrawN usbN\n", *argv);
		return 1;
	}

	system("modprobe -v usbhid");
	system("modprobe -v hid-logitech-dj");

	dork(argv[1], argv[2]);

	return 0;
}

^ permalink raw reply

* [PATCH v2 1/1] input: ideapad_slidebar: new input driver
From: Andrey Moiseev @ 2013-08-07 11:44 UTC (permalink / raw)
  To: linux-input
  Cc: dmitry.torokhov, arnoques, russianneuromancer, ike.pan,
	linux-kernel

v2: added myself as a maintainer

Sorry for previous bad-wrapped email.

ideapad_slidebar is a new driver which enables slidebars on some
Lenovo IdeaPad laptops (the slidebars work with SlideNav/Desktop
Navigator under Windows)

Fixes this: https://bugzilla.kernel.org/show_bug.cgi?id=16004

Registers 'IdeaPad Slidebar' input device and
/sys/devices/platform/ideapad_slidebar/slidebar_mode
for switching slidebar's modes.

Now works on:
IdeaPad Y550, Y550P.

May work on (testing and adding new models is needed):
Ideapad Y560, Y460, Y450, Y650,
and, probably, some others.

Driver source: https://github.com/o2genum/ideapad-slidebar.git

Patch is generated against current version of the mainline kernel.

Signed-off-by: Andrey Moiseev <o2g.org.ru@gmail.com>
---
 MAINTAINERS                           |   7 +
 drivers/input/misc/Kconfig            |   9 +
 drivers/input/misc/Makefile           |   1 +
 drivers/input/misc/ideapad_slidebar.c | 378 ++++++++++++++++++++++++++++++++++
 4 files changed, 395 insertions(+)
 create mode 100644 drivers/input/misc/ideapad_slidebar.c

diff --git a/MAINTAINERS b/MAINTAINERS
index defc053..2ff3dd8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4096,6 +4096,13 @@ W:	http://launchpad.net/ideapad-laptop
 S:	Maintained
 F:	drivers/platform/x86/ideapad-laptop.c
 
+IDEAPAD LAPTOP SLIDEBAR DRIVER
+M:	Andrey Moiseev <o2g.org.ru@gmail.com>
+L:	linux-input@vger.kernel.org
+W:	https://github.com/o2genum/ideapad-slidebar
+S:	Maintained
+F:	drivers/input/misc/ideapad_slidebar.c
+
 IDE/ATAPI DRIVERS
 M:	Borislav Petkov <bp@alien8.de>
 L:	linux-ide@vger.kernel.org
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 0b541cd..45729a9 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -647,4 +647,13 @@ config INPUT_SIRFSOC_ONKEY
 
 	  If unsure, say N.
 
+config INPUT_IDEAPAD_SLIDEBAR
+	tristate "IdeaPad Laptop Slidebar"
+	depends on INPUT
+	help
+	  Input driver for slidebars on some Lenovo IdeaPad laptops.
+
+	  If you have an IdeaPad laptop with a slidebar, say Y or M here.
+	  Module name is ideapad_slidebar.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 829de43..0ebfb6d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -61,3 +61,4 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
+obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
diff --git a/drivers/input/misc/ideapad_slidebar.c b/drivers/input/misc/ideapad_slidebar.c
new file mode 100644
index 0000000..78294fd
--- /dev/null
+++ b/drivers/input/misc/ideapad_slidebar.c
@@ -0,0 +1,378 @@
+/*
+ * Input driver for slidebars on some Lenovo IdeaPad laptops
+ *
+ * Copyright (C) 2013 Andrey Moiseev <o2g.org.ru@gmail.com>
+ *
+ * Reverse-engineered from Lenovo SlideNav software (SBarHook.dll).
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+/* Currently tested and works on:
+ *	Lenovo IdeaPad Y550
+ *	Lenovo IdeaPad Y550P
+ *
+ * Other models can be added easily. To test,
+ * load with 'force' parameter set 'true'.
+ *
+ * LEDs blinking and input mode are managed via sysfs,
+ * (hex, unsigned byte value):
+ * /sys/devices/platform/ideapad_slidebar/slidebar_mode
+ *
+ * The value is in byte range, however, I only figured out
+ * how bits 0b10011001 work. Some other bits, probably,
+ * are meaningfull too.
+ *
+ * Possible states:
+ *
+ * STD_INT, ONMOV_INT, OFF_INT, LAST_POLL, OFF_POLL
+ *
+ * Meaning:
+ *           released      touched
+ * STD       'heartbeat'   lights follow the finger
+ * ONMOV     no lights     lights follow the finger
+ * LAST      at last pos   lights follow the finger
+ * OFF       no lights     no lights
+ *
+ * INT       all input events are generated, interrupts are used
+ * POLL      no input events by default, to get them,
+ *	     send 0b10000000 (read below)
+ *
+ * Commands: write
+ *
+ * All      |  0b01001 -> STD_INT
+ * possible |  0b10001 -> ONMOV_INT
+ * states   |  0b01000 -> OFF_INT
+ *
+ *                      |  0b0 -> LAST_POLL
+ * STD_INT or ONMOV_INT |
+ *                      |  0b1 -> STD_INT
+ *
+ *                      |  0b0 -> OFF_POLL
+ * OFF_INT or OFF_POLL  |
+ *                      |  0b1 -> OFF_INT
+ *
+ * Any state |   0b10000000 ->  if the slidebar has updated data,
+ *				produce one input event (last position),
+ *				switch to respective POLL mode
+ *				(like 0x0), if not in POLL mode yet.
+ *
+ * Get current state: read
+ *
+ * masked by 0x11 read value means:
+ *
+ * 0x00   LAST
+ * 0x01   STD
+ * 0x10   OFF
+ * 0x11   ONMOV
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/dmi.h>
+#include <linux/spinlock.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/input.h>
+#include <linux/io.h>
+
+static bool force;
+module_param(force, bool, 0);
+MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
+
+#define KBD_IRQ 1
+
+spinlock_t sio_lock = __SPIN_LOCK_UNLOCKED(sio_lock);
+
+static int prev_scancode;
+static int touched;
+static struct input_dev *slidebar_input_dev;
+static struct platform_device *slidebar_platform_dev;
+
+/* Hardware interacting */
+static int slidebar_pos_get(void)
+{
+	int res;
+	unsigned long flags;
+	spin_lock_irqsave(&sio_lock, flags);
+	outb(0xf4, 0xff29);
+	outb(0xbf, 0xff2a);
+	res = inb(0xff2b);
+	spin_unlock_irqrestore(&sio_lock, flags);
+	return res;
+}
+
+static unsigned char slidebar_mode_get(void)
+{
+	int res;
+	unsigned long flags;
+	spin_lock_irqsave(&sio_lock, flags);
+	outb(0xf7, 0xff29);
+	outb(0x8b, 0xff2a);
+	res = inb(0xff2b);
+	spin_unlock_irqrestore(&sio_lock, flags);
+	return res;
+}
+
+static void slidebar_mode_set(unsigned char mode)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&sio_lock, flags);
+	outb(0xf7, 0xff29);
+	outb(0x8b, 0xff2a);
+	outb(mode, 0xff2b);
+	spin_unlock_irqrestore(&sio_lock, flags);
+}
+
+/* Keyboard handler */
+static irq_handler_t kbd_irq_handler(int irq, void *dev_id,
+					struct pt_regs *regs)
+{
+	/* Scancodes: e03b on move, bb on release */
+	int scancode = inb(0x60);
+	if (scancode == 0xbb) {
+		touched = 0;
+		input_report_key(slidebar_input_dev, BTN_TOUCH, 0);
+		input_sync(slidebar_input_dev);
+	} else if (prev_scancode == 0xe0 && scancode == 0x3b) {
+		if (!touched)
+			input_report_key(slidebar_input_dev, BTN_TOUCH, 1);
+		touched = 1;
+		input_report_abs(slidebar_input_dev, ABS_X, slidebar_pos_get());
+		input_sync(slidebar_input_dev);
+	}
+	prev_scancode = scancode;
+	return (irq_handler_t) IRQ_HANDLED;
+}
+
+/* Input device */
+static int setup_input_dev(void)
+{
+	int err;
+	err = request_irq(KBD_IRQ, (irq_handler_t) kbd_irq_handler, IRQF_SHARED,
+				"ideapad_slidebar", (void *)(kbd_irq_handler));
+	if (err) {
+		pr_err("ideapad_slidebar: Can't allocate irq %d\n", KBD_IRQ);
+		return -EBUSY;
+	}
+
+	slidebar_input_dev = input_allocate_device();
+	if (!slidebar_input_dev) {
+		pr_err("ideapad_slidebar: Not enough memory\n");
+		err = -ENOMEM;
+		goto err_free_irq;
+	}
+
+	slidebar_input_dev->name = "IdeaPad Slidebar";
+	slidebar_input_dev->id.bustype = BUS_HOST;
+	slidebar_input_dev->dev.parent = &slidebar_platform_dev->dev;
+	input_set_capability(slidebar_input_dev, EV_KEY, BTN_TOUCH);
+	input_set_capability(slidebar_input_dev, EV_ABS, ABS_X);
+	input_alloc_absinfo(slidebar_input_dev);
+	input_set_abs_params(slidebar_input_dev, ABS_X, 0, 0xff, 0, 0);
+
+	err = input_register_device(slidebar_input_dev);
+	if (err) {
+		pr_err("ideapad_slidebar: Failed to register device\n");
+		goto err_free_dev;
+	}
+	return 0;
+
+err_free_dev:
+	input_free_device(slidebar_input_dev);
+err_free_irq:
+	free_irq(KBD_IRQ, (void *)(kbd_irq_handler));
+	return err;
+}
+
+static void remove_input_dev(void)
+{
+	free_irq(KBD_IRQ, (void *)(kbd_irq_handler));
+	input_unregister_device(slidebar_input_dev);
+	input_free_device(slidebar_input_dev);
+}
+
+/* Sysfs slidebar_mode interface */
+static ssize_t show_slidebar_mode(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	return sprintf(buf, "%x\n", slidebar_mode_get());
+}
+
+static ssize_t store_slidebar_mode(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	int mode;
+	if (!count)
+		return 0;
+
+	if (sscanf(buf, "%x", &mode) != 1)
+		return -EINVAL;
+
+	slidebar_mode_set(mode);
+	return count;
+}
+
+static DEVICE_ATTR(slidebar_mode, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
+				show_slidebar_mode, store_slidebar_mode);
+
+static struct attribute *ideapad_attributes[] = {
+	&dev_attr_slidebar_mode.attr,
+	NULL
+};
+
+static struct attribute_group ideapad_attribute_group = {
+	.attrs = ideapad_attributes
+};
+
+static int setup_slidebar_mode_dev(void)
+{
+	return sysfs_create_group(&slidebar_platform_dev->dev.kobj,
+				  &ideapad_attribute_group);
+}
+
+static void remove_slidebar_mode_dev(void)
+{
+	return sysfs_remove_group(&slidebar_platform_dev->dev.kobj,
+				  &ideapad_attribute_group);
+}
+
+/* Platform device */
+static int setup_platform_dev(void)
+{
+	int err;
+	slidebar_platform_dev = platform_device_alloc("ideapad_slidebar", -1);
+	if (!slidebar_platform_dev) {
+		pr_err("ideapad_slidebar: Not enough memory\n");
+		return -ENOMEM;
+	}
+
+	err = platform_device_add(slidebar_platform_dev);
+	if (err) {
+		pr_err("ideapad_slidebar: Failed to register plarform device\n");
+		goto err_free_platform_device;
+	}
+	return 0;
+
+err_free_platform_device:
+	platform_device_put(slidebar_platform_dev);
+	return err;
+}
+
+static void remove_platform_dev(void)
+{
+	platform_device_del(slidebar_platform_dev);
+	platform_device_put(slidebar_platform_dev);
+}
+
+/* Platform driver */
+static struct platform_driver slidebar_drv = {
+	.driver = {
+		.name = "ideapad_slidebar",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int register_platform_drv(void)
+{
+	int err;
+	err = platform_driver_register(&slidebar_drv);
+	if (err)
+		pr_err("ideapad_slidebar: Failed to register platform driver\n");
+
+	return err;
+}
+
+static void unregister_platform_drv(void)
+{
+	platform_driver_unregister(&slidebar_drv);
+}
+
+/* DMI */
+static int ideapad_dmi_check(const struct dmi_system_id *id)
+{
+	pr_info("ideapad_slidebar: Laptop model '%s'\n", id->ident);
+	return 1;
+}
+
+static struct dmi_system_id __initdata ideapad_dmi_table[] = {
+	{
+		.ident = "Lenovo IdeaPad Y550",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "20017"),
+			DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Y550")
+		},
+		.callback = ideapad_dmi_check
+	},
+	{
+		.ident = "Lenovo IdeaPad Y550P",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "20035"),
+			DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Y550P")
+		},
+		.callback = ideapad_dmi_check
+	}
+};
+
+/* Init and cleanup */
+static int __init slidebar_init(void)
+{
+	int err;
+
+	if (!force && !dmi_check_system(ideapad_dmi_table))
+		return -ENODEV;
+
+	err = setup_platform_dev();
+	if (err)
+		return err;
+
+	err = register_platform_drv();
+	if (err)
+		goto err_remove_platform_dev;
+
+	err = setup_input_dev();
+	if (err)
+		goto err_unregister_platform_drv;
+	
+	err = setup_slidebar_mode_dev();
+	if (err)
+		goto err_remove_input_dev;
+	return 0;
+
+err_remove_input_dev:
+	remove_input_dev();
+err_unregister_platform_drv:
+	unregister_platform_drv();
+err_remove_platform_dev:
+	remove_platform_dev();
+	return err;
+}
+
+static void __exit slidebar_exit(void)
+{
+	remove_slidebar_mode_dev();
+	remove_input_dev();
+	remove_platform_dev();
+	unregister_platform_drv();
+}
+
+module_init(slidebar_init);
+module_exit(slidebar_exit);
+
+MODULE_AUTHOR("Andrey Moiseev <o2g.org.ru@gmail.com>");
+MODULE_DESCRIPTION("Slidebar input support for some Lenovo IdeaPad laptops");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("0.1");
+
+MODULE_ALIAS("dmi:*:svnLENOVO:pn20017:pvrLenovoIdeaPadY550:*");
+MODULE_ALIAS("dmi:*:svnLENOVO:pn20035:pvrLenovoIdeaPadY550P:*");
-- 
1.8.3.4


^ permalink raw reply related

* [PATCH v2 1/1] input: ideapad_slidebar: new input driver
From: Andrey Moiseev @ 2013-08-07 11:25 UTC (permalink / raw)
  To: linux-input
  Cc: dmitry.torokhov, arnoques, russianneuromancer, ike.pan,
	linux-kernel

v2: added myself as a maintainer

ideapad_slidebar is a new driver which enables slidebars on some
Lenovo IdeaPad laptops (the slidebars work with SlideNav/Desktop
Navigator under Windows)

Fixes this: https://bugzilla.kernel.org/show_bug.cgi?id=16004

Registers 'IdeaPad Slidebar' input device and
/sys/devices/platform/ideapad_slidebar/slidebar_mode
for switching slidebar's modes.

Now works on:
IdeaPad Y550, Y550P.

May work on (testing and adding new models is needed):
Ideapad Y560, Y460, Y450, Y650,
and, probably, some others.

Driver source: https://github.com/o2genum/ideapad-slidebar.git

Patch is generated against current version of the mainline kernel.

Signed-off-by: Andrey Moiseev <o2g.org.ru@gmail.com>
---
  MAINTAINERS                           |   7 +
  drivers/input/misc/Kconfig            |   9 +
  drivers/input/misc/Makefile           |   1 +
  drivers/input/misc/ideapad_slidebar.c | 378 
++++++++++++++++++++++++++++++++++
  4 files changed, 395 insertions(+)
  create mode 100644 drivers/input/misc/ideapad_slidebar.c

diff --git a/MAINTAINERS b/MAINTAINERS
index defc053..2ff3dd8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4096,6 +4096,13 @@ W:    http://launchpad.net/ideapad-laptop
  S:    Maintained
  F:    drivers/platform/x86/ideapad-laptop.c

+IDEAPAD LAPTOP SLIDEBAR DRIVER
+M:    Andrey Moiseev <o2g.org.ru@gmail.com>
+L:    linux-input@vger.kernel.org
+W:    https://github.com/o2genum/ideapad-slidebar
+S:    Maintained
+F:    drivers/input/misc/ideapad_slidebar.c
+
  IDE/ATAPI DRIVERS
  M:    Borislav Petkov <bp@alien8.de>
  L:    linux-ide@vger.kernel.org
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 0b541cd..45729a9 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -647,4 +647,13 @@ config INPUT_SIRFSOC_ONKEY

        If unsure, say N.

+config INPUT_IDEAPAD_SLIDEBAR
+    tristate "IdeaPad Laptop Slidebar"
+    depends on INPUT
+    help
+      Input driver for slidebars on some Lenovo IdeaPad laptops.
+
+      If you have an IdeaPad laptop with a slidebar, say Y or M here.
+      Module name is ideapad_slidebar.
+
  endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 829de43..0ebfb6d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -61,3 +61,4 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)    += wistron_btns.o
  obj-$(CONFIG_INPUT_WM831X_ON)        += wm831x-on.o
  obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)    += xen-kbdfront.o
  obj-$(CONFIG_INPUT_YEALINK)        += yealink.o
+obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)    += ideapad_slidebar.o
diff --git a/drivers/input/misc/ideapad_slidebar.c 
b/drivers/input/misc/ideapad_slidebar.c
new file mode 100644
index 0000000..78294fd
--- /dev/null
+++ b/drivers/input/misc/ideapad_slidebar.c
@@ -0,0 +1,378 @@
+/*
+ * Input driver for slidebars on some Lenovo IdeaPad laptops
+ *
+ * Copyright (C) 2013 Andrey Moiseev <o2g.org.ru@gmail.com>
+ *
+ * Reverse-engineered from Lenovo SlideNav software (SBarHook.dll).
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by 
the Free
+ * Software Foundation; either version 2 of the License, or (at your 
option)
+ * any later version.
+ *
+ * Trademarks are the property of their respective owners.
+ */
+
+/* Currently tested and works on:
+ *    Lenovo IdeaPad Y550
+ *    Lenovo IdeaPad Y550P
+ *
+ * Other models can be added easily. To test,
+ * load with 'force' parameter set 'true'.
+ *
+ * LEDs blinking and input mode are managed via sysfs,
+ * (hex, unsigned byte value):
+ * /sys/devices/platform/ideapad_slidebar/slidebar_mode
+ *
+ * The value is in byte range, however, I only figured out
+ * how bits 0b10011001 work. Some other bits, probably,
+ * are meaningfull too.
+ *
+ * Possible states:
+ *
+ * STD_INT, ONMOV_INT, OFF_INT, LAST_POLL, OFF_POLL
+ *
+ * Meaning:
+ *           released      touched
+ * STD       'heartbeat'   lights follow the finger
+ * ONMOV     no lights     lights follow the finger
+ * LAST      at last pos   lights follow the finger
+ * OFF       no lights     no lights
+ *
+ * INT       all input events are generated, interrupts are used
+ * POLL      no input events by default, to get them,
+ *         send 0b10000000 (read below)
+ *
+ * Commands: write
+ *
+ * All      |  0b01001 -> STD_INT
+ * possible |  0b10001 -> ONMOV_INT
+ * states   |  0b01000 -> OFF_INT
+ *
+ *                      |  0b0 -> LAST_POLL
+ * STD_INT or ONMOV_INT |
+ *                      |  0b1 -> STD_INT
+ *
+ *                      |  0b0 -> OFF_POLL
+ * OFF_INT or OFF_POLL  |
+ *                      |  0b1 -> OFF_INT
+ *
+ * Any state |   0b10000000 ->  if the slidebar has updated data,
+ *                produce one input event (last position),
+ *                switch to respective POLL mode
+ *                (like 0x0), if not in POLL mode yet.
+ *
+ * Get current state: read
+ *
+ * masked by 0x11 read value means:
+ *
+ * 0x00   LAST
+ * 0x01   STD
+ * 0x10   OFF
+ * 0x11   ONMOV
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/dmi.h>
+#include <linux/spinlock.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/input.h>
+#include <linux/io.h>
+
+static bool force;
+module_param(force, bool, 0);
+MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
+
+#define KBD_IRQ 1
+
+spinlock_t sio_lock = __SPIN_LOCK_UNLOCKED(sio_lock);
+
+static int prev_scancode;
+static int touched;
+static struct input_dev *slidebar_input_dev;
+static struct platform_device *slidebar_platform_dev;
+
+/* Hardware interacting */
+static int slidebar_pos_get(void)
+{
+    int res;
+    unsigned long flags;
+    spin_lock_irqsave(&sio_lock, flags);
+    outb(0xf4, 0xff29);
+    outb(0xbf, 0xff2a);
+    res = inb(0xff2b);
+    spin_unlock_irqrestore(&sio_lock, flags);
+    return res;
+}
+
+static unsigned char slidebar_mode_get(void)
+{
+    int res;
+    unsigned long flags;
+    spin_lock_irqsave(&sio_lock, flags);
+    outb(0xf7, 0xff29);
+    outb(0x8b, 0xff2a);
+    res = inb(0xff2b);
+    spin_unlock_irqrestore(&sio_lock, flags);
+    return res;
+}
+
+static void slidebar_mode_set(unsigned char mode)
+{
+    unsigned long flags;
+    spin_lock_irqsave(&sio_lock, flags);
+    outb(0xf7, 0xff29);
+    outb(0x8b, 0xff2a);
+    outb(mode, 0xff2b);
+    spin_unlock_irqrestore(&sio_lock, flags);
+}
+
+/* Keyboard handler */
+static irq_handler_t kbd_irq_handler(int irq, void *dev_id,
+                    struct pt_regs *regs)
+{
+    /* Scancodes: e03b on move, bb on release */
+    int scancode = inb(0x60);
+    if (scancode == 0xbb) {
+        touched = 0;
+        input_report_key(slidebar_input_dev, BTN_TOUCH, 0);
+        input_sync(slidebar_input_dev);
+    } else if (prev_scancode == 0xe0 && scancode == 0x3b) {
+        if (!touched)
+            input_report_key(slidebar_input_dev, BTN_TOUCH, 1);
+        touched = 1;
+        input_report_abs(slidebar_input_dev, ABS_X, slidebar_pos_get());
+        input_sync(slidebar_input_dev);
+    }
+    prev_scancode = scancode;
+    return (irq_handler_t) IRQ_HANDLED;
+}
+
+/* Input device */
+static int setup_input_dev(void)
+{
+    int err;
+    err = request_irq(KBD_IRQ, (irq_handler_t) kbd_irq_handler, 
IRQF_SHARED,
+                "ideapad_slidebar", (void *)(kbd_irq_handler));
+    if (err) {
+        pr_err("ideapad_slidebar: Can't allocate irq %d\n", KBD_IRQ);
+        return -EBUSY;
+    }
+
+    slidebar_input_dev = input_allocate_device();
+    if (!slidebar_input_dev) {
+        pr_err("ideapad_slidebar: Not enough memory\n");
+        err = -ENOMEM;
+        goto err_free_irq;
+    }
+
+    slidebar_input_dev->name = "IdeaPad Slidebar";
+    slidebar_input_dev->id.bustype = BUS_HOST;
+    slidebar_input_dev->dev.parent = &slidebar_platform_dev->dev;
+    input_set_capability(slidebar_input_dev, EV_KEY, BTN_TOUCH);
+    input_set_capability(slidebar_input_dev, EV_ABS, ABS_X);
+    input_alloc_absinfo(slidebar_input_dev);
+    input_set_abs_params(slidebar_input_dev, ABS_X, 0, 0xff, 0, 0);
+
+    err = input_register_device(slidebar_input_dev);
+    if (err) {
+        pr_err("ideapad_slidebar: Failed to register device\n");
+        goto err_free_dev;
+    }
+    return 0;
+
+err_free_dev:
+    input_free_device(slidebar_input_dev);
+err_free_irq:
+    free_irq(KBD_IRQ, (void *)(kbd_irq_handler));
+    return err;
+}
+
+static void remove_input_dev(void)
+{
+    free_irq(KBD_IRQ, (void *)(kbd_irq_handler));
+    input_unregister_device(slidebar_input_dev);
+    input_free_device(slidebar_input_dev);
+}
+
+/* Sysfs slidebar_mode interface */
+static ssize_t show_slidebar_mode(struct device *dev,
+                struct device_attribute *attr,
+                char *buf)
+{
+    return sprintf(buf, "%x\n", slidebar_mode_get());
+}
+
+static ssize_t store_slidebar_mode(struct device *dev,
+                struct device_attribute *attr,
+                const char *buf, size_t count)
+{
+    int mode;
+    if (!count)
+        return 0;
+
+    if (sscanf(buf, "%x", &mode) != 1)
+        return -EINVAL;
+
+    slidebar_mode_set(mode);
+    return count;
+}
+
+static DEVICE_ATTR(slidebar_mode, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
+                show_slidebar_mode, store_slidebar_mode);
+
+static struct attribute *ideapad_attributes[] = {
+    &dev_attr_slidebar_mode.attr,
+    NULL
+};
+
+static struct attribute_group ideapad_attribute_group = {
+    .attrs = ideapad_attributes
+};
+
+static int setup_slidebar_mode_dev(void)
+{
+    return sysfs_create_group(&slidebar_platform_dev->dev.kobj,
+                  &ideapad_attribute_group);
+}
+
+static void remove_slidebar_mode_dev(void)
+{
+    return sysfs_remove_group(&slidebar_platform_dev->dev.kobj,
+                  &ideapad_attribute_group);
+}
+
+/* Platform device */
+static int setup_platform_dev(void)
+{
+    int err;
+    slidebar_platform_dev = platform_device_alloc("ideapad_slidebar", -1);
+    if (!slidebar_platform_dev) {
+        pr_err("ideapad_slidebar: Not enough memory\n");
+        return -ENOMEM;
+    }
+
+    err = platform_device_add(slidebar_platform_dev);
+    if (err) {
+        pr_err("ideapad_slidebar: Failed to register plarform device\n");
+        goto err_free_platform_device;
+    }
+    return 0;
+
+err_free_platform_device:
+    platform_device_put(slidebar_platform_dev);
+    return err;
+}
+
+static void remove_platform_dev(void)
+{
+    platform_device_del(slidebar_platform_dev);
+    platform_device_put(slidebar_platform_dev);
+}
+
+/* Platform driver */
+static struct platform_driver slidebar_drv = {
+    .driver = {
+        .name = "ideapad_slidebar",
+        .owner = THIS_MODULE,
+    },
+};
+
+static int register_platform_drv(void)
+{
+    int err;
+    err = platform_driver_register(&slidebar_drv);
+    if (err)
+        pr_err("ideapad_slidebar: Failed to register platform driver\n");
+
+    return err;
+}
+
+static void unregister_platform_drv(void)
+{
+    platform_driver_unregister(&slidebar_drv);
+}
+
+/* DMI */
+static int ideapad_dmi_check(const struct dmi_system_id *id)
+{
+    pr_info("ideapad_slidebar: Laptop model '%s'\n", id->ident);
+    return 1;
+}
+
+static struct dmi_system_id __initdata ideapad_dmi_table[] = {
+    {
+        .ident = "Lenovo IdeaPad Y550",
+        .matches = {
+            DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+            DMI_MATCH(DMI_PRODUCT_NAME, "20017"),
+            DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Y550")
+        },
+        .callback = ideapad_dmi_check
+    },
+    {
+        .ident = "Lenovo IdeaPad Y550P",
+        .matches = {
+            DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+            DMI_MATCH(DMI_PRODUCT_NAME, "20035"),
+            DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Y550P")
+        },
+        .callback = ideapad_dmi_check
+    }
+};
+
+/* Init and cleanup */
+static int __init slidebar_init(void)
+{
+    int err;
+
+    if (!force && !dmi_check_system(ideapad_dmi_table))
+        return -ENODEV;
+
+    err = setup_platform_dev();
+    if (err)
+        return err;
+
+    err = register_platform_drv();
+    if (err)
+        goto err_remove_platform_dev;
+
+    err = setup_input_dev();
+    if (err)
+        goto err_unregister_platform_drv;
+
+    err = setup_slidebar_mode_dev();
+    if (err)
+        goto err_remove_input_dev;
+    return 0;
+
+err_remove_input_dev:
+    remove_input_dev();
+err_unregister_platform_drv:
+    unregister_platform_drv();
+err_remove_platform_dev:
+    remove_platform_dev();
+    return err;
+}
+
+static void __exit slidebar_exit(void)
+{
+    remove_slidebar_mode_dev();
+    remove_input_dev();
+    remove_platform_dev();
+    unregister_platform_drv();
+}
+
+module_init(slidebar_init);
+module_exit(slidebar_exit);
+
+MODULE_AUTHOR("Andrey Moiseev <o2g.org.ru@gmail.com>");
+MODULE_DESCRIPTION("Slidebar input support for some Lenovo IdeaPad 
laptops");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("0.1");
+
+MODULE_ALIAS("dmi:*:svnLENOVO:pn20017:pvrLenovoIdeaPadY550:*");
+MODULE_ALIAS("dmi:*:svnLENOVO:pn20035:pvrLenovoIdeaPadY550P:*");
-- 
1.8.3.4


^ permalink raw reply related

* [PATCH 1/1] Input: htcpen - Fix incorrect placement of __initdata
From: Sachin Kamat @ 2013-08-07  9:39 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, sachin.kamat, Pau Oliva Fora

__initdata should be placed between the variable name and equal
sign for the variable to be placed in the intended section.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Pau Oliva Fora <pau@eslack.org>
---
 drivers/input/touchscreen/htcpen.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/htcpen.c b/drivers/input/touchscreen/htcpen.c
index 6c4fb84..6650085 100644
--- a/drivers/input/touchscreen/htcpen.c
+++ b/drivers/input/touchscreen/htcpen.c
@@ -221,7 +221,7 @@ static struct isa_driver htcpen_isa_driver = {
 	}
 };
 
-static struct dmi_system_id __initdata htcshift_dmi_table[] = {
+static struct dmi_system_id htcshift_dmi_table[] __initdata = {
 	{
 		.ident = "Shift",
 		.matches = {
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 2/3] input: gpio_keys: Convert to devm-* API
From: Alexander Shiyan @ 2013-08-07  8:25 UTC (permalink / raw)
  To: linux-input; +Cc: Linus Walleij, Dmitry Torokhov, Alexander Shiyan
In-Reply-To: <1375863913-26648-1-git-send-email-shc_work@mail.ru>


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/input/keyboard/gpio_keys.c | 96 +++++++++++---------------------------
 1 file changed, 28 insertions(+), 68 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 440ce32..8fe28d7 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -432,7 +432,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 	struct device *dev = &pdev->dev;
 	irq_handler_t isr;
 	unsigned long irqflags;
-	int irq, error;
+	int error;
 
 	bdata->input = input;
 	bdata->button = button;
@@ -440,7 +440,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 
 	if (gpio_is_valid(button->gpio)) {
 
-		error = gpio_request_one(button->gpio, GPIOF_IN, desc);
+		error = devm_gpio_request_one(&pdev->dev, button->gpio,
+					      GPIOF_IN, desc);
 		if (error < 0) {
 			dev_err(dev, "Failed to request GPIO %d, error %d\n",
 				button->gpio, error);
@@ -456,15 +457,13 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 						button->debounce_interval;
 		}
 
-		irq = gpio_to_irq(button->gpio);
-		if (irq < 0) {
-			error = irq;
+		bdata->irq = gpio_to_irq(button->gpio);
+		if (bdata->irq < 0) {
 			dev_err(dev,
 				"Unable to get irq number for GPIO %d, error %d\n",
-				button->gpio, error);
-			goto fail;
+				button->gpio, bdata->irq);
+			return bdata->irq;
 		}
-		bdata->irq = irq;
 
 		INIT_WORK(&bdata->work, gpio_keys_gpio_work_func);
 		setup_timer(&bdata->timer,
@@ -506,16 +505,10 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 	if (error < 0) {
 		dev_err(dev, "Unable to claim irq %d; error %d\n",
 			bdata->irq, error);
-		goto fail;
+		return error;
 	}
 
 	return 0;
-
-fail:
-	if (gpio_is_valid(button->gpio))
-		gpio_free(button->gpio);
-
-	return error;
 }
 
 static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata)
@@ -572,28 +565,20 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 	struct device_node *node, *pp;
 	struct gpio_keys_platform_data *pdata;
 	struct gpio_keys_button *button;
-	int error;
-	int nbuttons;
-	int i;
+	int i, nbuttons;
 
 	node = dev->of_node;
-	if (!node) {
-		error = -ENODEV;
-		goto err_out;
-	}
+	if (!node)
+		return ERR_PTR(-ENODEV);
 
 	nbuttons = of_get_child_count(node);
-	if (nbuttons == 0) {
-		error = -ENODEV;
-		goto err_out;
-	}
+	if (nbuttons == 0)
+		return ERR_PTR(-ENODEV);
 
-	pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
-			GFP_KERNEL);
-	if (!pdata) {
-		error = -ENOMEM;
-		goto err_out;
-	}
+	pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * sizeof(*button),
+			     GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
 
 	pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
 	pdata->nbuttons = nbuttons;
@@ -613,12 +598,11 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 
 		gpio = of_get_gpio_flags(pp, 0, &flags);
 		if (gpio < 0) {
-			error = gpio;
-			if (error != -EPROBE_DEFER)
+			if (gpio != -EPROBE_DEFER)
 				dev_err(dev,
 					"Failed to get gpio flags, error: %d\n",
-					error);
-			goto err_free_pdata;
+					gpio);
+			return ERR_PTR(gpio);
 		}
 
 		button = &pdata->buttons[i++];
@@ -629,8 +613,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 		if (of_property_read_u32(pp, "linux,code", &button->code)) {
 			dev_err(dev, "Button without keycode: 0x%x\n",
 				button->gpio);
-			error = -EINVAL;
-			goto err_free_pdata;
+			return ERR_PTR(-EINVAL);
 		}
 
 		button->desc = of_get_property(pp, "label", NULL);
@@ -645,17 +628,10 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 			button->debounce_interval = 5;
 	}
 
-	if (pdata->nbuttons == 0) {
-		error = -EINVAL;
-		goto err_free_pdata;
-	}
+	if (!pdata->nbuttons)
+		return ERR_PTR(-EINVAL);
 
 	return pdata;
-
-err_free_pdata:
-	kfree(pdata);
-err_out:
-	return ERR_PTR(error);
 }
 
 static struct of_device_id gpio_keys_of_match[] = {
@@ -680,8 +656,6 @@ static void gpio_remove_key(struct gpio_button_data *bdata)
 	if (bdata->timer_debounce)
 		del_timer_sync(&bdata->timer);
 	cancel_work_sync(&bdata->work);
-	if (gpio_is_valid(bdata->button->gpio))
-		gpio_free(bdata->button->gpio);
 }
 
 static int gpio_keys_probe(struct platform_device *pdev)
@@ -699,14 +673,13 @@ static int gpio_keys_probe(struct platform_device *pdev)
 			return PTR_ERR(pdata);
 	}
 
-	ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
-			pdata->nbuttons * sizeof(struct gpio_button_data),
-			GFP_KERNEL);
-	input = input_allocate_device();
+	ddata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_keys_drvdata) +
+			     pdata->nbuttons * sizeof(struct gpio_button_data),
+			     GFP_KERNEL);
+	input = devm_input_allocate_device(&pdev->dev);
 	if (!ddata || !input) {
 		dev_err(dev, "failed to allocate state\n");
-		error = -ENOMEM;
-		goto fail1;
+		return -ENOMEM;
 	}
 
 	ddata->pdata = pdata;
@@ -767,13 +740,6 @@ static int gpio_keys_probe(struct platform_device *pdev)
 	while (--i >= 0)
 		gpio_remove_key(&ddata->data[i]);
 
- fail1:
-	input_free_device(input);
-	kfree(ddata);
-	/* If we have no platform data, we allocated pdata dynamically. */
-	if (!dev_get_platdata(&pdev->dev))
-		kfree(pdata);
-
 	return error;
 }
 
@@ -792,12 +758,6 @@ static int gpio_keys_remove(struct platform_device *pdev)
 
 	input_unregister_device(input);
 
-	/* If we have no platform data, we allocated pdata dynamically. */
-	if (!dev_get_platdata(&pdev->dev))
-		kfree(ddata->pdata);
-
-	kfree(ddata);
-
 	return 0;
 }
 
-- 
1.8.1.5


^ permalink raw reply related

* [PATCH 1/3] input: gpio_keys_polled: Convert to devm-* API
From: Alexander Shiyan @ 2013-08-07  8:25 UTC (permalink / raw)
  To: linux-input; +Cc: Linus Walleij, Dmitry Torokhov, Alexander Shiyan


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/input/keyboard/gpio_keys_polled.c | 87 ++++++++-----------------------
 1 file changed, 23 insertions(+), 64 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index cd5ed9e..b589d12 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -108,9 +108,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
 	struct device_node *node, *pp;
 	struct gpio_keys_platform_data *pdata;
 	struct gpio_keys_button *button;
-	int error;
-	int nbuttons;
-	int i;
+	int i, nbuttons;
 
 	node = dev->of_node;
 	if (!node)
@@ -120,12 +118,10 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
 	if (nbuttons == 0)
 		return NULL;
 
-	pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
-			GFP_KERNEL);
-	if (!pdata) {
-		error = -ENOMEM;
-		goto err_out;
-	}
+	pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * sizeof(*button),
+			     GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
 
 	pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
 	pdata->nbuttons = nbuttons;
@@ -146,12 +142,11 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
 
 		gpio = of_get_gpio_flags(pp, 0, &flags);
 		if (gpio < 0) {
-			error = gpio;
-			if (error != -EPROBE_DEFER)
+			if (gpio != -EPROBE_DEFER)
 				dev_err(dev,
 					"Failed to get gpio flags, error: %d\n",
-					error);
-			goto err_free_pdata;
+					gpio);
+			return ERR_PTR(gpio);
 		}
 
 		button = &pdata->buttons[i++];
@@ -162,8 +157,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
 		if (of_property_read_u32(pp, "linux,code", &button->code)) {
 			dev_err(dev, "Button without keycode: 0x%x\n",
 				button->gpio);
-			error = -EINVAL;
-			goto err_free_pdata;
+			return ERR_PTR(-EINVAL);
 		}
 
 		button->desc = of_get_property(pp, "label", NULL);
@@ -178,17 +172,10 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
 			button->debounce_interval = 5;
 	}
 
-	if (pdata->nbuttons == 0) {
-		error = -EINVAL;
-		goto err_free_pdata;
-	}
+	if (!pdata->nbuttons)
+		return ERR_PTR(-EINVAL);
 
 	return pdata;
-
-err_free_pdata:
-	kfree(pdata);
-err_out:
-	return ERR_PTR(error);
 }
 
 static struct of_device_id gpio_keys_polled_of_match[] = {
@@ -228,24 +215,21 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 
 	if (!pdata->poll_interval) {
 		dev_err(dev, "missing poll_interval value\n");
-		error = -EINVAL;
-		goto err_free_pdata;
+		return -EINVAL;
 	}
 
-	bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
-		       pdata->nbuttons * sizeof(struct gpio_keys_button_data),
-		       GFP_KERNEL);
+	bdev = devm_kzalloc(&pdev->dev, sizeof(struct gpio_keys_polled_dev) +
+		pdata->nbuttons * sizeof(struct gpio_keys_button_data),
+		GFP_KERNEL);
 	if (!bdev) {
 		dev_err(dev, "no memory for private data\n");
-		error = -ENOMEM;
-		goto err_free_pdata;
+		return -ENOMEM;
 	}
 
 	poll_dev = input_allocate_polled_device();
 	if (!poll_dev) {
 		dev_err(dev, "no memory for polled device\n");
-		error = -ENOMEM;
-		goto err_free_bdev;
+		return -ENOMEM;
 	}
 
 	poll_dev->private = bdev;
@@ -278,15 +262,15 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 		if (button->wakeup) {
 			dev_err(dev, DRV_NAME " does not support wakeup\n");
 			error = -EINVAL;
-			goto err_free_gpio;
+			goto err_out;
 		}
 
-		error = gpio_request_one(gpio, GPIOF_IN,
-					 button->desc ?: DRV_NAME);
+		error = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_IN,
+					      button->desc ? : DRV_NAME);
 		if (error) {
 			dev_err(dev, "unable to claim gpio %u, err=%d\n",
 				gpio, error);
-			goto err_free_gpio;
+			goto err_out;
 		}
 
 		bdata->can_sleep = gpio_cansleep(gpio);
@@ -306,7 +290,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 	if (error) {
 		dev_err(dev, "unable to register polled device, err=%d\n",
 			error);
-		goto err_free_gpio;
+		goto err_out;
 	}
 
 	/* report initial state of the buttons */
@@ -316,45 +300,20 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_free_gpio:
-	while (--i >= 0)
-		gpio_free(pdata->buttons[i].gpio);
-
+err_out:
 	input_free_polled_device(poll_dev);
 
-err_free_bdev:
-	kfree(bdev);
-
-err_free_pdata:
-	/* If we have no platform_data, we allocated pdata dynamically.  */
-	if (!dev_get_platdata(&pdev->dev))
-		kfree(pdata);
-
 	return error;
 }
 
 static int gpio_keys_polled_remove(struct platform_device *pdev)
 {
 	struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
-	const struct gpio_keys_platform_data *pdata = bdev->pdata;
-	int i;
 
 	input_unregister_polled_device(bdev->poll_dev);
 
-	for (i = 0; i < pdata->nbuttons; i++)
-		gpio_free(pdata->buttons[i].gpio);
-
 	input_free_polled_device(bdev->poll_dev);
 
-	/*
-	 * If we had no platform_data, we allocated pdata dynamically and
-	 * must free it here.
-	 */
-	if (!dev_get_platdata(&pdev->dev))
-		kfree(pdata);
-
-	kfree(bdev);
-
 	return 0;
 }
 
-- 
1.8.1.5


^ permalink raw reply related

* [PATCH 3/3] input: gpio_keys{_polled}: Replace enable/disable callbacks with regulator API
From: Alexander Shiyan @ 2013-08-07  8:25 UTC (permalink / raw)
  To: linux-input; +Cc: Linus Walleij, Dmitry Torokhov, Alexander Shiyan
In-Reply-To: <1375863913-26648-1-git-send-email-shc_work@mail.ru>

Typical use to enable/disable is a power switch, so replace these
callbacks to the regulator API. This will allow using devices,
which depends on the regulator, from devicetree.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 .../devicetree/bindings/input/gpio-keys-polled.txt |  1 +
 arch/arm/mach-ux500/board-mop500-regulators.c      |  2 +-
 arch/arm/mach-ux500/board-mop500.c                 | 25 ----------------------
 drivers/input/keyboard/gpio_keys.c                 | 16 ++++++++------
 drivers/input/keyboard/gpio_keys_polled.c          | 16 ++++++++------
 include/linux/gpio_keys.h                          |  2 --
 6 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/gpio-keys-polled.txt b/Documentation/devicetree/bindings/input/gpio-keys-polled.txt
index 313abef..4dba546 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys-polled.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys-polled.txt
@@ -7,6 +7,7 @@ Required properties:
 Optional properties:
 	- autorepeat: Boolean, Enable auto repeat feature of Linux input
 	  subsystem.
+	- keys-supply: The regulator to drive the GPIOs.
 
 Each button (key) is represented as a sub-node of "gpio-keys-polled":
 Subnode properties:
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c
index 0dc44c6..6952117 100644
--- a/arch/arm/mach-ux500/board-mop500-regulators.c
+++ b/arch/arm/mach-ux500/board-mop500-regulators.c
@@ -76,7 +76,7 @@ static struct regulator_consumer_supply ab8500_vaux1_consumers[] = {
 	/* Secondary display, ST uib */
 	REGULATOR_SUPPLY("vdd1", "samsung_s6d16d0.1"),
 	/* SFH7741 proximity sensor */
-	REGULATOR_SUPPLY("vcc", "gpio-keys.0"),
+	REGULATOR_SUPPLY("keys", "gpio-keys.0"),
 	/* BH1780GLS ambient light sensor */
 	REGULATOR_SUPPLY("vcc", "2-0029"),
 	/* lsm303dlh accelerometer */
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index df5d27a..f0b327d 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -375,15 +375,9 @@ static struct gpio_keys_button mop500_gpio_keys[] = {
 	}
 };
 
-static struct regulator *prox_regulator;
-static int mop500_prox_activate(struct device *dev);
-static void mop500_prox_deactivate(struct device *dev);
-
 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
 	.buttons	= mop500_gpio_keys,
 	.nbuttons	= ARRAY_SIZE(mop500_gpio_keys),
-	.enable		= mop500_prox_activate,
-	.disable	= mop500_prox_deactivate,
 };
 
 static struct platform_device mop500_gpio_keys_device = {
@@ -394,25 +388,6 @@ static struct platform_device mop500_gpio_keys_device = {
 	},
 };
 
-static int mop500_prox_activate(struct device *dev)
-{
-	prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
-						"vcc");
-	if (IS_ERR(prox_regulator)) {
-		dev_err(&mop500_gpio_keys_device.dev,
-			"no regulator\n");
-		return PTR_ERR(prox_regulator);
-	}
-
-	return regulator_enable(prox_regulator);
-}
-
-static void mop500_prox_deactivate(struct device *dev)
-{
-	regulator_disable(prox_regulator);
-	regulator_put(prox_regulator);
-}
-
 static struct cryp_platform_data u8500_cryp1_platform_data = {
 		.mem_to_engine = {
 				.dir = DMA_MEM_TO_DEV,
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 8fe28d7..785befc 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,6 +29,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/spinlock.h>
+#include <linux/regulator/consumer.h>
 
 struct gpio_button_data {
 	const struct gpio_keys_button *button;
@@ -47,6 +48,7 @@ struct gpio_keys_drvdata {
 	struct input_dev *input;
 	struct mutex disable_lock;
 	struct gpio_button_data data[0];
+	struct regulator *regulator;
 };
 
 /*
@@ -527,11 +529,10 @@ static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata)
 static int gpio_keys_open(struct input_dev *input)
 {
 	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
-	const struct gpio_keys_platform_data *pdata = ddata->pdata;
 	int error;
 
-	if (pdata->enable) {
-		error = pdata->enable(input->dev.parent);
+	if (!IS_ERR(ddata->regulator)) {
+		error = regulator_enable(ddata->regulator);
 		if (error)
 			return error;
 	}
@@ -545,10 +546,9 @@ static int gpio_keys_open(struct input_dev *input)
 static void gpio_keys_close(struct input_dev *input)
 {
 	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
-	const struct gpio_keys_platform_data *pdata = ddata->pdata;
 
-	if (pdata->disable)
-		pdata->disable(input->dev.parent);
+	if (!IS_ERR(ddata->regulator))
+		regulator_disable(ddata->regulator);
 }
 
 /*
@@ -682,6 +682,10 @@ static int gpio_keys_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	ddata->regulator = devm_regulator_get(&pdev->dev, "keys");
+	if (PTR_ERR(ddata->regulator) == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
 	ddata->pdata = pdata;
 	ddata->input = input;
 	mutex_init(&ddata->disable_lock);
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index b589d12..405afbd 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -27,6 +27,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
+#include <linux/regulator/consumer.h>
 
 #define DRV_NAME	"gpio-keys-polled"
 
@@ -42,6 +43,7 @@ struct gpio_keys_polled_dev {
 	struct device *dev;
 	const struct gpio_keys_platform_data *pdata;
 	struct gpio_keys_button_data data[0];
+	struct regulator *regulator;
 };
 
 static void gpio_keys_polled_check_state(struct input_dev *input,
@@ -87,19 +89,17 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
 static void gpio_keys_polled_open(struct input_polled_dev *dev)
 {
 	struct gpio_keys_polled_dev *bdev = dev->private;
-	const struct gpio_keys_platform_data *pdata = bdev->pdata;
 
-	if (pdata->enable)
-		pdata->enable(bdev->dev);
+	if (!IS_ERR(bdev->regulator))
+		regulator_enable(bdev->regulator);
 }
 
 static void gpio_keys_polled_close(struct input_polled_dev *dev)
 {
 	struct gpio_keys_polled_dev *bdev = dev->private;
-	const struct gpio_keys_platform_data *pdata = bdev->pdata;
 
-	if (pdata->disable)
-		pdata->disable(bdev->dev);
+	if (!IS_ERR(bdev->regulator))
+		regulator_disable(bdev->regulator);
 }
 
 #ifdef CONFIG_OF
@@ -226,6 +226,10 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	bdev->regulator = devm_regulator_get(&pdev->dev, "keys");
+	if (PTR_ERR(bdev->regulator) == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
 	poll_dev = input_allocate_polled_device();
 	if (!poll_dev) {
 		dev_err(dev, "no memory for polled device\n");
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index a7e977f..05d3bf8 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -23,8 +23,6 @@ struct gpio_keys_platform_data {
 	unsigned int poll_interval;	/* polling interval in msecs -
 					   for polling driver only */
 	unsigned int rep:1;		/* enable input subsystem auto repeat */
-	int (*enable)(struct device *dev);
-	void (*disable)(struct device *dev);
 	const char *name;		/* input device name */
 };
 
-- 
1.8.1.5


^ permalink raw reply related

* Re: List corruption in hidraw_release in 3.11-rc4
From: Jiri Kosina @ 2013-08-07  1:01 UTC (permalink / raw)
  To: Peter Wu; +Cc: linux-input, Manoj Chourasia, linux-kernel, alnovak
In-Reply-To: <6712128.bn50J4si9x@al>

On Tue, 6 Aug 2013, Peter Wu wrote:

> While debugging upowerd (with Logitech Unifying receiver via hidraw),
> I came across this list corruption warning.

Peter,

does the patch below fix the problem you are seeing?

---
 drivers/hid/hidraw.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index a745163..6f1feb2 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -518,7 +518,6 @@ int hidraw_connect(struct hid_device *hid)
 		goto out;
 	}
 
-	mutex_unlock(&minors_lock);
 	init_waitqueue_head(&dev->wait);
 	INIT_LIST_HEAD(&dev->list);
 
@@ -528,6 +527,7 @@ int hidraw_connect(struct hid_device *hid)
 	dev->exist = 1;
 	hid->hidraw = dev;
 
+	mutex_unlock(&minors_lock);
 out:
 	return result;
 
-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply related

* List corruption in hidraw_release in 3.11-rc4
From: Peter Wu @ 2013-08-06 21:30 UTC (permalink / raw)
  To: linux-input; +Cc: Manoj Chourasia, linux-kernel, Jiri Kosina

Hi,

While debugging upowerd (with Logitech Unifying receiver via hidraw),
I came across this list corruption warning. It probably has something
to do with me removing the receiver and re-inserting it while the file
descriptor to /dev/hidraw0 was still open. journalctl excerpt is on the
bottom of this message, what I did was:

1. Run upowerd under gdb (using sudo)
2. disconnect, wait for a short time and reinsert the USB receiver
3. kill upowerd (ctrl+c in gdb, confirm kill, gdb exits)

I have not yet tried to reproduce it, this is a heads-up.

Could http://lkml.org/lkml/2013/7/22/248 help with this case? I have not
seen a kernel Oops as mentioned in that report though.

Regards,
Peter

Aug 06 22:57:42 al sudo[14951]: peter : TTY=pts/8 ; PWD=/tmp/upower ; USER=root ; ENV=G_DEBUG=all ; COMMAND=/usr/bin/gdb --args /tmp/upower-build/dst/usr/lib/upower/upowerd -v
Aug 06 22:57:42 al sudo[14951]: pam_unix(sudo:session): session opened for user root by peter(uid=0)
Aug 06 22:58:11 al kernel: usb 1-1.1: USB disconnect, device number 7
Aug 06 22:58:13 al kernel: usb 1-1.1: new full-speed USB device number 8 using ehci-pci
Aug 06 22:58:13 al kernel: logitech-djreceiver 0003:046D:C52B.001B: hiddev0,hidraw0: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:1a.0-1.1/input2
Aug 06 22:58:13 al kernel: input: Logitech Unifying Device. Wireless PID:4013 as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.2/0003:046D:C52B.001B/input/input21
Aug 06 22:58:13 al kernel: logitech-djdevice 0003:046D:C52B.001C: input,hidraw1: USB HID v1.11 Mouse [Logitech Unifying Device. Wireless PID:4013] on usb-0000:00:1a.0-1.1:1
Aug 06 22:58:13 al kernel: input: Logitech Unifying Device. Wireless PID:2010 as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.2/0003:046D:C52B.001B/input/input22
Aug 06 22:58:13 al kernel: logitech-djdevice 0003:046D:C52B.001D: input,hidraw2: USB HID v1.11 Keyboard [Logitech Unifying Device. Wireless PID:2010] on usb-0000:00:1a.0-1.1:2
Aug 06 22:58:13 al mtp-probe[14989]: checking bus 1, device 8: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1"
Aug 06 22:58:13 al mtp-probe[14989]: bus: 1, device: 8 was not an MTP device
Aug 06 22:59:45 al kernel: usb 1-1.1: USB disconnect, device number 8
Aug 06 22:59:47 al kernel: usb 1-1.1: new full-speed USB device number 9 using ehci-pci
Aug 06 22:59:47 al kernel: logitech-djreceiver 0003:046D:C52B.0020: hiddev0,hidraw0: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:1a.0-1.1/input2
Aug 06 22:59:47 al kernel: input: Logitech Unifying Device. Wireless PID:4013 as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.2/0003:046D:C52B.0020/input/input23
Aug 06 22:59:47 al kernel: logitech-djdevice 0003:046D:C52B.0021: input,hidraw1: USB HID v1.11 Mouse [Logitech Unifying Device. Wireless PID:4013] on usb-0000:00:1a.0-1.1:1
Aug 06 22:59:47 al kernel: input: Logitech Unifying Device. Wireless PID:2010 as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.2/0003:046D:C52B.0020/input/input24
Aug 06 22:59:47 al kernel: logitech-djdevice 0003:046D:C52B.0022: input,hidraw2: USB HID v1.11 Keyboard [Logitech Unifying Device. Wireless PID:2010] on usb-0000:00:1a.0-1.1:2
Aug 06 22:59:47 al mtp-probe[15011]: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1"
Aug 06 22:59:47 al mtp-probe[15011]: bus: 1, device: 9 was not an MTP device
Aug 06 23:02:40 al kernel: ------------[ cut here ]------------
Aug 06 23:02:40 al kernel: WARNING: CPU: 3 PID: 14954 at lib/list_debug.c:59 __list_del_entry+0xa1/0xd0()
Aug 06 23:02:40 al kernel: list_del corruption. prev->next should be ffff8801ef384c18, but was           (null)
Aug 06 23:02:40 al kernel: Modules linked in: usb_storage ip_set_hash_ip xt_set ip_set nfnetlink ipt_REJECT xt_recent xt_owner xt_addrtype iptable_filter ipt_MASQUERADE iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat ip_tables xt_tcpudp nf_conntrack_ipv6 nf_defrag_ipv6 xt_LOG xt_limit sit tunnel4 ip_tunnel xt_conntrack nf_conntrack ip6table_filter ip6_tables x_tables arc4 iwldvm mac80211 pl2303 usbserial coretemp kvm_intel kvm psmouse snd_hda_codec_hdmi snd_hda_codec_via snd_hda_intel snd_hda_codec iwlwifi snd_hwdep snd_pcm cfg80211 snd_page_alloc jmb38x_ms jme memstick mii snd_timer snd soundcore i2c_i801 intel_ips mxm_wmi clevo_wmi(O) wmi bbswitch(O) autofs4 dm_crypt ahci xhci_hcd libahci sdhci_pci sdhci hid_logitech_dj usbhid hid i915 video i2c_algo_bit drm_kms_helper dr
 m
Aug 06 23:02:40 al kernel: CPU: 3 PID: 14954 Comm: upowerd Tainted: G           O 3.11.0-1-custom #1
Aug 06 23:02:40 al sudo[14951]: pam_unix(sudo:session): session closed for user root
Aug 06 23:02:40 al kernel: Hardware name: CLEVO CO.                        B7130                           /B7130                           , BIOS 6.00 08/27/2010
Aug 06 23:02:40 al kernel:  0000000000000009 ffff8801a4345b78 ffffffff81598af5 ffff8801a4345bc0
Aug 06 23:02:40 al kernel:  ffff8801a4345bb0 ffffffff810456bd ffff8801ef384c18 ffff8801ef384800
Aug 06 23:02:40 al kernel:  ffff8801a4257168 ffff880194e71000 ffff880232673820 ffff8801a4345c10
Aug 06 23:02:40 al kernel: Call Trace:
Aug 06 23:02:40 al kernel:  [<ffffffff81598af5>] dump_stack+0x54/0x74
Aug 06 23:02:40 al kernel:  [<ffffffff810456bd>] warn_slowpath_common+0x7d/0xa0
Aug 06 23:02:40 al kernel:  [<ffffffff8104572c>] warn_slowpath_fmt+0x4c/0x50
Aug 06 23:02:40 al kernel:  [<ffffffff812f58c1>] __list_del_entry+0xa1/0xd0
Aug 06 23:02:40 al kernel:  [<ffffffff812f58fd>] list_del+0xd/0x30
Aug 06 23:02:40 al kernel:  [<ffffffffa013c0a6>] hidraw_release+0x46/0xe0 [hid]
Aug 06 23:02:40 al kernel:  [<ffffffff81171c74>] __fput+0xf4/0x250
Aug 06 23:02:40 al kernel:  [<ffffffff81171e1e>] ____fput+0xe/0x10
Aug 06 23:02:40 al kernel:  [<ffffffff810670c4>] task_work_run+0xb4/0xe0
Aug 06 23:02:40 al kernel:  [<ffffffff81046ba8>] do_exit+0x2b8/0xa70
Aug 06 23:02:40 al kernel:  [<ffffffff815a005c>] ? _raw_spin_unlock_irq+0x2c/0x40
Aug 06 23:02:40 al kernel:  [<ffffffff810482e9>] do_group_exit+0x49/0xc0
Aug 06 23:02:40 al kernel:  [<ffffffff81058c73>] get_signal_to_deliver+0x2c3/0x6e0
Aug 06 23:02:40 al kernel:  [<ffffffff81058d67>] ? get_signal_to_deliver+0x3b7/0x6e0
Aug 06 23:02:40 al kernel:  [<ffffffff810023d8>] do_signal+0x48/0x8b0
Aug 06 23:02:40 al kernel:  [<ffffffff811394d7>] ? might_fault+0x57/0xb0
Aug 06 23:02:40 al kernel:  [<ffffffff815a90c0>] ? sysret_signal+0x5/0x47
Aug 06 23:02:40 al kernel:  [<ffffffff81002ca5>] do_notify_resume+0x65/0x80
Aug 06 23:02:40 al kernel:  [<ffffffff815a9352>] int_signal+0x12/0x17
Aug 06 23:02:40 al kernel: ---[ end trace cb12de73e428a7e2 ]---
Aug 06 23:02:40 al kernel: ------------[ cut here ]------------
Aug 06 23:02:40 al kernel: WARNING: CPU: 3 PID: 14954 at lib/list_debug.c:59 __list_del_entry+0xa1/0xd0()
Aug 06 23:02:40 al kernel: list_del corruption. prev->next should be ffff88019126f418, but was dead000000100100
Aug 06 23:02:40 al kernel: Modules linked in: usb_storage ip_set_hash_ip xt_set ip_set nfnetlink ipt_REJECT xt_recent xt_owner xt_addrtype iptable_filter ipt_MASQUERADE iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat ip_tables xt_tcpudp nf_conntrack_ipv6 nf_defrag_ipv6 xt_LOG xt_limit sit tunnel4 ip_tunnel xt_conntrack nf_conntrack ip6table_filter ip6_tables x_tables arc4 iwldvm mac80211 pl2303 usbserial coretemp kvm_intel kvm psmouse snd_hda_codec_hdmi snd_hda_codec_via snd_hda_intel snd_hda_codec iwlwifi snd_hwdep snd_pcm cfg80211 snd_page_alloc jmb38x_ms jme memstick mii snd_timer snd soundcore i2c_i801 intel_ips mxm_wmi clevo_wmi(O) wmi bbswitch(O) autofs4 dm_crypt ahci xhci_hcd libahci sdhci_pci sdhci hid_logitech_dj usbhid hid i915 video i2c_algo_bit drm_kms_helper dr
 m
Aug 06 23:02:40 al kernel: CPU: 3 PID: 14954 Comm: upowerd Tainted: G        W  O 3.11.0-1-custom #1
Aug 06 23:02:40 al kernel: Hardware name: CLEVO CO.                        B7130                           /B7130                           , BIOS 6.00 08/27/2010
Aug 06 23:02:40 al kernel:  0000000000000009 ffff8801a4345b78 ffffffff81598af5 ffff8801a4345bc0
Aug 06 23:02:40 al kernel:  ffff8801a4345bb0 ffffffff810456bd ffff88019126f418 ffff88019126f000
Aug 06 23:02:40 al kernel:  ffff8801a4257168 ffff880194e71000 ffff880232673820 ffff8801a4345c10
Aug 06 23:02:40 al kernel: Call Trace:
Aug 06 23:02:40 al kernel:  [<ffffffff81598af5>] dump_stack+0x54/0x74
Aug 06 23:02:40 al kernel:  [<ffffffff810456bd>] warn_slowpath_common+0x7d/0xa0
Aug 06 23:02:40 al kernel:  [<ffffffff8104572c>] warn_slowpath_fmt+0x4c/0x50
Aug 06 23:02:40 al kernel:  [<ffffffff812f58c1>] __list_del_entry+0xa1/0xd0
Aug 06 23:02:40 al kernel:  [<ffffffff812f58fd>] list_del+0xd/0x30
Aug 06 23:02:40 al kernel:  [<ffffffffa013c0a6>] hidraw_release+0x46/0xe0 [hid]
Aug 06 23:02:40 al kernel:  [<ffffffff81171c74>] __fput+0xf4/0x250
Aug 06 23:02:40 al kernel:  [<ffffffff81171e1e>] ____fput+0xe/0x10
Aug 06 23:02:40 al kernel:  [<ffffffff810670c4>] task_work_run+0xb4/0xe0
Aug 06 23:02:40 al kernel:  [<ffffffff81046ba8>] do_exit+0x2b8/0xa70
Aug 06 23:02:40 al kernel:  [<ffffffff815a005c>] ? _raw_spin_unlock_irq+0x2c/0x40
Aug 06 23:02:40 al kernel:  [<ffffffff810482e9>] do_group_exit+0x49/0xc0
Aug 06 23:02:40 al kernel:  [<ffffffff81058c73>] get_signal_to_deliver+0x2c3/0x6e0
Aug 06 23:02:40 al kernel:  [<ffffffff81058d67>] ? get_signal_to_deliver+0x3b7/0x6e0
Aug 06 23:02:40 al kernel:  [<ffffffff810023d8>] do_signal+0x48/0x8b0
Aug 06 23:02:40 al kernel:  [<ffffffff811394d7>] ? might_fault+0x57/0xb0
Aug 06 23:02:40 al kernel:  [<ffffffff815a90c0>] ? sysret_signal+0x5/0x47
Aug 06 23:02:40 al kernel:  [<ffffffff81002ca5>] do_notify_resume+0x65/0x80
Aug 06 23:02:40 al kernel:  [<ffffffff815a9352>] int_signal+0x12/0x17
Aug 06 23:02:40 al kernel: ---[ end trace cb12de73e428a7e3 ]---
Aug 06 23:02:41 al sudo[15029]: peter : TTY=pts/8 ; PWD=/tmp/upower ; USER=root ; ENV=G_DEBUG=all ; COMMAND=/usr/bin/gdb --args /tmp/upower-build/dst/usr/lib/upower/upowerd -v
Aug 06 23:02:41 al sudo[15029]: pam_unix(sudo:session): session opened for user root by peter(uid=0)
Aug 06 23:03:20 al sudo[15029]: pam_unix(sudo:session): session closed for user root


^ permalink raw reply

* Re: [PATCH 2/2] HID: hid-logitech-dj, querying_devices was never set
From: Sune Mølgaard @ 2013-08-06 21:03 UTC (permalink / raw)
  To: Benjamin Tissoires, Jiri Kosina
  Cc: Nestor Lopez Casado, Andrew de los Reyes, joseph.salisbury,
	linux-input, linux-kernel@vger.kernel.org
In-Reply-To: <CAN+gG=Hjd1Ay0=HrJdV9797DxTMf97_13kdkuHNWi24EfPL-ig@mail.gmail.com>

Being affected by this bug, I can confirm that Linux 3.11-rc4 still
exhibits the unwanted behaviour for me, but that commenting out the
single line from the second patch makes it work.

Thus, for requesting a revert on that line, you are most welcome to put
me down as a "Tested-By".

Best regards,

Sune Mølgaard

Benjamin Tissoires wrote:
> On Mon, Aug 5, 2013 at 3:22 PM, Jiri Kosina <jkosina@suse.cz> wrote:
>> On Fri, 2 Aug 2013, Benjamin Tissoires wrote:
>>
>>>> Could you please elaborate? (and put an elaborate description to revert
>>>> commit log perhaps?)
>>>
>>> Sure, so here is the revert commit log:
>>>
>>> --
>>>
>>> Commit "HID: hid-logitech-dj, querying_devices was never set" activate
>>> a flag which guarantees that we do not ask the receiver for too many
>>> enumeration. When the flag is set, each following enumeration call is
>>> discarded (the usb request is not forwarded to the receiver). The flag
>>> is then released when the driver receive a pairing information event,
>>> which normally follows the enumeration request.
>>> However, the USB3 bug makes the driver think the enumeration request
>>> has been forwarded to the receiver. However, it is actually not the
>>> case because the USB stack returns -EPIPE. So, when a new unknown
>>> device appears, the workaround consisting in asking for a new
>>> enumeration is not working anymore: this new enumeration is discarded
>>> because of the flag, which is never reset.
>>>
>>> A solution could be to trigger a timeout before releasing it, but for
>>> now, let's just revert the patch.
>>>
>>> --
>>
>> Thanks Benjamin.
>>
>> I'd like to have a bit more clarification about the USB3 bug, as this
>> whole issue is not completely clear to me.
>>
>> To be more specific -- when exactly do we receive -EPIPE, why do we
>> receive it and why do we not handle it properly?
> 
> Sure, I'll try (though the more I think of it, the more it seems
> blurry to me :( ).
> 
> So the initial probe function in hid-logitech-dj was implemented by
> using a direct call to hid_output_raw_report(). This call was
> synchronous, so we did get the -EPIPE return code. Then, the probe()
> function returns the -EPIPE error, cleaning the receiver and
> unregister it from the hid bus.
> 
> However, now, we use hid_hw_request(), which is asynchronous (from
> what I can read). At least, this code returns "void" as the set_report
> command seems to be scheduled for later handling. In usbhid, when the
> queue is flushed, I did not found a way to retrieve the error code...
> 
> So basically, the -EPIPE is received in usbhid_restart_ctrl_queue(),
> but nothing notifies hid-logitech-dj from the error. In the end, the
> probe() function returns without error code, but the receiver never
> received the notification.
> 
> Cheers,
> Benjamin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 


-- 
"Testiculos habet et bene pendentes"
See http://www.newint.org/features/1993/06/05/curious/

^ permalink raw reply

* Re: [PATCH 2/2] ARM: tegra: use dt-binding header for key code
From: Stephen Warren @ 2013-08-06 19:28 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	swarren-DDmLM1+adcrQT0dZR+AlfA, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1375798370-2231-2-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

On 08/06/2013 08:12 AM, Laxman Dewangan wrote:
> In place of hardcoding the key code in DTS file and comment the key code
> as side notes, use the key code macro defines in the dt-bindings/input/input.h
> directly.

This one also looks fine to me. I'll wait for an updated version that
converts everything once patch 1/2 is accepted/applied.

^ permalink raw reply

* Re: [PATCH 1/2] include: dt-binding: input: create a DT header defining key codes.
From: Stephen Warren @ 2013-08-06 19:28 UTC (permalink / raw)
  To: Laxman Dewangan
  Cc: dmitry.torokhov, swarren, linux, linux-arm-kernel, linux-tegra,
	linux-kernel, linux-input, devicetree, Ian Campbell, Rob Herring,
	Pawel Moll, Mark Rutland
In-Reply-To: <1375798370-2231-1-git-send-email-ldewangan@nvidia.com>

(CC'ing DT bindings maintainers too, hence quoting a bit of the patch)

On 08/06/2013 08:12 AM, Laxman Dewangan wrote:
> Many of Key device tree bindings uses the constant number as key code
> which matches with kernel header key code and then comment as follows
> for reference/better readability:
> 	linux,code = <102>; /* KEY_HOME */
> 
> Create a DT header which defines all the key code so that DT key bindings
> can use it as follows:
> 	linux,code = <KEY_HOME>;

This looks fine to me.
Reviewed-by: Stephen Warren <swarren@nvidia.com>

A comment in support of the patch: This is adding OS-specific content to
the DT. However, the bindings this header file supports are already
written that way. There's not really any alternative here, since some
numbering scheme had to be chosen for keycodes, and it may as well be
the same set as the first/primary OS that'll use the binding.

As far as merging it, this patch should probably go through the core DT
tree, perhaps in a topic branch so that e.g. Tegra an MVEBU can merge it
in to apply your subsequent patches (or we can just wait until the next
kernel release to merge them in).

>  include/dt-bindings/input/input.h |  525 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 525 insertions(+), 0 deletions(-)
>  create mode 100644 include/dt-bindings/input/input.h
> 
> diff --git a/include/dt-bindings/input/input.h b/include/dt-bindings/input/input.h
> new file mode 100644
> index 0000000..042e7b3
> --- /dev/null
> +++ b/include/dt-bindings/input/input.h
> @@ -0,0 +1,525 @@
> +/*
> + * This header provides constants for most input bindings.
> + *
> + * Most input bindings include key code, matrix key code format.
> + * In most cases, key code and matrix key code format uses
> + * the standard values/macro defined in this header.
> + */
> +
> +#ifndef _DT_BINDINGS_INPUT_INPUT_H
> +#define _DT_BINDINGS_INPUT_INPUT_H
> +
> +#define KEY_RESERVED		0
> +#define KEY_ESC			1
> +#define KEY_1			2
> +#define KEY_2			3
...
> +#define BTN_DPAD_UP		0x220
> +#define BTN_DPAD_DOWN		0x221
> +#define BTN_DPAD_LEFT		0x222
> +#define BTN_DPAD_RIGHT		0x223
> +
> +#define MATRIX_KEY(row, col, code)	\
> +	((((row) & 0xFF) << 24) | (((col) & 0xFF) << 16) | ((code) & 0xFFFF))
> +
> +#endif /* _DT_BINDINGS_INPUT_INPUT_H */


^ permalink raw reply

* Re: [PATCH 1/2] include: dt-binding: input: create a DT header defining key codes.
From: Jason Cooper @ 2013-08-06 14:28 UTC (permalink / raw)
  To: Laxman Dewangan, Andrew Lunn, Gregory CLEMENT, Thomas Petazzoni,
	Ezequiel Garcia
  Cc: dmitry.torokhov, swarren, linux, linux-arm-kernel, linux-tegra,
	linux-kernel, linux-input, devicetree
In-Reply-To: <1375798370-2231-1-git-send-email-ldewangan@nvidia.com>

Laxman,

On Tue, Aug 06, 2013 at 07:42:49PM +0530, Laxman Dewangan wrote:
> Many of Key device tree bindings uses the constant number as key code
> which matches with kernel header key code and then comment as follows
> for reference/better readability:
> 	linux,code = <102>; /* KEY_HOME */
> 
> Create a DT header which defines all the key code so that DT key bindings
> can use it as follows:
> 	linux,code = <KEY_HOME>;
> 
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> ---
> Just adding the change for Tegra114-dalmore DTS file along with this change.
> If this is accpeted and no issue on this then I will cleanup more Tegra
> specific DTS files.
> 
>  include/dt-bindings/input/input.h |  525 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 525 insertions(+), 0 deletions(-)
>  create mode 100644 include/dt-bindings/input/input.h

Thanks for doing this!  I'm adding the mvebu maintainers to the Cc: to
remind us to go through our board files once this gets merged.

thx,

Jason.

> 
> diff --git a/include/dt-bindings/input/input.h b/include/dt-bindings/input/input.h
> new file mode 100644
> index 0000000..042e7b3
> --- /dev/null
> +++ b/include/dt-bindings/input/input.h
> @@ -0,0 +1,525 @@
> +/*
> + * This header provides constants for most input bindings.
> + *
> + * Most input bindings include key code, matrix key code format.
> + * In most cases, key code and matrix key code format uses
> + * the standard values/macro defined in this header.
> + */
> +
> +#ifndef _DT_BINDINGS_INPUT_INPUT_H
> +#define _DT_BINDINGS_INPUT_INPUT_H
> +
> +#define KEY_RESERVED		0
> +#define KEY_ESC			1
> +#define KEY_1			2
> +#define KEY_2			3
> +#define KEY_3			4
> +#define KEY_4			5
> +#define KEY_5			6
> +#define KEY_6			7
> +#define KEY_7			8
> +#define KEY_8			9
> +#define KEY_9			10
> +#define KEY_0			11
> +#define KEY_MINUS		12
> +#define KEY_EQUAL		13
> +#define KEY_BACKSPACE		14
> +#define KEY_TAB			15
> +#define KEY_Q			16
> +#define KEY_W			17
> +#define KEY_E			18
> +#define KEY_R			19
> +#define KEY_T			20
> +#define KEY_Y			21
> +#define KEY_U			22
> +#define KEY_I			23
> +#define KEY_O			24
> +#define KEY_P			25
> +#define KEY_LEFTBRACE		26
> +#define KEY_RIGHTBRACE		27
> +#define KEY_ENTER		28
> +#define KEY_LEFTCTRL		29
> +#define KEY_A			30
> +#define KEY_S			31
> +#define KEY_D			32
> +#define KEY_F			33
> +#define KEY_G			34
> +#define KEY_H			35
> +#define KEY_J			36
> +#define KEY_K			37
> +#define KEY_L			38
> +#define KEY_SEMICOLON		39
> +#define KEY_APOSTROPHE		40
> +#define KEY_GRAVE		41
> +#define KEY_LEFTSHIFT		42
> +#define KEY_BACKSLASH		43
> +#define KEY_Z			44
> +#define KEY_X			45
> +#define KEY_C			46
> +#define KEY_V			47
> +#define KEY_B			48
> +#define KEY_N			49
> +#define KEY_M			50
> +#define KEY_COMMA		51
> +#define KEY_DOT			52
> +#define KEY_SLASH		53
> +#define KEY_RIGHTSHIFT		54
> +#define KEY_KPASTERISK		55
> +#define KEY_LEFTALT		56
> +#define KEY_SPACE		57
> +#define KEY_CAPSLOCK		58
> +#define KEY_F1			59
> +#define KEY_F2			60
> +#define KEY_F3			61
> +#define KEY_F4			62
> +#define KEY_F5			63
> +#define KEY_F6			64
> +#define KEY_F7			65
> +#define KEY_F8			66
> +#define KEY_F9			67
> +#define KEY_F10			68
> +#define KEY_NUMLOCK		69
> +#define KEY_SCROLLLOCK		70
> +#define KEY_KP7			71
> +#define KEY_KP8			72
> +#define KEY_KP9			73
> +#define KEY_KPMINUS		74
> +#define KEY_KP4			75
> +#define KEY_KP5			76
> +#define KEY_KP6			77
> +#define KEY_KPPLUS		78
> +#define KEY_KP1			79
> +#define KEY_KP2			80
> +#define KEY_KP3			81
> +#define KEY_KP0			82
> +#define KEY_KPDOT		83
> +
> +#define KEY_ZENKAKUHANKAKU	85
> +#define KEY_102ND		86
> +#define KEY_F11			87
> +#define KEY_F12			88
> +#define KEY_RO			89
> +#define KEY_KATAKANA		90
> +#define KEY_HIRAGANA		91
> +#define KEY_HENKAN		92
> +#define KEY_KATAKANAHIRAGANA	93
> +#define KEY_MUHENKAN		94
> +#define KEY_KPJPCOMMA		95
> +#define KEY_KPENTER		96
> +#define KEY_RIGHTCTRL		97
> +#define KEY_KPSLASH		98
> +#define KEY_SYSRQ		99
> +#define KEY_RIGHTALT		100
> +#define KEY_LINEFEED		101
> +#define KEY_HOME		102
> +#define KEY_UP			103
> +#define KEY_PAGEUP		104
> +#define KEY_LEFT		105
> +#define KEY_RIGHT		106
> +#define KEY_END			107
> +#define KEY_DOWN		108
> +#define KEY_PAGEDOWN		109
> +#define KEY_INSERT		110
> +#define KEY_DELETE		111
> +#define KEY_MACRO		112
> +#define KEY_MUTE		113
> +#define KEY_VOLUMEDOWN		114
> +#define KEY_VOLUMEUP		115
> +#define KEY_POWER		116	/* SC System Power Down */
> +#define KEY_KPEQUAL		117
> +#define KEY_KPPLUSMINUS		118
> +#define KEY_PAUSE		119
> +#define KEY_SCALE		120	/* AL Compiz Scale (Expose) */
> +
> +#define KEY_KPCOMMA		121
> +#define KEY_HANGEUL		122
> +#define KEY_HANGUEL		KEY_HANGEUL
> +#define KEY_HANJA		123
> +#define KEY_YEN			124
> +#define KEY_LEFTMETA		125
> +#define KEY_RIGHTMETA		126
> +#define KEY_COMPOSE		127
> +
> +#define KEY_STOP		128	/* AC Stop */
> +#define KEY_AGAIN		129
> +#define KEY_PROPS		130	/* AC Properties */
> +#define KEY_UNDO		131	/* AC Undo */
> +#define KEY_FRONT		132
> +#define KEY_COPY		133	/* AC Copy */
> +#define KEY_OPEN		134	/* AC Open */
> +#define KEY_PASTE		135	/* AC Paste */
> +#define KEY_FIND		136	/* AC Search */
> +#define KEY_CUT			137	/* AC Cut */
> +#define KEY_HELP		138	/* AL Integrated Help Center */
> +#define KEY_MENU		139	/* Menu (show menu) */
> +#define KEY_CALC		140	/* AL Calculator */
> +#define KEY_SETUP		141
> +#define KEY_SLEEP		142	/* SC System Sleep */
> +#define KEY_WAKEUP		143	/* System Wake Up */
> +#define KEY_FILE		144	/* AL Local Machine Browser */
> +#define KEY_SENDFILE		145
> +#define KEY_DELETEFILE		146
> +#define KEY_XFER		147
> +#define KEY_PROG1		148
> +#define KEY_PROG2		149
> +#define KEY_WWW			150	/* AL Internet Browser */
> +#define KEY_MSDOS		151
> +#define KEY_COFFEE		152	/* AL Terminal Lock/Screensaver */
> +#define KEY_SCREENLOCK		KEY_COFFEE
> +#define KEY_DIRECTION		153
> +#define KEY_CYCLEWINDOWS	154
> +#define KEY_MAIL		155
> +#define KEY_BOOKMARKS		156	/* AC Bookmarks */
> +#define KEY_COMPUTER		157
> +#define KEY_BACK		158	/* AC Back */
> +#define KEY_FORWARD		159	/* AC Forward */
> +#define KEY_CLOSECD		160
> +#define KEY_EJECTCD		161
> +#define KEY_EJECTCLOSECD	162
> +#define KEY_NEXTSONG		163
> +#define KEY_PLAYPAUSE		164
> +#define KEY_PREVIOUSSONG	165
> +#define KEY_STOPCD		166
> +#define KEY_RECORD		167
> +#define KEY_REWIND		168
> +#define KEY_PHONE		169	/* Media Select Telephone */
> +#define KEY_ISO			170
> +#define KEY_CONFIG		171	/* AL Consumer Control Configuration */
> +#define KEY_HOMEPAGE		172	/* AC Home */
> +#define KEY_REFRESH		173	/* AC Refresh */
> +#define KEY_EXIT		174	/* AC Exit */
> +#define KEY_MOVE		175
> +#define KEY_EDIT		176
> +#define KEY_SCROLLUP		177
> +#define KEY_SCROLLDOWN		178
> +#define KEY_KPLEFTPAREN		179
> +#define KEY_KPRIGHTPAREN	180
> +#define KEY_NEW			181	/* AC New */
> +#define KEY_REDO		182	/* AC Redo/Repeat */
> +
> +#define KEY_F13			183
> +#define KEY_F14			184
> +#define KEY_F15			185
> +#define KEY_F16			186
> +#define KEY_F17			187
> +#define KEY_F18			188
> +#define KEY_F19			189
> +#define KEY_F20			190
> +#define KEY_F21			191
> +#define KEY_F22			192
> +#define KEY_F23			193
> +#define KEY_F24			194
> +
> +#define KEY_PLAYCD		200
> +#define KEY_PAUSECD		201
> +#define KEY_PROG3		202
> +#define KEY_PROG4		203
> +#define KEY_DASHBOARD		204	/* AL Dashboard */
> +#define KEY_SUSPEND		205
> +#define KEY_CLOSE		206	/* AC Close */
> +#define KEY_PLAY		207
> +#define KEY_FASTFORWARD		208
> +#define KEY_BASSBOOST		209
> +#define KEY_PRINT		210	/* AC Print */
> +#define KEY_HP			211
> +#define KEY_CAMERA		212
> +#define KEY_SOUND		213
> +#define KEY_QUESTION		214
> +#define KEY_EMAIL		215
> +#define KEY_CHAT		216
> +#define KEY_SEARCH		217
> +#define KEY_CONNECT		218
> +#define KEY_FINANCE		219	/* AL Checkbook/Finance */
> +#define KEY_SPORT		220
> +#define KEY_SHOP		221
> +#define KEY_ALTERASE		222
> +#define KEY_CANCEL		223	/* AC Cancel */
> +#define KEY_BRIGHTNESSDOWN	224
> +#define KEY_BRIGHTNESSUP	225
> +#define KEY_MEDIA		226
> +
> +#define KEY_SWITCHVIDEOMODE	227	/* Cycle between available video
> +					   outputs (Monitor/LCD/TV-out/etc) */
> +#define KEY_KBDILLUMTOGGLE	228
> +#define KEY_KBDILLUMDOWN	229
> +#define KEY_KBDILLUMUP		230
> +
> +#define KEY_SEND		231	/* AC Send */
> +#define KEY_REPLY		232	/* AC Reply */
> +#define KEY_FORWARDMAIL		233	/* AC Forward Msg */
> +#define KEY_SAVE		234	/* AC Save */
> +#define KEY_DOCUMENTS		235
> +
> +#define KEY_BATTERY		236
> +
> +#define KEY_BLUETOOTH		237
> +#define KEY_WLAN		238
> +#define KEY_UWB			239
> +
> +#define KEY_UNKNOWN		240
> +
> +#define KEY_VIDEO_NEXT		241	/* drive next video source */
> +#define KEY_VIDEO_PREV		242	/* drive previous video source */
> +#define KEY_BRIGHTNESS_CYCLE	243	/* brightness up, after max is min */
> +#define KEY_BRIGHTNESS_ZERO	244	/* brightness off, use ambient */
> +#define KEY_DISPLAY_OFF		245	/* display device to off state */
> +
> +#define KEY_WIMAX		246
> +#define KEY_RFKILL		247	/* Key that controls all radios */
> +
> +#define KEY_MICMUTE		248	/* Mute / unmute the microphone */
> +
> +/* Code 255 is reserved for special needs of AT keyboard driver */
> +
> +#define BTN_MISC		0x100
> +#define BTN_0			0x100
> +#define BTN_1			0x101
> +#define BTN_2			0x102
> +#define BTN_3			0x103
> +#define BTN_4			0x104
> +#define BTN_5			0x105
> +#define BTN_6			0x106
> +#define BTN_7			0x107
> +#define BTN_8			0x108
> +#define BTN_9			0x109
> +
> +#define BTN_MOUSE		0x110
> +#define BTN_LEFT		0x110
> +#define BTN_RIGHT		0x111
> +#define BTN_MIDDLE		0x112
> +#define BTN_SIDE		0x113
> +#define BTN_EXTRA		0x114
> +#define BTN_FORWARD		0x115
> +#define BTN_BACK		0x116
> +#define BTN_TASK		0x117
> +
> +#define BTN_JOYSTICK		0x120
> +#define BTN_TRIGGER		0x120
> +#define BTN_THUMB		0x121
> +#define BTN_THUMB2		0x122
> +#define BTN_TOP			0x123
> +#define BTN_TOP2		0x124
> +#define BTN_PINKIE		0x125
> +#define BTN_BASE		0x126
> +#define BTN_BASE2		0x127
> +#define BTN_BASE3		0x128
> +#define BTN_BASE4		0x129
> +#define BTN_BASE5		0x12a
> +#define BTN_BASE6		0x12b
> +#define BTN_DEAD		0x12f
> +
> +#define BTN_GAMEPAD		0x130
> +#define BTN_SOUTH		0x130
> +#define BTN_A			BTN_SOUTH
> +#define BTN_EAST		0x131
> +#define BTN_B			BTN_EAST
> +#define BTN_C			0x132
> +#define BTN_NORTH		0x133
> +#define BTN_X			BTN_NORTH
> +#define BTN_WEST		0x134
> +#define BTN_Y			BTN_WEST
> +#define BTN_Z			0x135
> +#define BTN_TL			0x136
> +#define BTN_TR			0x137
> +#define BTN_TL2			0x138
> +#define BTN_TR2			0x139
> +#define BTN_SELECT		0x13a
> +#define BTN_START		0x13b
> +#define BTN_MODE		0x13c
> +#define BTN_THUMBL		0x13d
> +#define BTN_THUMBR		0x13e
> +
> +#define BTN_DIGI		0x140
> +#define BTN_TOOL_PEN		0x140
> +#define BTN_TOOL_RUBBER		0x141
> +#define BTN_TOOL_BRUSH		0x142
> +#define BTN_TOOL_PENCIL		0x143
> +#define BTN_TOOL_AIRBRUSH	0x144
> +#define BTN_TOOL_FINGER		0x145
> +#define BTN_TOOL_MOUSE		0x146
> +#define BTN_TOOL_LENS		0x147
> +#define BTN_TOOL_QUINTTAP	0x148	/* Five fingers on trackpad */
> +#define BTN_TOUCH		0x14a
> +#define BTN_STYLUS		0x14b
> +#define BTN_STYLUS2		0x14c
> +#define BTN_TOOL_DOUBLETAP	0x14d
> +#define BTN_TOOL_TRIPLETAP	0x14e
> +#define BTN_TOOL_QUADTAP	0x14f	/* Four fingers on trackpad */
> +
> +#define BTN_WHEEL		0x150
> +#define BTN_GEAR_DOWN		0x150
> +#define BTN_GEAR_UP		0x151
> +
> +#define KEY_OK			0x160
> +#define KEY_SELECT		0x161
> +#define KEY_GOTO		0x162
> +#define KEY_CLEAR		0x163
> +#define KEY_POWER2		0x164
> +#define KEY_OPTION		0x165
> +#define KEY_INFO		0x166	/* AL OEM Features/Tips/Tutorial */
> +#define KEY_TIME		0x167
> +#define KEY_VENDOR		0x168
> +#define KEY_ARCHIVE		0x169
> +#define KEY_PROGRAM		0x16a	/* Media Select Program Guide */
> +#define KEY_CHANNEL		0x16b
> +#define KEY_FAVORITES		0x16c
> +#define KEY_EPG			0x16d
> +#define KEY_PVR			0x16e	/* Media Select Home */
> +#define KEY_MHP			0x16f
> +#define KEY_LANGUAGE		0x170
> +#define KEY_TITLE		0x171
> +#define KEY_SUBTITLE		0x172
> +#define KEY_ANGLE		0x173
> +#define KEY_ZOOM		0x174
> +#define KEY_MODE		0x175
> +#define KEY_KEYBOARD		0x176
> +#define KEY_SCREEN		0x177
> +#define KEY_PC			0x178	/* Media Select Computer */
> +#define KEY_TV			0x179	/* Media Select TV */
> +#define KEY_TV2			0x17a	/* Media Select Cable */
> +#define KEY_VCR			0x17b	/* Media Select VCR */
> +#define KEY_VCR2		0x17c	/* VCR Plus */
> +#define KEY_SAT			0x17d	/* Media Select Satellite */
> +#define KEY_SAT2		0x17e
> +#define KEY_CD			0x17f	/* Media Select CD */
> +#define KEY_TAPE		0x180	/* Media Select Tape */
> +#define KEY_RADIO		0x181
> +#define KEY_TUNER		0x182	/* Media Select Tuner */
> +#define KEY_PLAYER		0x183
> +#define KEY_TEXT		0x184
> +#define KEY_DVD			0x185	/* Media Select DVD */
> +#define KEY_AUX			0x186
> +#define KEY_MP3			0x187
> +#define KEY_AUDIO		0x188	/* AL Audio Browser */
> +#define KEY_VIDEO		0x189	/* AL Movie Browser */
> +#define KEY_DIRECTORY		0x18a
> +#define KEY_LIST		0x18b
> +#define KEY_MEMO		0x18c	/* Media Select Messages */
> +#define KEY_CALENDAR		0x18d
> +#define KEY_RED			0x18e
> +#define KEY_GREEN		0x18f
> +#define KEY_YELLOW		0x190
> +#define KEY_BLUE		0x191
> +#define KEY_CHANNELUP		0x192	/* Channel Increment */
> +#define KEY_CHANNELDOWN		0x193	/* Channel Decrement */
> +#define KEY_FIRST		0x194
> +#define KEY_LAST		0x195	/* Recall Last */
> +#define KEY_AB			0x196
> +#define KEY_NEXT		0x197
> +#define KEY_RESTART		0x198
> +#define KEY_SLOW		0x199
> +#define KEY_SHUFFLE		0x19a
> +#define KEY_BREAK		0x19b
> +#define KEY_PREVIOUS		0x19c
> +#define KEY_DIGITS		0x19d
> +#define KEY_TEEN		0x19e
> +#define KEY_TWEN		0x19f
> +#define KEY_VIDEOPHONE		0x1a0	/* Media Select Video Phone */
> +#define KEY_GAMES		0x1a1	/* Media Select Games */
> +#define KEY_ZOOMIN		0x1a2	/* AC Zoom In */
> +#define KEY_ZOOMOUT		0x1a3	/* AC Zoom Out */
> +#define KEY_ZOOMRESET		0x1a4	/* AC Zoom */
> +#define KEY_WORDPROCESSOR	0x1a5	/* AL Word Processor */
> +#define KEY_EDITOR		0x1a6	/* AL Text Editor */
> +#define KEY_SPREADSHEET		0x1a7	/* AL Spreadsheet */
> +#define KEY_GRAPHICSEDITOR	0x1a8	/* AL Graphics Editor */
> +#define KEY_PRESENTATION	0x1a9	/* AL Presentation App */
> +#define KEY_DATABASE		0x1aa	/* AL Database App */
> +#define KEY_NEWS		0x1ab	/* AL Newsreader */
> +#define KEY_VOICEMAIL		0x1ac	/* AL Voicemail */
> +#define KEY_ADDRESSBOOK		0x1ad	/* AL Contacts/Address Book */
> +#define KEY_MESSENGER		0x1ae	/* AL Instant Messaging */
> +#define KEY_DISPLAYTOGGLE	0x1af	/* Turn display (LCD) on and off */
> +#define KEY_SPELLCHECK		0x1b0   /* AL Spell Check */
> +#define KEY_LOGOFF		0x1b1   /* AL Logoff */
> +
> +#define KEY_DOLLAR		0x1b2
> +#define KEY_EURO		0x1b3
> +
> +#define KEY_FRAMEBACK		0x1b4	/* Consumer - transport controls */
> +#define KEY_FRAMEFORWARD	0x1b5
> +#define KEY_CONTEXT_MENU	0x1b6	/* GenDesc - system context menu */
> +#define KEY_MEDIA_REPEAT	0x1b7	/* Consumer - transport control */
> +#define KEY_10CHANNELSUP	0x1b8	/* 10 channels up (10+) */
> +#define KEY_10CHANNELSDOWN	0x1b9	/* 10 channels down (10-) */
> +#define KEY_IMAGES		0x1ba	/* AL Image Browser */
> +
> +#define KEY_DEL_EOL		0x1c0
> +#define KEY_DEL_EOS		0x1c1
> +#define KEY_INS_LINE		0x1c2
> +#define KEY_DEL_LINE		0x1c3
> +
> +#define KEY_FN			0x1d0
> +#define KEY_FN_ESC		0x1d1
> +#define KEY_FN_F1		0x1d2
> +#define KEY_FN_F2		0x1d3
> +#define KEY_FN_F3		0x1d4
> +#define KEY_FN_F4		0x1d5
> +#define KEY_FN_F5		0x1d6
> +#define KEY_FN_F6		0x1d7
> +#define KEY_FN_F7		0x1d8
> +#define KEY_FN_F8		0x1d9
> +#define KEY_FN_F9		0x1da
> +#define KEY_FN_F10		0x1db
> +#define KEY_FN_F11		0x1dc
> +#define KEY_FN_F12		0x1dd
> +#define KEY_FN_1		0x1de
> +#define KEY_FN_2		0x1df
> +#define KEY_FN_D		0x1e0
> +#define KEY_FN_E		0x1e1
> +#define KEY_FN_F		0x1e2
> +#define KEY_FN_S		0x1e3
> +#define KEY_FN_B		0x1e4
> +
> +#define KEY_BRL_DOT1		0x1f1
> +#define KEY_BRL_DOT2		0x1f2
> +#define KEY_BRL_DOT3		0x1f3
> +#define KEY_BRL_DOT4		0x1f4
> +#define KEY_BRL_DOT5		0x1f5
> +#define KEY_BRL_DOT6		0x1f6
> +#define KEY_BRL_DOT7		0x1f7
> +#define KEY_BRL_DOT8		0x1f8
> +#define KEY_BRL_DOT9		0x1f9
> +#define KEY_BRL_DOT10		0x1fa
> +
> +#define KEY_NUMERIC_0		0x200	/* used by phones, remote controls, */
> +#define KEY_NUMERIC_1		0x201	/* and other keypads */
> +#define KEY_NUMERIC_2		0x202
> +#define KEY_NUMERIC_3		0x203
> +#define KEY_NUMERIC_4		0x204
> +#define KEY_NUMERIC_5		0x205
> +#define KEY_NUMERIC_6		0x206
> +#define KEY_NUMERIC_7		0x207
> +#define KEY_NUMERIC_8		0x208
> +#define KEY_NUMERIC_9		0x209
> +#define KEY_NUMERIC_STAR	0x20a
> +#define KEY_NUMERIC_POUND	0x20b
> +
> +#define KEY_CAMERA_FOCUS	0x210
> +#define KEY_WPS_BUTTON		0x211	/* WiFi Protected Setup key */
> +
> +#define KEY_TOUCHPAD_TOGGLE	0x212	/* Request switch touchpad on or off */
> +#define KEY_TOUCHPAD_ON		0x213
> +#define KEY_TOUCHPAD_OFF	0x214
> +
> +#define KEY_CAMERA_ZOOMIN	0x215
> +#define KEY_CAMERA_ZOOMOUT	0x216
> +#define KEY_CAMERA_UP		0x217
> +#define KEY_CAMERA_DOWN		0x218
> +#define KEY_CAMERA_LEFT		0x219
> +#define KEY_CAMERA_RIGHT	0x21a
> +
> +#define KEY_ATTENDANT_ON	0x21b
> +#define KEY_ATTENDANT_OFF	0x21c
> +#define KEY_ATTENDANT_TOGGLE	0x21d	/* Attendant call on or off */
> +#define KEY_LIGHTS_TOGGLE	0x21e	/* Reading light on or off */
> +
> +#define BTN_DPAD_UP		0x220
> +#define BTN_DPAD_DOWN		0x221
> +#define BTN_DPAD_LEFT		0x222
> +#define BTN_DPAD_RIGHT		0x223
> +
> +#define MATRIX_KEY(row, col, code)	\
> +	((((row) & 0xFF) << 24) | (((col) & 0xFF) << 16) | ((code) & 0xFFFF))
> +
> +#endif /* _DT_BINDINGS_INPUT_INPUT_H */
> -- 
> 1.7.1.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 2/2] ARM: tegra: use dt-binding header for key code
From: Laxman Dewangan @ 2013-08-06 14:12 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	swarren-DDmLM1+adcrQT0dZR+AlfA
  Cc: linux-lFZ/pmaqli7XmaaqVzeoHQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Laxman Dewangan
In-Reply-To: <1375798370-2231-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

In place of hardcoding the key code in DTS file and comment the key code
as side notes, use the key code macro defines in the dt-bindings/input/input.h
directly.

Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 arch/arm/boot/dts/tegra114-dalmore.dts |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/tegra114-dalmore.dts b/arch/arm/boot/dts/tegra114-dalmore.dts
index 7c50d37..c56bf2d 100644
--- a/arch/arm/boot/dts/tegra114-dalmore.dts
+++ b/arch/arm/boot/dts/tegra114-dalmore.dts
@@ -1,5 +1,6 @@
 /dts-v1/;
 
+#include <dt-bindings/input/input.h>
 #include "tegra114.dtsi"
 
 / {
@@ -1084,26 +1085,26 @@
 		home {
 			label = "Home";
 			gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
-			linux,code = <102>; /* KEY_HOME */
+			linux,code = <KEY_HOME>;
 		};
 
 		power {
 			label = "Power";
 			gpios = <&gpio TEGRA_GPIO(Q, 0) GPIO_ACTIVE_LOW>;
-			linux,code = <116>; /* KEY_POWER */
+			linux,code = <KEY_POWER>;
 			gpio-key,wakeup;
 		};
 
 		volume_down {
 			label = "Volume Down";
 			gpios = <&gpio TEGRA_GPIO(R, 1) GPIO_ACTIVE_LOW>;
-			linux,code = <114>; /* KEY_VOLUMEDOWN */
+			linux,code = <KEY_VOLUMEDOWN>;
 		};
 
 		volume_up {
 			label = "Volume Up";
 			gpios = <&gpio TEGRA_GPIO(R, 2) GPIO_ACTIVE_LOW>;
-			linux,code = <115>; /* KEY_VOLUMEUP */
+			linux,code = <KEY_VOLUMEUP>;
 		};
 	};
 
-- 
1.7.1.1

^ permalink raw reply related

* [PATCH 1/2] include: dt-binding: input: create a DT header defining key codes.
From: Laxman Dewangan @ 2013-08-06 14:12 UTC (permalink / raw)
  To: dmitry.torokhov, swarren
  Cc: linux, linux-arm-kernel, linux-tegra, linux-kernel, linux-input,
	devicetree, Laxman Dewangan

Many of Key device tree bindings uses the constant number as key code
which matches with kernel header key code and then comment as follows
for reference/better readability:
	linux,code = <102>; /* KEY_HOME */

Create a DT header which defines all the key code so that DT key bindings
can use it as follows:
	linux,code = <KEY_HOME>;

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
Just adding the change for Tegra114-dalmore DTS file along with this change.
If this is accpeted and no issue on this then I will cleanup more Tegra
specific DTS files.

 include/dt-bindings/input/input.h |  525 +++++++++++++++++++++++++++++++++++++
 1 files changed, 525 insertions(+), 0 deletions(-)
 create mode 100644 include/dt-bindings/input/input.h

diff --git a/include/dt-bindings/input/input.h b/include/dt-bindings/input/input.h
new file mode 100644
index 0000000..042e7b3
--- /dev/null
+++ b/include/dt-bindings/input/input.h
@@ -0,0 +1,525 @@
+/*
+ * This header provides constants for most input bindings.
+ *
+ * Most input bindings include key code, matrix key code format.
+ * In most cases, key code and matrix key code format uses
+ * the standard values/macro defined in this header.
+ */
+
+#ifndef _DT_BINDINGS_INPUT_INPUT_H
+#define _DT_BINDINGS_INPUT_INPUT_H
+
+#define KEY_RESERVED		0
+#define KEY_ESC			1
+#define KEY_1			2
+#define KEY_2			3
+#define KEY_3			4
+#define KEY_4			5
+#define KEY_5			6
+#define KEY_6			7
+#define KEY_7			8
+#define KEY_8			9
+#define KEY_9			10
+#define KEY_0			11
+#define KEY_MINUS		12
+#define KEY_EQUAL		13
+#define KEY_BACKSPACE		14
+#define KEY_TAB			15
+#define KEY_Q			16
+#define KEY_W			17
+#define KEY_E			18
+#define KEY_R			19
+#define KEY_T			20
+#define KEY_Y			21
+#define KEY_U			22
+#define KEY_I			23
+#define KEY_O			24
+#define KEY_P			25
+#define KEY_LEFTBRACE		26
+#define KEY_RIGHTBRACE		27
+#define KEY_ENTER		28
+#define KEY_LEFTCTRL		29
+#define KEY_A			30
+#define KEY_S			31
+#define KEY_D			32
+#define KEY_F			33
+#define KEY_G			34
+#define KEY_H			35
+#define KEY_J			36
+#define KEY_K			37
+#define KEY_L			38
+#define KEY_SEMICOLON		39
+#define KEY_APOSTROPHE		40
+#define KEY_GRAVE		41
+#define KEY_LEFTSHIFT		42
+#define KEY_BACKSLASH		43
+#define KEY_Z			44
+#define KEY_X			45
+#define KEY_C			46
+#define KEY_V			47
+#define KEY_B			48
+#define KEY_N			49
+#define KEY_M			50
+#define KEY_COMMA		51
+#define KEY_DOT			52
+#define KEY_SLASH		53
+#define KEY_RIGHTSHIFT		54
+#define KEY_KPASTERISK		55
+#define KEY_LEFTALT		56
+#define KEY_SPACE		57
+#define KEY_CAPSLOCK		58
+#define KEY_F1			59
+#define KEY_F2			60
+#define KEY_F3			61
+#define KEY_F4			62
+#define KEY_F5			63
+#define KEY_F6			64
+#define KEY_F7			65
+#define KEY_F8			66
+#define KEY_F9			67
+#define KEY_F10			68
+#define KEY_NUMLOCK		69
+#define KEY_SCROLLLOCK		70
+#define KEY_KP7			71
+#define KEY_KP8			72
+#define KEY_KP9			73
+#define KEY_KPMINUS		74
+#define KEY_KP4			75
+#define KEY_KP5			76
+#define KEY_KP6			77
+#define KEY_KPPLUS		78
+#define KEY_KP1			79
+#define KEY_KP2			80
+#define KEY_KP3			81
+#define KEY_KP0			82
+#define KEY_KPDOT		83
+
+#define KEY_ZENKAKUHANKAKU	85
+#define KEY_102ND		86
+#define KEY_F11			87
+#define KEY_F12			88
+#define KEY_RO			89
+#define KEY_KATAKANA		90
+#define KEY_HIRAGANA		91
+#define KEY_HENKAN		92
+#define KEY_KATAKANAHIRAGANA	93
+#define KEY_MUHENKAN		94
+#define KEY_KPJPCOMMA		95
+#define KEY_KPENTER		96
+#define KEY_RIGHTCTRL		97
+#define KEY_KPSLASH		98
+#define KEY_SYSRQ		99
+#define KEY_RIGHTALT		100
+#define KEY_LINEFEED		101
+#define KEY_HOME		102
+#define KEY_UP			103
+#define KEY_PAGEUP		104
+#define KEY_LEFT		105
+#define KEY_RIGHT		106
+#define KEY_END			107
+#define KEY_DOWN		108
+#define KEY_PAGEDOWN		109
+#define KEY_INSERT		110
+#define KEY_DELETE		111
+#define KEY_MACRO		112
+#define KEY_MUTE		113
+#define KEY_VOLUMEDOWN		114
+#define KEY_VOLUMEUP		115
+#define KEY_POWER		116	/* SC System Power Down */
+#define KEY_KPEQUAL		117
+#define KEY_KPPLUSMINUS		118
+#define KEY_PAUSE		119
+#define KEY_SCALE		120	/* AL Compiz Scale (Expose) */
+
+#define KEY_KPCOMMA		121
+#define KEY_HANGEUL		122
+#define KEY_HANGUEL		KEY_HANGEUL
+#define KEY_HANJA		123
+#define KEY_YEN			124
+#define KEY_LEFTMETA		125
+#define KEY_RIGHTMETA		126
+#define KEY_COMPOSE		127
+
+#define KEY_STOP		128	/* AC Stop */
+#define KEY_AGAIN		129
+#define KEY_PROPS		130	/* AC Properties */
+#define KEY_UNDO		131	/* AC Undo */
+#define KEY_FRONT		132
+#define KEY_COPY		133	/* AC Copy */
+#define KEY_OPEN		134	/* AC Open */
+#define KEY_PASTE		135	/* AC Paste */
+#define KEY_FIND		136	/* AC Search */
+#define KEY_CUT			137	/* AC Cut */
+#define KEY_HELP		138	/* AL Integrated Help Center */
+#define KEY_MENU		139	/* Menu (show menu) */
+#define KEY_CALC		140	/* AL Calculator */
+#define KEY_SETUP		141
+#define KEY_SLEEP		142	/* SC System Sleep */
+#define KEY_WAKEUP		143	/* System Wake Up */
+#define KEY_FILE		144	/* AL Local Machine Browser */
+#define KEY_SENDFILE		145
+#define KEY_DELETEFILE		146
+#define KEY_XFER		147
+#define KEY_PROG1		148
+#define KEY_PROG2		149
+#define KEY_WWW			150	/* AL Internet Browser */
+#define KEY_MSDOS		151
+#define KEY_COFFEE		152	/* AL Terminal Lock/Screensaver */
+#define KEY_SCREENLOCK		KEY_COFFEE
+#define KEY_DIRECTION		153
+#define KEY_CYCLEWINDOWS	154
+#define KEY_MAIL		155
+#define KEY_BOOKMARKS		156	/* AC Bookmarks */
+#define KEY_COMPUTER		157
+#define KEY_BACK		158	/* AC Back */
+#define KEY_FORWARD		159	/* AC Forward */
+#define KEY_CLOSECD		160
+#define KEY_EJECTCD		161
+#define KEY_EJECTCLOSECD	162
+#define KEY_NEXTSONG		163
+#define KEY_PLAYPAUSE		164
+#define KEY_PREVIOUSSONG	165
+#define KEY_STOPCD		166
+#define KEY_RECORD		167
+#define KEY_REWIND		168
+#define KEY_PHONE		169	/* Media Select Telephone */
+#define KEY_ISO			170
+#define KEY_CONFIG		171	/* AL Consumer Control Configuration */
+#define KEY_HOMEPAGE		172	/* AC Home */
+#define KEY_REFRESH		173	/* AC Refresh */
+#define KEY_EXIT		174	/* AC Exit */
+#define KEY_MOVE		175
+#define KEY_EDIT		176
+#define KEY_SCROLLUP		177
+#define KEY_SCROLLDOWN		178
+#define KEY_KPLEFTPAREN		179
+#define KEY_KPRIGHTPAREN	180
+#define KEY_NEW			181	/* AC New */
+#define KEY_REDO		182	/* AC Redo/Repeat */
+
+#define KEY_F13			183
+#define KEY_F14			184
+#define KEY_F15			185
+#define KEY_F16			186
+#define KEY_F17			187
+#define KEY_F18			188
+#define KEY_F19			189
+#define KEY_F20			190
+#define KEY_F21			191
+#define KEY_F22			192
+#define KEY_F23			193
+#define KEY_F24			194
+
+#define KEY_PLAYCD		200
+#define KEY_PAUSECD		201
+#define KEY_PROG3		202
+#define KEY_PROG4		203
+#define KEY_DASHBOARD		204	/* AL Dashboard */
+#define KEY_SUSPEND		205
+#define KEY_CLOSE		206	/* AC Close */
+#define KEY_PLAY		207
+#define KEY_FASTFORWARD		208
+#define KEY_BASSBOOST		209
+#define KEY_PRINT		210	/* AC Print */
+#define KEY_HP			211
+#define KEY_CAMERA		212
+#define KEY_SOUND		213
+#define KEY_QUESTION		214
+#define KEY_EMAIL		215
+#define KEY_CHAT		216
+#define KEY_SEARCH		217
+#define KEY_CONNECT		218
+#define KEY_FINANCE		219	/* AL Checkbook/Finance */
+#define KEY_SPORT		220
+#define KEY_SHOP		221
+#define KEY_ALTERASE		222
+#define KEY_CANCEL		223	/* AC Cancel */
+#define KEY_BRIGHTNESSDOWN	224
+#define KEY_BRIGHTNESSUP	225
+#define KEY_MEDIA		226
+
+#define KEY_SWITCHVIDEOMODE	227	/* Cycle between available video
+					   outputs (Monitor/LCD/TV-out/etc) */
+#define KEY_KBDILLUMTOGGLE	228
+#define KEY_KBDILLUMDOWN	229
+#define KEY_KBDILLUMUP		230
+
+#define KEY_SEND		231	/* AC Send */
+#define KEY_REPLY		232	/* AC Reply */
+#define KEY_FORWARDMAIL		233	/* AC Forward Msg */
+#define KEY_SAVE		234	/* AC Save */
+#define KEY_DOCUMENTS		235
+
+#define KEY_BATTERY		236
+
+#define KEY_BLUETOOTH		237
+#define KEY_WLAN		238
+#define KEY_UWB			239
+
+#define KEY_UNKNOWN		240
+
+#define KEY_VIDEO_NEXT		241	/* drive next video source */
+#define KEY_VIDEO_PREV		242	/* drive previous video source */
+#define KEY_BRIGHTNESS_CYCLE	243	/* brightness up, after max is min */
+#define KEY_BRIGHTNESS_ZERO	244	/* brightness off, use ambient */
+#define KEY_DISPLAY_OFF		245	/* display device to off state */
+
+#define KEY_WIMAX		246
+#define KEY_RFKILL		247	/* Key that controls all radios */
+
+#define KEY_MICMUTE		248	/* Mute / unmute the microphone */
+
+/* Code 255 is reserved for special needs of AT keyboard driver */
+
+#define BTN_MISC		0x100
+#define BTN_0			0x100
+#define BTN_1			0x101
+#define BTN_2			0x102
+#define BTN_3			0x103
+#define BTN_4			0x104
+#define BTN_5			0x105
+#define BTN_6			0x106
+#define BTN_7			0x107
+#define BTN_8			0x108
+#define BTN_9			0x109
+
+#define BTN_MOUSE		0x110
+#define BTN_LEFT		0x110
+#define BTN_RIGHT		0x111
+#define BTN_MIDDLE		0x112
+#define BTN_SIDE		0x113
+#define BTN_EXTRA		0x114
+#define BTN_FORWARD		0x115
+#define BTN_BACK		0x116
+#define BTN_TASK		0x117
+
+#define BTN_JOYSTICK		0x120
+#define BTN_TRIGGER		0x120
+#define BTN_THUMB		0x121
+#define BTN_THUMB2		0x122
+#define BTN_TOP			0x123
+#define BTN_TOP2		0x124
+#define BTN_PINKIE		0x125
+#define BTN_BASE		0x126
+#define BTN_BASE2		0x127
+#define BTN_BASE3		0x128
+#define BTN_BASE4		0x129
+#define BTN_BASE5		0x12a
+#define BTN_BASE6		0x12b
+#define BTN_DEAD		0x12f
+
+#define BTN_GAMEPAD		0x130
+#define BTN_SOUTH		0x130
+#define BTN_A			BTN_SOUTH
+#define BTN_EAST		0x131
+#define BTN_B			BTN_EAST
+#define BTN_C			0x132
+#define BTN_NORTH		0x133
+#define BTN_X			BTN_NORTH
+#define BTN_WEST		0x134
+#define BTN_Y			BTN_WEST
+#define BTN_Z			0x135
+#define BTN_TL			0x136
+#define BTN_TR			0x137
+#define BTN_TL2			0x138
+#define BTN_TR2			0x139
+#define BTN_SELECT		0x13a
+#define BTN_START		0x13b
+#define BTN_MODE		0x13c
+#define BTN_THUMBL		0x13d
+#define BTN_THUMBR		0x13e
+
+#define BTN_DIGI		0x140
+#define BTN_TOOL_PEN		0x140
+#define BTN_TOOL_RUBBER		0x141
+#define BTN_TOOL_BRUSH		0x142
+#define BTN_TOOL_PENCIL		0x143
+#define BTN_TOOL_AIRBRUSH	0x144
+#define BTN_TOOL_FINGER		0x145
+#define BTN_TOOL_MOUSE		0x146
+#define BTN_TOOL_LENS		0x147
+#define BTN_TOOL_QUINTTAP	0x148	/* Five fingers on trackpad */
+#define BTN_TOUCH		0x14a
+#define BTN_STYLUS		0x14b
+#define BTN_STYLUS2		0x14c
+#define BTN_TOOL_DOUBLETAP	0x14d
+#define BTN_TOOL_TRIPLETAP	0x14e
+#define BTN_TOOL_QUADTAP	0x14f	/* Four fingers on trackpad */
+
+#define BTN_WHEEL		0x150
+#define BTN_GEAR_DOWN		0x150
+#define BTN_GEAR_UP		0x151
+
+#define KEY_OK			0x160
+#define KEY_SELECT		0x161
+#define KEY_GOTO		0x162
+#define KEY_CLEAR		0x163
+#define KEY_POWER2		0x164
+#define KEY_OPTION		0x165
+#define KEY_INFO		0x166	/* AL OEM Features/Tips/Tutorial */
+#define KEY_TIME		0x167
+#define KEY_VENDOR		0x168
+#define KEY_ARCHIVE		0x169
+#define KEY_PROGRAM		0x16a	/* Media Select Program Guide */
+#define KEY_CHANNEL		0x16b
+#define KEY_FAVORITES		0x16c
+#define KEY_EPG			0x16d
+#define KEY_PVR			0x16e	/* Media Select Home */
+#define KEY_MHP			0x16f
+#define KEY_LANGUAGE		0x170
+#define KEY_TITLE		0x171
+#define KEY_SUBTITLE		0x172
+#define KEY_ANGLE		0x173
+#define KEY_ZOOM		0x174
+#define KEY_MODE		0x175
+#define KEY_KEYBOARD		0x176
+#define KEY_SCREEN		0x177
+#define KEY_PC			0x178	/* Media Select Computer */
+#define KEY_TV			0x179	/* Media Select TV */
+#define KEY_TV2			0x17a	/* Media Select Cable */
+#define KEY_VCR			0x17b	/* Media Select VCR */
+#define KEY_VCR2		0x17c	/* VCR Plus */
+#define KEY_SAT			0x17d	/* Media Select Satellite */
+#define KEY_SAT2		0x17e
+#define KEY_CD			0x17f	/* Media Select CD */
+#define KEY_TAPE		0x180	/* Media Select Tape */
+#define KEY_RADIO		0x181
+#define KEY_TUNER		0x182	/* Media Select Tuner */
+#define KEY_PLAYER		0x183
+#define KEY_TEXT		0x184
+#define KEY_DVD			0x185	/* Media Select DVD */
+#define KEY_AUX			0x186
+#define KEY_MP3			0x187
+#define KEY_AUDIO		0x188	/* AL Audio Browser */
+#define KEY_VIDEO		0x189	/* AL Movie Browser */
+#define KEY_DIRECTORY		0x18a
+#define KEY_LIST		0x18b
+#define KEY_MEMO		0x18c	/* Media Select Messages */
+#define KEY_CALENDAR		0x18d
+#define KEY_RED			0x18e
+#define KEY_GREEN		0x18f
+#define KEY_YELLOW		0x190
+#define KEY_BLUE		0x191
+#define KEY_CHANNELUP		0x192	/* Channel Increment */
+#define KEY_CHANNELDOWN		0x193	/* Channel Decrement */
+#define KEY_FIRST		0x194
+#define KEY_LAST		0x195	/* Recall Last */
+#define KEY_AB			0x196
+#define KEY_NEXT		0x197
+#define KEY_RESTART		0x198
+#define KEY_SLOW		0x199
+#define KEY_SHUFFLE		0x19a
+#define KEY_BREAK		0x19b
+#define KEY_PREVIOUS		0x19c
+#define KEY_DIGITS		0x19d
+#define KEY_TEEN		0x19e
+#define KEY_TWEN		0x19f
+#define KEY_VIDEOPHONE		0x1a0	/* Media Select Video Phone */
+#define KEY_GAMES		0x1a1	/* Media Select Games */
+#define KEY_ZOOMIN		0x1a2	/* AC Zoom In */
+#define KEY_ZOOMOUT		0x1a3	/* AC Zoom Out */
+#define KEY_ZOOMRESET		0x1a4	/* AC Zoom */
+#define KEY_WORDPROCESSOR	0x1a5	/* AL Word Processor */
+#define KEY_EDITOR		0x1a6	/* AL Text Editor */
+#define KEY_SPREADSHEET		0x1a7	/* AL Spreadsheet */
+#define KEY_GRAPHICSEDITOR	0x1a8	/* AL Graphics Editor */
+#define KEY_PRESENTATION	0x1a9	/* AL Presentation App */
+#define KEY_DATABASE		0x1aa	/* AL Database App */
+#define KEY_NEWS		0x1ab	/* AL Newsreader */
+#define KEY_VOICEMAIL		0x1ac	/* AL Voicemail */
+#define KEY_ADDRESSBOOK		0x1ad	/* AL Contacts/Address Book */
+#define KEY_MESSENGER		0x1ae	/* AL Instant Messaging */
+#define KEY_DISPLAYTOGGLE	0x1af	/* Turn display (LCD) on and off */
+#define KEY_SPELLCHECK		0x1b0   /* AL Spell Check */
+#define KEY_LOGOFF		0x1b1   /* AL Logoff */
+
+#define KEY_DOLLAR		0x1b2
+#define KEY_EURO		0x1b3
+
+#define KEY_FRAMEBACK		0x1b4	/* Consumer - transport controls */
+#define KEY_FRAMEFORWARD	0x1b5
+#define KEY_CONTEXT_MENU	0x1b6	/* GenDesc - system context menu */
+#define KEY_MEDIA_REPEAT	0x1b7	/* Consumer - transport control */
+#define KEY_10CHANNELSUP	0x1b8	/* 10 channels up (10+) */
+#define KEY_10CHANNELSDOWN	0x1b9	/* 10 channels down (10-) */
+#define KEY_IMAGES		0x1ba	/* AL Image Browser */
+
+#define KEY_DEL_EOL		0x1c0
+#define KEY_DEL_EOS		0x1c1
+#define KEY_INS_LINE		0x1c2
+#define KEY_DEL_LINE		0x1c3
+
+#define KEY_FN			0x1d0
+#define KEY_FN_ESC		0x1d1
+#define KEY_FN_F1		0x1d2
+#define KEY_FN_F2		0x1d3
+#define KEY_FN_F3		0x1d4
+#define KEY_FN_F4		0x1d5
+#define KEY_FN_F5		0x1d6
+#define KEY_FN_F6		0x1d7
+#define KEY_FN_F7		0x1d8
+#define KEY_FN_F8		0x1d9
+#define KEY_FN_F9		0x1da
+#define KEY_FN_F10		0x1db
+#define KEY_FN_F11		0x1dc
+#define KEY_FN_F12		0x1dd
+#define KEY_FN_1		0x1de
+#define KEY_FN_2		0x1df
+#define KEY_FN_D		0x1e0
+#define KEY_FN_E		0x1e1
+#define KEY_FN_F		0x1e2
+#define KEY_FN_S		0x1e3
+#define KEY_FN_B		0x1e4
+
+#define KEY_BRL_DOT1		0x1f1
+#define KEY_BRL_DOT2		0x1f2
+#define KEY_BRL_DOT3		0x1f3
+#define KEY_BRL_DOT4		0x1f4
+#define KEY_BRL_DOT5		0x1f5
+#define KEY_BRL_DOT6		0x1f6
+#define KEY_BRL_DOT7		0x1f7
+#define KEY_BRL_DOT8		0x1f8
+#define KEY_BRL_DOT9		0x1f9
+#define KEY_BRL_DOT10		0x1fa
+
+#define KEY_NUMERIC_0		0x200	/* used by phones, remote controls, */
+#define KEY_NUMERIC_1		0x201	/* and other keypads */
+#define KEY_NUMERIC_2		0x202
+#define KEY_NUMERIC_3		0x203
+#define KEY_NUMERIC_4		0x204
+#define KEY_NUMERIC_5		0x205
+#define KEY_NUMERIC_6		0x206
+#define KEY_NUMERIC_7		0x207
+#define KEY_NUMERIC_8		0x208
+#define KEY_NUMERIC_9		0x209
+#define KEY_NUMERIC_STAR	0x20a
+#define KEY_NUMERIC_POUND	0x20b
+
+#define KEY_CAMERA_FOCUS	0x210
+#define KEY_WPS_BUTTON		0x211	/* WiFi Protected Setup key */
+
+#define KEY_TOUCHPAD_TOGGLE	0x212	/* Request switch touchpad on or off */
+#define KEY_TOUCHPAD_ON		0x213
+#define KEY_TOUCHPAD_OFF	0x214
+
+#define KEY_CAMERA_ZOOMIN	0x215
+#define KEY_CAMERA_ZOOMOUT	0x216
+#define KEY_CAMERA_UP		0x217
+#define KEY_CAMERA_DOWN		0x218
+#define KEY_CAMERA_LEFT		0x219
+#define KEY_CAMERA_RIGHT	0x21a
+
+#define KEY_ATTENDANT_ON	0x21b
+#define KEY_ATTENDANT_OFF	0x21c
+#define KEY_ATTENDANT_TOGGLE	0x21d	/* Attendant call on or off */
+#define KEY_LIGHTS_TOGGLE	0x21e	/* Reading light on or off */
+
+#define BTN_DPAD_UP		0x220
+#define BTN_DPAD_DOWN		0x221
+#define BTN_DPAD_LEFT		0x222
+#define BTN_DPAD_RIGHT		0x223
+
+#define MATRIX_KEY(row, col, code)	\
+	((((row) & 0xFF) << 24) | (((col) & 0xFF) << 16) | ((code) & 0xFFFF))
+
+#endif /* _DT_BINDINGS_INPUT_INPUT_H */
-- 
1.7.1.1


^ permalink raw reply related

* Re: [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers
From: Andy Shevchenko @ 2013-08-06 11:43 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, Benjamin Tissoires
In-Reply-To: <1372163081-11394-1-git-send-email-andriy.shevchenko@linux.intel.com>

On Tue, 2013-06-25 at 15:24 +0300, Andy Shevchenko wrote: 
> The vendor and product parameters are defined as __u32, but used as short int.
> Let's do an explicit casting for them.

Jiri, Benjamin, any comment on this?

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/hid/i2c-hid/i2c-hid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> index 879b0ed..d595f2a 100644
> --- a/drivers/hid/i2c-hid/i2c-hid.c
> +++ b/drivers/hid/i2c-hid/i2c-hid.c
> @@ -1009,7 +1009,7 @@ static int i2c_hid_probe(struct i2c_client *client,
>  	hid->product = le16_to_cpu(ihid->hdesc.wProductID);
>  
>  	snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX",
> -		 client->name, hid->vendor, hid->product);
> +		 client->name, (short int)hid->vendor, (short int)hid->product);
>  
>  	ret = hid_add_device(hid);
>  	if (ret) {

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply

* Re: [PATCH 2/2] i2c-hid: remove mostly useless parameter 'debug'
From: Andy Shevchenko @ 2013-08-06  8:02 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, Mika Westerberg
In-Reply-To: <alpine.LNX.2.00.1308051124240.17512@pobox.suse.cz>

On Mon, 2013-08-05 at 11:26 +0200, Jiri Kosina wrote: 
> On Fri, 2 Aug 2013, Benjamin Tissoires wrote:
> 
> > > With only one condition if dynamic debug is enabled in kernel.
> > > So, it would be nice to gather opinions, however, the decision is
> > > totally depends on type of user who wants to debug the module.
> > > 
> > Yep, I agree that Jiri's opinion would be helpful.
> > 
> > Meanwhile, we could also wait a little for more i2c-hid to hit the
> > market and to be widely tested, and then remove the debug flag. We
> > should also remove the debug events in get_i2c_hid_get_input() which
> > would pollute systems without dynamic debugging but with the DEBUG
> > config still enabled.
> 
> Well, it doesn't seem to make too much sense to me to have generic/bus use 
> hid_dbg() (although it's used very rarely) and a "sub-driver" use 
> something else.
> 
> Basically the options I see:
> 
> - keep i2c-hid as is
> - convert the whole drivers/hid to dev_dbg()
> - introduce another hid debugfs file in parallel to rdesc and events for 
>   these types of messages

Debugfs could be off in the kernel configuration. Whatever we choose
there will be a kernel that has a disabled option which prevents to
debug: either debugging is turned off, or driver itself.


There is another possibility as well:
instead of dev_dbg() we may add trace points and subscribe to them from
userspace via perf, for example.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply

* Re: [PATCH 1/2] input: ti_tsc: Enable shared IRQ for TSC
From: Russ Dill @ 2013-08-05 22:42 UTC (permalink / raw)
  To: zubair.lutfullah
  Cc: Dmitry Torokhov, Jonathan Cameron, jic23, linux-iio, linux-kernel,
	linux-input, gregkh
In-Reply-To: <20130805170201.GA4310@gmail.com>

On 08/05/2013 10:02 AM, Zubair Lutfullah : wrote:
> On Mon, Aug 05, 2013 at 09:12:56AM -0700, Dmitry Torokhov wrote:
>>>> Touchscreen and ADC share the same IRQ line from parent MFD core.
>>>> Previously only Touchscreen was interrupt based.
>>>> With continuous mode support added in ADC driver, driver requires
>>>> interrupt to process the ADC samples, so enable shared IRQ flag bit for
>>>> touchscreen.
>>>>
>>>> @@ -260,8 +260,18 @@ static irqreturn_t titsc_irq(int irq, void *dev)
>>>>  	unsigned int fsm;
>>>>  
>>>> +	/*
>>>> +	 * ADC and touchscreen share the IRQ line.
>>>> +	 * FIFO1 threshold, FIFO1 Overrun and FIFO1 underflow
>>>> +	 * interrupts are used by ADC,
>>>> +	 * hence return from touchscreen IRQ handler if FIFO1
>>>> +	 * related interrupts occurred.
>>>> +	 */
>>>> +	if ((status & IRQENB_FIFO1THRES) ||
>>>> +			(status & IRQENB_FIFO1OVRRUN) ||
>>>> +			(status & IRQENB_FIFO1UNDRFLW))
>>>> +		return IRQ_NONE;
>>>> +	else if (status & IRQENB_FIFO0THRES) {
>>
>> What happens if both parts have data at the same time? Can both
>> IRQENB_FIFO1THRES and IRQENB_FIFO0THRES be signalled? What will happen
>> in this case?
> 
> If ADC is sampling and someone is touching the TSC, both interrupts
> can signal so closely that for the purpose of the kernel,
> they can be seen as signaled together.
> 
> FIFO 1 used only by ADC and FIFO1THRES handler is inside the iio/adc driver
> FIFO 0 used only by TSC and FIFO0THRES handler is inside the input/touchscreen
> 
> Note: These are level interrupts.
> 
> I would like some input on how to handle such a situation. 
> 
> Thanks
> Zubair Lutfullah
> 

As far as I know, if there are any bits you can handle and ack, do so
and return IRQ_HANDLED. Otherwise, return IRQ_NONE. If there are still
pending bits, the interrupt will fire again, your handler will be called
again, return IRQ_NONE, and the next handler will be called.

^ permalink raw reply

* Re: [PATCH 1/2] input: ti_tsc: Enable shared IRQ for TSC
From: Zubair Lutfullah : @ 2013-08-05 19:21 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Zubair Lutfullah :, Jonathan Cameron,
	jic23-KWPb1pKIrIJaa/9Udqfwiw, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, Russ.Dill-l0cyMroinI0
In-Reply-To: <20130805174031.GA20093-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>

On Mon, Aug 05, 2013 at 10:40:31AM -0700, Dmitry Torokhov wrote:
> > 
> > FIFO 1 used only by ADC and FIFO1THRES handler is inside the iio/adc driver
> > FIFO 0 used only by TSC and FIFO0THRES handler is inside the input/touchscreen
> > 
> > Note: These are level interrupts.
> > 
> > I would like some input on how to handle such a situation. 
> 
> It looks like you need to have smart demultiplexing in MFD core of your
> driver instead of relying on shared interrupt handler.
> 
> Another option would be to check "your" bits, handle the data, clear the
> status and then check bits again and return IRQ_NONE instead of
> IRQ_HANDLED if other guys bits are set, but it is way too ugly.
> 
> Thanks.
> 
> -- 
> Dmitry

That is going to make a lot of changes in mfd, input and iio
And should require a separate patch series.

Is it possible to accept the current patches to add continuous mode 
to the ADC side as is before the next merge window?

This issue doesn't disturb each side individually..

I'll look into fixing the IRQs after settling continuous mode.

Thanks
Zubair Lutfullah

^ permalink raw reply

* Re: [PATCH 1/2] input: ti_tsc: Enable shared IRQ for TSC
From: Dmitry Torokhov @ 2013-08-05 17:40 UTC (permalink / raw)
  To: Zubair Lutfullah :
  Cc: Jonathan Cameron, jic23, linux-iio, linux-kernel, linux-input,
	gregkh, Russ.Dill
In-Reply-To: <20130805170201.GA4310@gmail.com>

On Mon, Aug 05, 2013 at 06:02:02PM +0100, Zubair Lutfullah : wrote:
> On Mon, Aug 05, 2013 at 09:12:56AM -0700, Dmitry Torokhov wrote:
> > > > Touchscreen and ADC share the same IRQ line from parent MFD core.
> > > > Previously only Touchscreen was interrupt based.
> > > > With continuous mode support added in ADC driver, driver requires
> > > > interrupt to process the ADC samples, so enable shared IRQ flag bit for
> > > > touchscreen.
> > > > 
> > > > @@ -260,8 +260,18 @@ static irqreturn_t titsc_irq(int irq, void *dev)
> > > >  	unsigned int fsm;
> > > >  
> > > > +	/*
> > > > +	 * ADC and touchscreen share the IRQ line.
> > > > +	 * FIFO1 threshold, FIFO1 Overrun and FIFO1 underflow
> > > > +	 * interrupts are used by ADC,
> > > > +	 * hence return from touchscreen IRQ handler if FIFO1
> > > > +	 * related interrupts occurred.
> > > > +	 */
> > > > +	if ((status & IRQENB_FIFO1THRES) ||
> > > > +			(status & IRQENB_FIFO1OVRRUN) ||
> > > > +			(status & IRQENB_FIFO1UNDRFLW))
> > > > +		return IRQ_NONE;
> > > > +	else if (status & IRQENB_FIFO0THRES) {
> > 
> > What happens if both parts have data at the same time? Can both
> > IRQENB_FIFO1THRES and IRQENB_FIFO0THRES be signalled? What will happen
> > in this case?
> 
> If ADC is sampling and someone is touching the TSC, both interrupts
> can signal so closely that for the purpose of the kernel,
> they can be seen as signaled together.
> 
> FIFO 1 used only by ADC and FIFO1THRES handler is inside the iio/adc driver
> FIFO 0 used only by TSC and FIFO0THRES handler is inside the input/touchscreen
> 
> Note: These are level interrupts.
> 
> I would like some input on how to handle such a situation. 

It looks like you need to have smart demultiplexing in MFD core of your
driver instead of relying on shared interrupt handler.

Another option would be to check "your" bits, handle the data, clear the
status and then check bits again and return IRQ_NONE instead of
IRQ_HANDLED if other guys bits are set, but it is way too ugly.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 1/2] input: ti_tsc: Enable shared IRQ for TSC
From: Zubair Lutfullah : @ 2013-08-05 17:02 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jonathan Cameron, Zubair Lutfullah, jic23-KWPb1pKIrIJaa/9Udqfwiw,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, Russ.Dill-l0cyMroinI0
In-Reply-To: <20130805161256.GA8794-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>

On Mon, Aug 05, 2013 at 09:12:56AM -0700, Dmitry Torokhov wrote:
> > > Touchscreen and ADC share the same IRQ line from parent MFD core.
> > > Previously only Touchscreen was interrupt based.
> > > With continuous mode support added in ADC driver, driver requires
> > > interrupt to process the ADC samples, so enable shared IRQ flag bit for
> > > touchscreen.
> > > 
> > > @@ -260,8 +260,18 @@ static irqreturn_t titsc_irq(int irq, void *dev)
> > >  	unsigned int fsm;
> > >  
> > > +	/*
> > > +	 * ADC and touchscreen share the IRQ line.
> > > +	 * FIFO1 threshold, FIFO1 Overrun and FIFO1 underflow
> > > +	 * interrupts are used by ADC,
> > > +	 * hence return from touchscreen IRQ handler if FIFO1
> > > +	 * related interrupts occurred.
> > > +	 */
> > > +	if ((status & IRQENB_FIFO1THRES) ||
> > > +			(status & IRQENB_FIFO1OVRRUN) ||
> > > +			(status & IRQENB_FIFO1UNDRFLW))
> > > +		return IRQ_NONE;
> > > +	else if (status & IRQENB_FIFO0THRES) {
> 
> What happens if both parts have data at the same time? Can both
> IRQENB_FIFO1THRES and IRQENB_FIFO0THRES be signalled? What will happen
> in this case?

If ADC is sampling and someone is touching the TSC, both interrupts
can signal so closely that for the purpose of the kernel,
they can be seen as signaled together.

FIFO 1 used only by ADC and FIFO1THRES handler is inside the iio/adc driver
FIFO 0 used only by TSC and FIFO0THRES handler is inside the input/touchscreen

Note: These are level interrupts.

I would like some input on how to handle such a situation. 

Thanks
Zubair Lutfullah

^ permalink raw reply

* Re: [PATCH 1/2] input: ti_tsc: Enable shared IRQ for TSC
From: Dmitry Torokhov @ 2013-08-05 16:12 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Zubair Lutfullah, jic23, linux-iio, linux-kernel, linux-input,
	gregkh, Russ.Dill
In-Reply-To: <51FE361B.5030900@kernel.org>

On Sun, Aug 04, 2013 at 12:08:11PM +0100, Jonathan Cameron wrote:
> On 07/27/13 00:51, Zubair Lutfullah wrote:
> > From: "Patil, Rachna" <rachna@ti.com>
> > 
> > Touchscreen and ADC share the same IRQ line from parent MFD core.
> > Previously only Touchscreen was interrupt based.
> > With continuous mode support added in ADC driver, driver requires
> > interrupt to process the ADC samples, so enable shared IRQ flag bit for
> > touchscreen.
> > 
> > Signed-off-by: Patil, Rachna <rachna@ti.com>
> > Acked-by: Vaibhav Hiremath <hvaibhav@ti.com>
> > Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com>
> > Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> I'd rather this went via input independent of the other patch
> (if not there all that will happen is one or other driver will
> fail to probe if both are attempted?)
> 
> Can take it through IIO but only with a Dmitry Ack.
> 
> > ---
> >  drivers/input/touchscreen/ti_am335x_tsc.c |   18 ++++++++++++++----
> >  1 file changed, 14 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> > index e1c5300..68d1250 100644
> > --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> > +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> > @@ -260,8 +260,18 @@ static irqreturn_t titsc_irq(int irq, void *dev)
> >  	unsigned int fsm;
> >  
> >  	status = titsc_readl(ts_dev, REG_IRQSTATUS);
> > -	if (status & IRQENB_FIFO0THRES) {
> > -
> > +	/*
> > +	 * ADC and touchscreen share the IRQ line.
> > +	 * FIFO1 threshold, FIFO1 Overrun and FIFO1 underflow
> > +	 * interrupts are used by ADC,
> > +	 * hence return from touchscreen IRQ handler if FIFO1
> > +	 * related interrupts occurred.
> > +	 */
> > +	if ((status & IRQENB_FIFO1THRES) ||
> > +			(status & IRQENB_FIFO1OVRRUN) ||
> > +			(status & IRQENB_FIFO1UNDRFLW))
> > +		return IRQ_NONE;
> > +	else if (status & IRQENB_FIFO0THRES) {

What happens if both parts have data at the same time? Can both
IRQENB_FIFO1THRES and IRQENB_FIFO0THRES be signalled? What will happen
in this case?

Thanks.

-- 
Dmitry

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox