linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] input - leds: fix input_led_disconnect path
From: Benjamin Tissoires @ 2017-12-20 18:42 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Samuel Thibault, Peter Hutterer, linux-input@vger.kernel.org,
	lkml, 3.8+
In-Reply-To: <CAKdAkRS40XySAWRakx27prKu11dfirA+V=C2ksDfiOcJzRee+A@mail.gmail.com>

On Wed, Dec 20, 2017 at 7:20 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Wed, Dec 20, 2017 at 9:11 AM, Benjamin Tissoires
> <benjamin.tissoires@redhat.com> wrote:
>> On Sat, Dec 16, 2017 at 1:48 AM, Dmitry Torokhov
>> <dmitry.torokhov@gmail.com> wrote:
>>> Hi Benjamin,
>>>
>>> On Thu, Dec 14, 2017 at 02:25:22PM +0100, Benjamin Tissoires wrote:
>>>> Before unregistering the led classes, we have to be sure there is no
>>>> more events in the input pipeline.
>>>> Closing the input node before removing the led classes flushes the
>>>> pipeline and this prevents segfaults.
>>>
>>> I do not think this actually the issue. input_leds_event() is an empty
>>> stub, it does not really do anything with events it receives form input
>>> core, and it does not reference the led structures. The way input leds
>>
>> Right. Actually, we could simply drop the stub as input_to_handler()
>> checks for the validity of .event().
>>
>>> work is that input driver owns the hardware led and is responsible for
>>> communicating with it. The LED subsystem is a secondary interface,
>>> requests coming from /sys/class/led/... are being forwarded to the input
>>> core and then to the input hardware driver by the way of:
>>>
>>> input_leds_brightness_set() ->
>>>         input_inject_event() ->
>>>                 input_handle_event()->
>>>                         disposition & INPUT_PASS_TO_DEVICE
>>>                                 dev->event() (in atkbd or hid-input)
>>>                                         actual control of LED
>>>
>>> I do not see how stopping event flow from input core to input-leds would
>>> help here.
>>
>> I wonder if this solution in this patch is not just masking the race
>> condition by forcing the sync.
>>
>> After further researches, I realized that the patch is actually not
>> needed. In the upstream repo of Peter, the code inject events and
>> closes the device ASAP, triggering races with udev.
>> Adding the proper udev stubs seem to solve the issues.
>> I still have other random crashes, but I can't seem to reproduce the
>> error of https://bugzilla.kernel.org/show_bug.cgi?id=197679 now.
>>
>> Anyway, I can't explain the backtrace of the kernel bug, it is as if
>> we are calling the unregister function without having properly
>> registered the device. But this can not happen because of the mutexes
>> in place.
>> The race seems to be udev and probably the led class accesses...
>
> I wonder if the crash was observed only with your first patch adding
> the delay in initializing the leds?

Nah, the bug was initially found by Peter on a plain Fedora system
without my crap :)

>
>>
>> BTW, if the handler doesn't use the events coming in from the input
>> subsystem, is there any benefits of opening the device from the
>> handler?
>> I tried without, and it seemed to be working fine, but I wonder if
>> there is no hidden dependency I haven't see.
>
> You want to open the device as it is what essentially powers it up, so
> that it can react to input_inject_event() sent via LED subsystem. In
> case of atkbd input_open_device() will result in call to serio_open()
> which enables the KBD port of i8042. You probably do not see any
> difference because the VT subsystem already attached the keyboard
> handler to the device and it already "opened" the device in question.
>

Right. So I guess there is not much to do then :)

Cheers,
Benjamin

^ permalink raw reply

* Re: [PATCH v2] Input: mms114 - add support for mms152
From: Dmitry Torokhov @ 2017-12-20 18:34 UTC (permalink / raw)
  To: Simon Shields; +Cc: linux-input@vger.kernel.org, devicetree, Andi Shyti
In-Reply-To: <20171220153810.1961-1-simon@lineageos.org>

[resending as plain text]

Hi Simon,

On Wed, Dec 20, 2017 at 9:38 AM, Simon Shields <simon@lineageos.org> wrote:
> MMS152 has no configuration registers, but the packet format used in
> interrupts is identical to mms114.

Since there seems to be renewed interest in mms114 driver, I would like for
it to get a facelift and switch to using the standard touchscreen
properties rather than the custom ones (we still need to keep compatibility
though). Also, we do not seem to have any in-tree users of the
mms114_platform_data structure. Can you please see if you  can:

- switch the driver to use the generic device properties
(device_property_*() API)
- use touchscreen_parse_properties() to parse the standard touchscreen
properties
- use touchscreen_report_pos() to report coordinates
- drop mms114_platform_data

Thanks!

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] touchscreen: mms114: add support for mms152
From: Rob Herring @ 2017-12-20 18:21 UTC (permalink / raw)
  To: Simon Shields
  Cc: Dmitry Torokhov, linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20171218124933.1803-1-simon-WP75azK+jQYgsBAKwltoeQ@public.gmane.org>

On Mon, Dec 18, 2017 at 11:49:33PM +1100, Simon Shields wrote:
> MMS152 has no configuration registers, but the packet format used in
> interrupts is identical to mms114.
> 
> Signed-off-by: Simon Shields <simon-WP75azK+jQYgsBAKwltoeQ@public.gmane.org>
> ---
>  .../bindings/input/touchscreen/mms114.txt          |  8 ++--
>  drivers/input/touchscreen/mms114.c                 | 55 +++++++++++++++++++---
>  include/linux/platform_data/mms114.h               |  6 +++
>  3 files changed, 58 insertions(+), 11 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt
> index 89d4c56c5671..733411020ced 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt
> @@ -1,15 +1,15 @@
> -* MELFAS MMS114 touchscreen controller
> +* MELFAS MMS114/MMS152 touchscreen controller
>  
>  Required properties:
> -- compatible: must be "melfas,mms114"
> +- compatible: "melfas,mms114" for MMS114, or "melfas,mms152" for MMS152

Please reformat to 1 per line.

>  - reg: I2C address of the chip
>  - interrupts: interrupt to which the chip is connected
>  - x-size: horizontal resolution of touchscreen
>  - y-size: vertical resolution of touchscreen
>  
>  Optional properties:
> -- contact-threshold:
> -- moving-threshold:
> +- contact-threshold: only with "melfas,mms114"
> +- moving-threshold: only with "melfas,mms114"
>  - x-invert: invert X axis
>  - y-invert: invert Y axis
>  
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 2/2] input - leds: fix input_led_disconnect path
From: Dmitry Torokhov @ 2017-12-20 18:20 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Samuel Thibault, Peter Hutterer, linux-input@vger.kernel.org,
	lkml, 3.8+
In-Reply-To: <CAO-hwJK1j6Kx=dT1uYi0DicuuU3qSLg7buoyGq2mqZStFG6Qkg@mail.gmail.com>

On Wed, Dec 20, 2017 at 9:11 AM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> On Sat, Dec 16, 2017 at 1:48 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>> Hi Benjamin,
>>
>> On Thu, Dec 14, 2017 at 02:25:22PM +0100, Benjamin Tissoires wrote:
>>> Before unregistering the led classes, we have to be sure there is no
>>> more events in the input pipeline.
>>> Closing the input node before removing the led classes flushes the
>>> pipeline and this prevents segfaults.
>>
>> I do not think this actually the issue. input_leds_event() is an empty
>> stub, it does not really do anything with events it receives form input
>> core, and it does not reference the led structures. The way input leds
>
> Right. Actually, we could simply drop the stub as input_to_handler()
> checks for the validity of .event().
>
>> work is that input driver owns the hardware led and is responsible for
>> communicating with it. The LED subsystem is a secondary interface,
>> requests coming from /sys/class/led/... are being forwarded to the input
>> core and then to the input hardware driver by the way of:
>>
>> input_leds_brightness_set() ->
>>         input_inject_event() ->
>>                 input_handle_event()->
>>                         disposition & INPUT_PASS_TO_DEVICE
>>                                 dev->event() (in atkbd or hid-input)
>>                                         actual control of LED
>>
>> I do not see how stopping event flow from input core to input-leds would
>> help here.
>
> I wonder if this solution in this patch is not just masking the race
> condition by forcing the sync.
>
> After further researches, I realized that the patch is actually not
> needed. In the upstream repo of Peter, the code inject events and
> closes the device ASAP, triggering races with udev.
> Adding the proper udev stubs seem to solve the issues.
> I still have other random crashes, but I can't seem to reproduce the
> error of https://bugzilla.kernel.org/show_bug.cgi?id=197679 now.
>
> Anyway, I can't explain the backtrace of the kernel bug, it is as if
> we are calling the unregister function without having properly
> registered the device. But this can not happen because of the mutexes
> in place.
> The race seems to be udev and probably the led class accesses...

I wonder if the crash was observed only with your first patch adding
the delay in initializing the leds?

>
> BTW, if the handler doesn't use the events coming in from the input
> subsystem, is there any benefits of opening the device from the
> handler?
> I tried without, and it seemed to be working fine, but I wonder if
> there is no hidden dependency I haven't see.

You want to open the device as it is what essentially powers it up, so
that it can react to input_inject_event() sent via LED subsystem. In
case of atkbd input_open_device() will result in call to serio_open()
which enables the KBD port of i8042. You probably do not see any
difference because the VT subsystem already attached the keyboard
handler to the device and it already "opened" the device in question.

Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH v2] Input: mms114 - add support for mms152
From: Simon Shields @ 2017-12-20 15:38 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, devicetree, Andi Shyti, Simon Shields
In-Reply-To: <20171218124933.1803-1-simon@lineageos.org>

MMS152 has no configuration registers, but the packet format used in
interrupts is identical to mms114.

Signed-off-by: Simon Shields <simon@lineageos.org>
---
 .../bindings/input/touchscreen/mms114.txt          |  8 ++--
 drivers/input/touchscreen/mms114.c                 | 53 +++++++++++++++++++---
 include/linux/platform_data/mms114.h               |  6 +++
 3 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt
index 89d4c56c5671..733411020ced 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt
@@ -1,15 +1,15 @@
-* MELFAS MMS114 touchscreen controller
+* MELFAS MMS114/MMS152 touchscreen controller
 
 Required properties:
-- compatible: must be "melfas,mms114"
+- compatible: "melfas,mms114" for MMS114, or "melfas,mms152" for MMS152
 - reg: I2C address of the chip
 - interrupts: interrupt to which the chip is connected
 - x-size: horizontal resolution of touchscreen
 - y-size: vertical resolution of touchscreen
 
 Optional properties:
-- contact-threshold:
-- moving-threshold:
+- contact-threshold: only with "melfas,mms114"
+- moving-threshold: only with "melfas,mms114"
 - x-invert: invert X axis
 - y-invert: invert Y axis
 
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index e5eeb6311f7d..9ecda193802b 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/i2c.h>
 #include <linux/input/mt.h>
 #include <linux/interrupt.h>
@@ -33,6 +34,9 @@
 #define MMS114_INFOMATION		0x10
 #define MMS114_TSP_REV			0xF0
 
+#define MMS152_FW_REV			0xE1
+#define MMS152_COMPAT_GROUP		0xF2
+
 /* Minimum delay time is 50us between stop and start signal of i2c */
 #define MMS114_I2C_DELAY		50
 
@@ -251,12 +255,27 @@ static int mms114_get_version(struct mms114_data *data)
 	u8 buf[6];
 	int error;
 
-	error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf);
-	if (error < 0)
-		return error;
+	switch (data->pdata->type) {
+	case TYPE_MMS152:
+		error = __mms114_read_reg(data, MMS152_FW_REV, 3, buf);
+		if (error < 0)
+			return error;
+		buf[3] = i2c_smbus_read_byte_data(data->client,
+			MMS152_COMPAT_GROUP);
+		if (buf[3] < 0)
+			return buf[3];
+		dev_info(dev, "TSP FW Rev: bootloader 0x%x / core 0x%x / config 0x%x, Compat group: %c\n",
+				buf[0], buf[1], buf[2], buf[3]);
+		break;
+	case TYPE_MMS114:
+		error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf);
+		if (error < 0)
+			return error;
 
-	dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n",
-		 buf[0], buf[1], buf[3]);
+		dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n",
+			 buf[0], buf[1], buf[3]);
+		break;
+	}
 
 	return 0;
 }
@@ -271,6 +290,10 @@ static int mms114_setup_regs(struct mms114_data *data)
 	if (error < 0)
 		return error;
 
+	/* MMS152 has no configuration or power on registers */
+	if (data->pdata->type == TYPE_MMS152)
+		return 0;
+
 	error = mms114_set_active(data, true);
 	if (error < 0)
 		return error;
@@ -391,6 +414,8 @@ static struct mms114_platform_data *mms114_parse_dt(struct device *dev)
 		return NULL;
 	}
 
+	pdata->type = (enum mms_type)of_device_get_match_data(dev);
+
 	if (of_property_read_u32(np, "x-size", &pdata->x_size)) {
 		dev_err(dev, "failed to get x-size property\n");
 		return NULL;
@@ -456,7 +481,15 @@ static int mms114_probe(struct i2c_client *client,
 	data->input_dev = input_dev;
 	data->pdata = pdata;
 
-	input_dev->name = "MELFAS MMS114 Touchscreen";
+	switch (pdata->type) {
+	case TYPE_MMS114:
+		input_dev->name = "MELFAS MMS114 Touchscreen";
+		break;
+	case TYPE_MMS152:
+		input_dev->name = "MELFAS MMS152 Touchscreen";
+		break;
+	}
+
 	input_dev->id.bustype = BUS_I2C;
 	input_dev->dev.parent = &client->dev;
 	input_dev->open = mms114_input_open;
@@ -569,7 +602,13 @@ MODULE_DEVICE_TABLE(i2c, mms114_id);
 
 #ifdef CONFIG_OF
 static const struct of_device_id mms114_dt_match[] = {
-	{ .compatible = "melfas,mms114" },
+	{
+		.compatible = "melfas,mms114",
+		.data = (void *)TYPE_MMS114,
+	}, {
+		.compatible = "melfas,mms152",
+		.data = (void *)TYPE_MMS152,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, mms114_dt_match);
diff --git a/include/linux/platform_data/mms114.h b/include/linux/platform_data/mms114.h
index 5722ebfb2738..58e4c463bf0c 100644
--- a/include/linux/platform_data/mms114.h
+++ b/include/linux/platform_data/mms114.h
@@ -10,6 +10,11 @@
 #ifndef __LINUX_MMS114_H
 #define __LINUX_MMS114_H
 
+enum mms_type {
+	TYPE_MMS114,
+	TYPE_MMS152,
+};
+
 struct mms114_platform_data {
 	unsigned int x_size;
 	unsigned int y_size;
@@ -17,6 +22,7 @@ struct mms114_platform_data {
 	unsigned int moving_threshold;
 	bool x_invert;
 	bool y_invert;
+	enum mms_type type;
 
 	void (*cfg_pin)(bool);
 };
-- 
2.15.1


^ permalink raw reply related

* Re: [PATCH 2/2] input - leds: fix input_led_disconnect path
From: Benjamin Tissoires @ 2017-12-20 15:11 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Samuel Thibault, Peter Hutterer, linux-input, linux-kernel,
	stable
In-Reply-To: <20171216004846.3blocf4u45adwalh@dtor-ws>

On Sat, Dec 16, 2017 at 1:48 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Benjamin,
>
> On Thu, Dec 14, 2017 at 02:25:22PM +0100, Benjamin Tissoires wrote:
>> Before unregistering the led classes, we have to be sure there is no
>> more events in the input pipeline.
>> Closing the input node before removing the led classes flushes the
>> pipeline and this prevents segfaults.
>
> I do not think this actually the issue. input_leds_event() is an empty
> stub, it does not really do anything with events it receives form input
> core, and it does not reference the led structures. The way input leds

Right. Actually, we could simply drop the stub as input_to_handler()
checks for the validity of .event().

> work is that input driver owns the hardware led and is responsible for
> communicating with it. The LED subsystem is a secondary interface,
> requests coming from /sys/class/led/... are being forwarded to the input
> core and then to the input hardware driver by the way of:
>
> input_leds_brightness_set() ->
>         input_inject_event() ->
>                 input_handle_event()->
>                         disposition & INPUT_PASS_TO_DEVICE
>                                 dev->event() (in atkbd or hid-input)
>                                         actual control of LED
>
> I do not see how stopping event flow from input core to input-leds would
> help here.

I wonder if this solution in this patch is not just masking the race
condition by forcing the sync.

After further researches, I realized that the patch is actually not
needed. In the upstream repo of Peter, the code inject events and
closes the device ASAP, triggering races with udev.
Adding the proper udev stubs seem to solve the issues.
I still have other random crashes, but I can't seem to reproduce the
error of https://bugzilla.kernel.org/show_bug.cgi?id=197679 now.

Anyway, I can't explain the backtrace of the kernel bug, it is as if
we are calling the unregister function without having properly
registered the device. But this can not happen because of the mutexes
in place.
The race seems to be udev and probably the led class accesses...

BTW, if the handler doesn't use the events coming in from the input
subsystem, is there any benefits of opening the device from the
handler?
I tried without, and it seemed to be working fine, but I wonder if
there is no hidden dependency I haven't see.

Cheers,
Benjamin

^ permalink raw reply

* [PATCH v5 2/2] dt-bindings: input: Add documentation for cyttsp5
From: Mylène Josserand @ 2017-12-20 10:08 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland
  Cc: mylene.josserand, thomas.petazzoni, maxime.ripard, linux-kernel,
	linux-input, devicetree
In-Reply-To: <20171220100843.2759-1-mylene.josserand@free-electrons.com>

Add the Cypress TrueTouch Generation 5 touchscreen device tree bindings
documentation. It can use I2C or SPI bus.
This touchscreen can handle some defined zone that are designed and
sent as button. To be able to customize the keycode sent, the
"linux,keycodes" property can be used.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
---
 .../bindings/input/touchscreen/cypress,cyttsp5.txt | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cypress,cyttsp5.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/cypress,cyttsp5.txt b/Documentation/devicetree/bindings/input/touchscreen/cypress,cyttsp5.txt
new file mode 100644
index 000000000000..1e0e90e322c7
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/cypress,cyttsp5.txt
@@ -0,0 +1,39 @@
+* Cypress cyttsp touchscreen controller, generation 5
+
+Required properties:
+ - compatible		: must be "cypress,cyttsp5"
+ - reg			: Device I2C address or SPI chip select number
+ - interrupt-parent	: the phandle for the gpio controller
+			  (see interrupt binding[0]).
+ - interrupts		: (gpio) interrupt to which the chip is connected
+			  (see interrupt binding[0]).
+
+Optional properties:
+ - reset-gpios		: the reset gpio the chip is connected to
+			  (see GPIO binding[1] for more details).
+Some other touchscreen optional properties can be defined such as
+"touchscreen-size-x". See ./touchscreen.txt[2] for more details.
+
+This touchscreen can handle some buttons that are touchscreen's defined zones.
+Each button's event can be customized using a property:
+	- linux,keycodes: List of keycode to emit.
+
+[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+[1]: Documentation/devicetree/bindings/gpio/gpio.txt
+[2]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
+
+Example:
+&i2c0 {
+	[...]
+
+	touchscreen@24 {
+		compatible = "cypress,cyttsp5";
+		reg = <0x24>;
+
+		interrupt-parent = <&pio>;
+		interrupts = <1 5 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>;
+		touchscreen-swapped-x-y;
+		linux,keycodes = <KEY_HOMEPAGE>, <KEY_MENU>, <KEY_BACK>;
+	};
+};
-- 
2.11.0

^ permalink raw reply related

* [PATCH v5 1/2] Input: Add driver for Cypress Generation 5 touchscreen
From: Mylène Josserand @ 2017-12-20 10:08 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8
  Cc: mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20171220100843.2759-1-mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

This is the basic driver for the Cypress TrueTouch Gen5 touchscreen
controllers. This driver supports only the I2C bus but it uses regmap
so SPI support could be added later.
The touchscreen can retrieve some defined zone that are handled as
buttons (according to the hardware). That is why it handles
button and multitouch events.

Reviewed-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Signed-off-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 drivers/input/touchscreen/Kconfig   |   16 +
 drivers/input/touchscreen/Makefile  |    1 +
 drivers/input/touchscreen/cyttsp5.c | 1112 +++++++++++++++++++++++++++++++++++
 3 files changed, 1129 insertions(+)
 create mode 100644 drivers/input/touchscreen/cyttsp5.c

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0cfdb7cb610e..28eea6d5f1bb 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -238,6 +238,22 @@ config TOUCHSCREEN_CYTTSP4_SPI
 	  To compile this driver as a module, choose M here: the
 	  module will be called cyttsp4_spi.
 
+config TOUCHSCREEN_CYTTSP5
+	tristate "Cypress TrueTouch Gen5 Touchscreen Driver"
+	depends on OF
+	select REGMAP_I2C
+	select CRC_ITU_T
+	help
+	  Driver for Parade TrueTouch Standard Product
+	  Generation 5 touchscreen controllers.
+	  I2C bus interface support only.
+
+	  Say Y here if you have a Cypress Gen5 touchscreen.
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cyttsp5.
+
 config TOUCHSCREEN_DA9034
 	tristate "Touchscreen support for Dialog Semiconductor DA9034"
 	depends on PMIC_DA903X
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index d2a2b3b7af27..e7d124901dd9 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI)	+= cyttsp_spi.o
 obj-$(CONFIG_TOUCHSCREEN_CYTTSP4_CORE)	+= cyttsp4_core.o
 obj-$(CONFIG_TOUCHSCREEN_CYTTSP4_I2C)	+= cyttsp4_i2c.o cyttsp_i2c_common.o
 obj-$(CONFIG_TOUCHSCREEN_CYTTSP4_SPI)	+= cyttsp4_spi.o
+obj-$(CONFIG_TOUCHSCREEN_CYTTSP5)	+= cyttsp5.o
 obj-$(CONFIG_TOUCHSCREEN_DA9034)	+= da9034-ts.o
 obj-$(CONFIG_TOUCHSCREEN_DA9052)	+= da9052_tsi.o
 obj-$(CONFIG_TOUCHSCREEN_DYNAPRO)	+= dynapro.o
diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c
new file mode 100644
index 000000000000..f059dc41e7ad
--- /dev/null
+++ b/drivers/input/touchscreen/cyttsp5.c
@@ -0,0 +1,1112 @@
+/*
+ * Parade TrueTouch(TM) Standard Product V5 Module.
+ * For use with Parade touchscreen controllers.
+ *
+ * Copyright (C) 2015 Parade Technologies
+ * Copyright (C) 2012-2015 Cypress Semiconductor
+ * Copyright (C) 2017 Free Electrons
+ *
+ * Author: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, and only version 2, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <asm/unaligned.h>
+#include <linux/crc-itu-t.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/gpio.h>
+#include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+#define CYTTSP5_NAME				"cyttsp5"
+#define CY_I2C_DATA_SIZE			(2 * 256)
+#define HID_VERSION				0x0100
+#define CY_MAX_INPUT				512
+#define CYTTSP5_PREALLOCATED_CMD_BUFFER	32
+#define CY_BITS_PER_BTN			1
+#define CY_NUM_BTN_EVENT_ID			((1 << CY_BITS_PER_BTN) - 1)
+
+#define MAX_AREA				255
+#define HID_OUTPUT_BL_SOP			0x1
+#define HID_OUTPUT_BL_EOP			0x17
+#define HID_OUTPUT_BL_LAUNCH_APP		0x3B
+#define HID_OUTPUT_BL_LAUNCH_APP_SIZE		11
+#define HID_OUTPUT_GET_SYSINFO			0x2
+#define HID_OUTPUT_GET_SYSINFO_SIZE		5
+
+#define HID_DESC_REG				0x1
+#define HID_INPUT_REG				0x3
+#define HID_OUTPUT_REG				0x4
+
+#define REPORT_ID_TOUCH			0x1
+#define REPORT_ID_BTN				0x3
+#define REPORT_SIZE_5				5
+#define REPORT_SIZE_8				8
+#define REPORT_SIZE_16				16
+
+/* Touch reports offsets */
+/* Header offsets */
+#define TOUCH_REPORT_DESC_HDR_CONTACTCOUNT	16
+/* Record offsets */
+#define TOUCH_REPORT_DESC_CONTACTID		8
+#define TOUCH_REPORT_DESC_X			16
+#define TOUCH_REPORT_DESC_Y			32
+#define TOUCH_REPORT_DESC_P			48
+#define TOUCH_REPORT_DESC_MAJ			56
+#define TOUCH_REPORT_DESC_MIN			64
+
+/* HID */
+#define HID_TOUCH_REPORT_ID			0x1
+#define HID_BTN_REPORT_ID			0x3
+#define HID_APP_RESPONSE_REPORT_ID		0x1F
+#define HID_APP_OUTPUT_REPORT_ID		0x2F
+#define HID_BL_RESPONSE_REPORT_ID		0x30
+#define HID_BL_OUTPUT_REPORT_ID		0x40
+
+#define HID_OUTPUT_RESPONSE_REPORT_OFFSET	2
+#define HID_OUTPUT_RESPONSE_CMD_OFFSET		4
+#define HID_OUTPUT_RESPONSE_CMD_MASK		0x7F
+
+#define HID_SYSINFO_SENSING_OFFSET		33
+#define HID_SYSINFO_BTN_OFFSET			48
+#define HID_SYSINFO_BTN_MASK			0xFF
+#define HID_SYSINFO_MAX_BTN			8
+
+/*  Timeout in ms */
+#define CY_HID_OUTPUT_TIMEOUT			200
+#define CY_HID_OUTPUT_GET_SYSINFO_TIMEOUT	3000
+#define CY_HID_GET_HID_DESCRIPTOR_TIMEOUT	4000
+
+/* maximum number of concurrent tracks */
+#define TOUCH_REPORT_SIZE			10
+#define TOUCH_INPUT_HEADER_SIZE		7
+#define BTN_REPORT_SIZE			9
+#define BTN_INPUT_HEADER_SIZE			5
+
+/* All usage pages for Touch Report */
+#define TOUCH_REPORT_USAGE_PG_X		0x00010030
+#define TOUCH_REPORT_USAGE_PG_Y		0x00010031
+#define TOUCH_REPORT_USAGE_PG_P		0x000D0030
+#define TOUCH_REPORT_USAGE_PG_CONTACTID	0x000D0051
+#define TOUCH_REPORT_USAGE_PG_CONTACTCOUNT	0x000D0054
+#define TOUCH_REPORT_USAGE_PG_MAJ		0xFF010062
+#define TOUCH_REPORT_USAGE_PG_MIN		0xFF010063
+#define TOUCH_COL_USAGE_PG			0x000D0022
+
+/* helpers */
+#define HI_BYTE(x)				(u8)(((x) >> 8) & 0xFF)
+#define LOW_BYTE(x)				(u8)((x) & 0xFF)
+
+/* System Information interface definitions */
+struct cyttsp5_sensing_conf_data_dev {
+	u8 electrodes_x;
+	u8 electrodes_y;
+	__le16 len_x;
+	__le16 len_y;
+	__le16 res_x;
+	__le16 res_y;
+	__le16 max_z;
+	u8 origin_x;
+	u8 origin_y;
+	u8 btn;
+	u8 scan_mode;
+	u8 max_num_of_tch_per_refresh_cycle;
+} __packed;
+
+struct cyttsp5_sensing_conf_data {
+	u16 res_x;
+	u16 res_y;
+	u16 max_z;
+	u16 len_x;
+	u16 len_y;
+	u8 origin_x;
+	u8 origin_y;
+	u8 max_tch;
+};
+
+enum hid_cmd_state {
+	HID_CMD_DONE,
+	HID_CMD_BUSY,
+};
+
+enum cyttsp5_tch_abs {	/* for ordering within the extracted touch data array */
+	CY_TCH_X,	/* X */
+	CY_TCH_Y,	/* Y */
+	CY_TCH_P,	/* P (Z) */
+	CY_TCH_T,	/* TOUCH ID */
+	CY_TCH_MAJ,	/* TOUCH_MAJOR */
+	CY_TCH_MIN,	/* TOUCH_MINOR */
+	CY_TCH_NUM_ABS,
+};
+
+struct cyttsp5_tch_abs_params {
+	size_t ofs;	/* abs byte offset */
+	size_t size;	/* size in bits */
+	size_t min;	/* min value */
+	size_t max;	/* max value */
+	size_t bofs;	/* bit offset */
+};
+
+struct cyttsp5_touch {
+	int hdr;
+	int abs[CY_TCH_NUM_ABS];
+};
+
+struct cyttsp5_sysinfo {
+	struct cyttsp5_sensing_conf_data sensing_conf_data;
+	int num_btns;
+	struct cyttsp5_tch_abs_params tch_hdr;
+	struct cyttsp5_tch_abs_params tch_abs[CY_TCH_NUM_ABS];
+	u32 key_code[HID_SYSINFO_MAX_BTN];
+	u8 *xy_mode;
+	u8 *xy_data;
+};
+
+struct cyttsp5_hid_desc {
+	__le16 hid_desc_len;
+	u8 packet_id;
+	u8 reserved_byte;
+	__le16 bcd_version;
+	__le16 report_desc_len;
+	__le16 report_desc_register;
+	__le16 input_register;
+	__le16 max_input_len;
+	__le16 output_register;
+	__le16 max_output_len;
+	__le16 command_register;
+	__le16 data_register;
+	__le16 vendor_id;
+	__le16 product_id;
+	__le16 version_id;
+	u8 reserved[4];
+} __packed;
+
+struct cyttsp5 {
+	struct device *dev;
+	struct mutex system_lock;
+	wait_queue_head_t wait_q;
+	struct cyttsp5_sysinfo sysinfo;
+	int hid_cmd_state;
+	struct cyttsp5_hid_desc hid_desc;
+	u8 cmd_buf[CYTTSP5_PREALLOCATED_CMD_BUFFER];
+	u8 input_buf[CY_MAX_INPUT];
+	u8 response_buf[CY_MAX_INPUT];
+	struct gpio_desc *reset_gpio;
+	struct input_dev *input;
+	char phys[NAME_MAX];
+	int num_prv_rec;
+	struct regmap *regmap;
+};
+
+/*
+ * For what understood in the datasheet, the register does not
+ * matter. For consistency, used the Input Register address
+ * but it does mean anything to the device. The important data
+ * to send is the I2C address
+ */
+static int cyttsp5_read(struct cyttsp5 *ts, u8 *buf, u32 max)
+{
+	int rc;
+	u32 size;
+	u8 temp[2];
+
+	if (!buf)
+		return -EINVAL;
+
+	/* Read the frame to retrieve the size */
+	rc = regmap_bulk_read(ts->regmap, HID_INPUT_REG, temp, 2);
+	if (rc < 0)
+		return rc;
+
+	size = get_unaligned_le16(temp);
+	if (!size || size == 2)
+		return 0;
+
+	if (size > max)
+		return -EINVAL;
+
+	/* Get the real value */
+	return regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, size);
+}
+
+static int cyttsp5_write(struct cyttsp5 *ts, unsigned int reg, u8 *data,
+			 size_t size)
+{
+	u8 cmd[size + 1];
+
+	/* High bytes of register address needed as first byte of cmd */
+	cmd[0] = HI_BYTE(reg);
+
+	/* Copy the rest of the data */
+	if (data)
+		memcpy(&cmd[1], data, size);
+
+	/* The hardware wants to receive a frame with the address register
+	 * contains in the first two bytes. As the regmap_write function
+	 * add the register adresse in the frame, we use the LOW_BYTE as
+	 * first frame byte for the address register and the first
+	 * data byte is the high register + left of the cmd to send
+	 */
+	return regmap_bulk_write(ts->regmap, LOW_BYTE(reg), cmd, size + 1);
+}
+
+static void cyttsp5_final_sync(struct input_dev *input, int max_slots,
+			       unsigned long *ids)
+{
+	int t;
+
+	for (t = 0; t < max_slots; t++) {
+		if (test_bit(t, ids))
+			continue;
+		input_mt_slot(input, t);
+		input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
+	}
+
+	input_sync(input);
+}
+
+static void cyttsp5_report_slot_liftoff(struct cyttsp5 *ts, int max_slots)
+{
+	int t;
+
+	if (ts->num_prv_rec == 0)
+		return;
+
+	for (t = 0; t < max_slots; t++) {
+		input_mt_slot(ts->input, t);
+		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
+	}
+}
+
+static void cyttsp5_mt_lift_all(struct cyttsp5 *ts)
+{
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int max = si->tch_abs[CY_TCH_T].max;
+
+	if (ts->num_prv_rec != 0) {
+		cyttsp5_report_slot_liftoff(ts, max);
+		input_sync(ts->input);
+		ts->num_prv_rec = 0;
+	}
+}
+
+static void cyttsp5_get_touch_axis(int *axis, int size, int max, u8 *xy_data,
+				   int bofs)
+{
+	int nbyte;
+	int next;
+
+	for (nbyte = 0, *axis = 0, next = 0; nbyte < size; nbyte++)
+		*axis = *axis + ((xy_data[nbyte] >> bofs) << (nbyte * 8));
+
+	*axis &= max - 1;
+}
+
+static void cyttsp5_get_touch_record(struct cyttsp5 *ts,
+				     struct cyttsp5_touch *touch, u8 *xy_data)
+{
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	enum cyttsp5_tch_abs abs;
+
+	for (abs = CY_TCH_X; abs < CY_TCH_NUM_ABS; abs++) {
+		cyttsp5_get_touch_axis(&touch->abs[abs],
+				       si->tch_abs[abs].size,
+				       si->tch_abs[abs].max,
+				       xy_data + si->tch_abs[abs].ofs,
+				       si->tch_abs[abs].bofs);
+	}
+}
+
+static void cyttsp5_get_mt_touches(struct cyttsp5 *ts,
+				   struct cyttsp5_touch *tch, int num_cur_tch)
+{
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int i, t = 0;
+	DECLARE_BITMAP(ids, si->tch_abs[CY_TCH_T].max);
+	u8 *tch_addr;
+	int tmp;
+
+	bitmap_zero(ids, si->tch_abs[CY_TCH_T].max);
+	memset(tch->abs, 0, sizeof(tch->abs));
+
+	for (i = 0; i < num_cur_tch; i++) {
+		tch_addr = si->xy_data + (i * TOUCH_REPORT_SIZE);
+		cyttsp5_get_touch_record(ts, tch, tch_addr);
+
+		/* Convert MAJOR/MINOR from mm to resolution */
+		tmp = tch->abs[CY_TCH_MAJ] * 100 * si->sensing_conf_data.res_x;
+		tch->abs[CY_TCH_MAJ] = tmp / si->sensing_conf_data.len_x;
+		tmp = tch->abs[CY_TCH_MIN] * 100 * si->sensing_conf_data.res_x;
+		tch->abs[CY_TCH_MIN] = tmp / si->sensing_conf_data.len_x;
+
+		t = tch->abs[CY_TCH_T];
+		input_mt_slot(ts->input, t);
+		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true);
+		__set_bit(t, ids);
+
+		/* position and pressure fields */
+		input_report_abs(ts->input, ABS_MT_POSITION_X,
+				 tch->abs[CY_TCH_X]);
+		input_report_abs(ts->input, ABS_MT_POSITION_Y,
+				 tch->abs[CY_TCH_Y]);
+		input_report_abs(ts->input, ABS_MT_PRESSURE,
+				 tch->abs[CY_TCH_P]);
+
+		/* Get the extended touch fields */
+		input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
+				 tch->abs[CY_TCH_MAJ]);
+		input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
+				 tch->abs[CY_TCH_MIN]);
+	}
+
+	cyttsp5_final_sync(ts->input, si->tch_abs[CY_TCH_T].max, ids);
+
+	ts->num_prv_rec = num_cur_tch;
+}
+
+/* read xy_data for all current touches */
+static int cyttsp5_xy_worker(struct cyttsp5 *ts)
+{
+	struct device *dev = ts->dev;
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int max_tch = si->sensing_conf_data.max_tch;
+	struct cyttsp5_touch tch;
+	u8 num_cur_tch;
+
+	cyttsp5_get_touch_axis(&tch.hdr, si->tch_hdr.size,
+			       si->tch_hdr.max,
+			       si->xy_mode + 3 + si->tch_hdr.ofs,
+			       si->tch_hdr.bofs);
+
+	num_cur_tch = tch.hdr;
+	if (num_cur_tch > max_tch) {
+		dev_err(dev, "Num touch err detected (n=%d)\n", num_cur_tch);
+		num_cur_tch = max_tch;
+	}
+
+	if (num_cur_tch == 0 && ts->num_prv_rec == 0)
+		return 0;
+
+	/* extract xy_data for all currently reported touches */
+	if (num_cur_tch)
+		cyttsp5_get_mt_touches(ts, &tch, num_cur_tch);
+	else
+		cyttsp5_mt_lift_all(ts);
+
+	return 0;
+}
+
+static int cyttsp5_mt_attention(struct device *dev)
+{
+	struct cyttsp5 *ts = dev_get_drvdata(dev);
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int rc;
+
+	if (si->xy_mode[2] != HID_TOUCH_REPORT_ID)
+		return 0;
+
+	/* core handles handshake */
+	rc = cyttsp5_xy_worker(ts);
+	if (rc < 0)
+		dev_err(dev, "xy_worker error r=%d\n", rc);
+
+	return rc;
+}
+
+static int cyttsp5_setup_input_device(struct device *dev)
+{
+	struct cyttsp5 *ts = dev_get_drvdata(dev);
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int max_x, max_y, max_p;
+	int max_x_tmp, max_y_tmp;
+	int rc;
+
+	__set_bit(EV_ABS, ts->input->evbit);
+	__set_bit(EV_REL, ts->input->evbit);
+	__set_bit(EV_KEY, ts->input->evbit);
+
+	max_x_tmp = si->sensing_conf_data.res_x;
+	max_y_tmp = si->sensing_conf_data.res_y;
+	max_x = max_y_tmp - 1;
+	max_y = max_x_tmp - 1;
+	max_p = si->sensing_conf_data.max_z;
+
+	input_mt_init_slots(ts->input, si->tch_abs[CY_TCH_T].max, 0);
+
+	__set_bit(ABS_MT_POSITION_X, ts->input->absbit);
+	__set_bit(ABS_MT_POSITION_Y, ts->input->absbit);
+	__set_bit(ABS_MT_PRESSURE, ts->input->absbit);
+
+	input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
+	input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
+	input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, max_p, 0, 0);
+
+	input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, MAX_AREA, 0, 0);
+	input_set_abs_params(ts->input, ABS_MT_TOUCH_MINOR, 0, MAX_AREA, 0, 0);
+
+	rc = input_register_device(ts->input);
+	if (rc < 0)
+		dev_err(dev, "Error, failed register input device r=%d\n", rc);
+
+	return rc;
+}
+
+#ifdef CONFIG_OF
+static int cyttsp5_parse_dt_key_code(struct device *dev)
+{
+	struct cyttsp5 *ts = dev_get_drvdata(dev);
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	struct device_node *np;
+	int i;
+
+	np = dev->of_node;
+	if (!np)
+		return -EINVAL;
+
+	if (!si->num_btns)
+		return 0;
+
+	/* Initialize the button to RESERVED */
+	for (i = 0; i < si->num_btns; i++)
+		si->key_code[i] = KEY_RESERVED;
+
+	return of_property_read_u32_array(np, "linux,keycodes",
+				   si->key_code, si->num_btns);
+}
+#else
+static int cyttsp5_parse_dt_key_code(struct device *dev)
+{
+	struct cyttsp5 *ts = dev_get_drvdata(dev);
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int i;
+
+	if (!si->num_btns)
+		return 0;
+
+	/* Initialize the button to RESERVED */
+	for (i = 0; i < si->num_btns; i++)
+		si->key_code[i] = KEY_RESERVED;
+
+	return 0;
+}
+#endif
+
+static int cyttsp5_btn_attention(struct device *dev)
+{
+	struct cyttsp5 *ts = dev_get_drvdata(dev);
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int cur_btn;
+	int cur_btn_state;
+
+	if (si->xy_mode[2] != HID_BTN_REPORT_ID || !si->num_btns)
+		return 0;
+
+	/* extract button press/release touch information */
+	for (cur_btn = 0; cur_btn < si->num_btns; cur_btn++) {
+		/* Get current button state */
+		cur_btn_state = (si->xy_data[0] >> (cur_btn * CY_BITS_PER_BTN))
+			& CY_NUM_BTN_EVENT_ID;
+
+		input_report_key(ts->input, si->key_code[cur_btn],
+				 cur_btn_state);
+		input_sync(ts->input);
+	}
+
+	return 0;
+}
+
+static u16 cyttsp5_compute_crc(u8 *buf, u32 size)
+{
+	u16 remainder = 0xFFFF;
+	u16 xor_mask = 0x0000;
+	u32 index;
+	u32 byte_value;
+	u32 table_index;
+	u32 crc_bit_width = sizeof(u16) * 8;
+
+	/* Divide the message by polynomial, via the table. */
+	for (index = 0; index < size; index++) {
+		byte_value = buf[index];
+		table_index = ((byte_value >> 4) & 0x0F)
+			^ (remainder >> (crc_bit_width - 4));
+		remainder = crc_itu_t_table[table_index]
+			^ (remainder << 4);
+		table_index = (byte_value & 0x0F)
+			^ (remainder >> (crc_bit_width - 4));
+		remainder = crc_itu_t_table[table_index]
+			^ (remainder << 4);
+	}
+
+	/* Perform the final remainder CRC. */
+	return remainder ^ xor_mask;
+}
+
+static int cyttsp5_validate_cmd_response(struct cyttsp5 *ts, u8 code)
+{
+	u16 size, crc;
+	u8 status, offset;
+	int command_code;
+
+	size = get_unaligned_le16(&ts->response_buf[0]);
+
+	if (!size)
+		return 0;
+
+	offset = ts->response_buf[HID_OUTPUT_RESPONSE_REPORT_OFFSET];
+
+	if (offset == HID_BL_RESPONSE_REPORT_ID) {
+		if (ts->response_buf[4] != HID_OUTPUT_BL_SOP) {
+			dev_err(ts->dev, "HID output response, wrong SOP\n");
+			return -EPROTO;
+		}
+
+		if (ts->response_buf[size - 1] != HID_OUTPUT_BL_EOP) {
+			dev_err(ts->dev, "HID output response, wrong EOP\n");
+			return -EPROTO;
+		}
+
+		crc = cyttsp5_compute_crc(&ts->response_buf[4], size - 7);
+		if (ts->response_buf[size - 3] != LOW_BYTE(crc) ||
+		    ts->response_buf[size - 2] != HI_BYTE(crc)) {
+			dev_err(ts->dev, "HID output response, wrong CRC 0x%X\n",
+				crc);
+			return -EPROTO;
+		}
+
+		status = ts->response_buf[5];
+		if (status) {
+			dev_err(ts->dev, "HID output response, ERROR:%d\n",
+				status);
+			return -EPROTO;
+		}
+	}
+
+	if (offset == HID_APP_RESPONSE_REPORT_ID) {
+		command_code = ts->response_buf[HID_OUTPUT_RESPONSE_CMD_OFFSET]
+			& HID_OUTPUT_RESPONSE_CMD_MASK;
+		if (command_code != code) {
+			dev_err(ts->dev,
+				"HID output response, wrong command_code:%X\n",
+				command_code);
+			return -EPROTO;
+		}
+	}
+
+	return 0;
+}
+
+static void cyttsp5_si_get_btn_data(struct cyttsp5 *ts)
+{
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+	int i;
+	unsigned int btns = ts->response_buf[HID_SYSINFO_BTN_OFFSET]
+		& HID_SYSINFO_BTN_MASK;
+
+	si->num_btns = 0;
+	for (i = 0; i < HID_SYSINFO_MAX_BTN; i++) {
+		if (btns & BIT(i))
+			si->num_btns++;
+	}
+}
+
+static int cyttsp5_get_sysinfo_regs(struct cyttsp5 *ts)
+{
+	struct cyttsp5_sensing_conf_data *scd = &ts->sysinfo.sensing_conf_data;
+	struct cyttsp5_sensing_conf_data_dev *scd_dev =
+		(struct cyttsp5_sensing_conf_data_dev *)
+		&ts->response_buf[HID_SYSINFO_SENSING_OFFSET];
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+
+	cyttsp5_si_get_btn_data(ts);
+
+	scd->max_tch = scd_dev->max_num_of_tch_per_refresh_cycle;
+	scd->res_x = get_unaligned_le16(&scd_dev->res_x);
+	scd->res_y = get_unaligned_le16(&scd_dev->res_y);
+	scd->max_z = get_unaligned_le16(&scd_dev->max_z);
+	scd->len_x = get_unaligned_le16(&scd_dev->len_x);
+	scd->len_y = get_unaligned_le16(&scd_dev->len_y);
+
+	si->xy_data = devm_kzalloc(ts->dev, scd->max_tch * TOUCH_REPORT_SIZE,
+				   GFP_KERNEL);
+	if (!si->xy_data)
+		return -ENOMEM;
+
+	si->xy_mode = devm_kzalloc(ts->dev, TOUCH_INPUT_HEADER_SIZE,
+				   GFP_KERNEL);
+	if (!si->xy_mode)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static int cyttsp5_hid_output_get_sysinfo(struct cyttsp5 *ts)
+{
+	int rc;
+	u8 cmd[HID_OUTPUT_GET_SYSINFO_SIZE];
+
+	ts->hid_cmd_state = HID_CMD_BUSY;
+
+	/* HI bytes of Output register address */
+	cmd[0] = LOW_BYTE(HID_OUTPUT_GET_SYSINFO_SIZE);
+	cmd[1] = HI_BYTE(HID_OUTPUT_GET_SYSINFO_SIZE);
+	cmd[2] = HID_APP_OUTPUT_REPORT_ID;
+	cmd[3] = 0x0; /* Reserved */
+	cmd[4] = HID_OUTPUT_GET_SYSINFO;
+
+	rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd,
+			   HID_OUTPUT_GET_SYSINFO_SIZE);
+	if (rc) {
+		dev_err(ts->dev, "Failed to write command %d", rc);
+		goto error;
+	}
+
+	rc = wait_event_timeout(ts->wait_q, (ts->hid_cmd_state == HID_CMD_DONE),
+				msecs_to_jiffies(CY_HID_OUTPUT_GET_SYSINFO_TIMEOUT));
+	if (!rc) {
+		dev_err(ts->dev, "HID output cmd execution timed out\n");
+		rc = -ETIME;
+		goto error;
+	}
+
+	rc = cyttsp5_validate_cmd_response(ts, HID_OUTPUT_GET_SYSINFO);
+	if (rc) {
+		dev_err(ts->dev, "Validation of the response failed\n");
+		goto error;
+	}
+
+	return cyttsp5_get_sysinfo_regs(ts);
+
+error:
+	mutex_lock(&ts->system_lock);
+	ts->hid_cmd_state = HID_CMD_DONE;
+	mutex_unlock(&ts->system_lock);
+	return rc;
+}
+
+static int cyttsp5_hid_output_bl_launch_app(struct cyttsp5 *ts)
+{
+	int rc;
+	u8 cmd[HID_OUTPUT_BL_LAUNCH_APP];
+	u16 crc;
+
+	mutex_lock(&ts->system_lock);
+	ts->hid_cmd_state = HID_CMD_BUSY;
+	mutex_unlock(&ts->system_lock);
+
+	cmd[0] = LOW_BYTE(HID_OUTPUT_BL_LAUNCH_APP_SIZE);
+	cmd[1] = HI_BYTE(HID_OUTPUT_BL_LAUNCH_APP_SIZE);
+	cmd[2] = HID_BL_OUTPUT_REPORT_ID;
+	cmd[3] = 0x0; /* Reserved */
+	cmd[4] = HID_OUTPUT_BL_SOP;
+	cmd[5] = HID_OUTPUT_BL_LAUNCH_APP;
+	cmd[6] = 0x0; /* Low bytes of data */
+	cmd[7] = 0x0; /* Hi bytes of data */
+	crc = cyttsp5_compute_crc(&cmd[4], 4);
+	cmd[8] = LOW_BYTE(crc);
+	cmd[9] = HI_BYTE(crc);
+	cmd[10] = HID_OUTPUT_BL_EOP;
+
+	rc = cyttsp5_write(ts, HID_OUTPUT_REG, cmd,
+			   HID_OUTPUT_BL_LAUNCH_APP_SIZE);
+	if (rc) {
+		dev_err(ts->dev, "Failed to write command %d", rc);
+		goto error;
+	}
+
+	rc = wait_event_timeout(ts->wait_q, (ts->hid_cmd_state == HID_CMD_DONE),
+				msecs_to_jiffies(CY_HID_OUTPUT_TIMEOUT));
+	if (!rc) {
+		dev_err(ts->dev, "HID output cmd execution timed out\n");
+		rc = -ETIME;
+		goto error;
+	}
+
+	rc = cyttsp5_validate_cmd_response(ts, HID_OUTPUT_BL_LAUNCH_APP);
+	if (rc) {
+		dev_err(ts->dev, "Validation of the response failed\n");
+		goto error;
+	}
+
+	return rc;
+
+error:
+	mutex_lock(&ts->system_lock);
+	ts->hid_cmd_state = HID_CMD_DONE;
+	mutex_unlock(&ts->system_lock);
+
+	return rc;
+}
+
+static int cyttsp5_get_hid_descriptor(struct cyttsp5 *ts,
+				      struct cyttsp5_hid_desc *desc)
+{
+	struct device *dev = ts->dev;
+	__le16 hid_desc_register = HID_DESC_REG;
+	int rc;
+	u8 cmd[2];
+
+	/* Read HID descriptor length and version */
+	mutex_lock(&ts->system_lock);
+	ts->hid_cmd_state = HID_CMD_BUSY;
+	mutex_unlock(&ts->system_lock);
+
+	/* Set HID descriptor register */
+	memcpy(cmd, &hid_desc_register, sizeof(hid_desc_register));
+
+	rc = cyttsp5_write(ts, HID_DESC_REG, NULL, 0);
+	if (rc < 0) {
+		dev_err(dev, "Failed to get HID descriptor, rc=%d\n", rc);
+		goto error;
+	}
+
+	rc = wait_event_timeout(ts->wait_q, (ts->hid_cmd_state == HID_CMD_DONE),
+				msecs_to_jiffies(CY_HID_GET_HID_DESCRIPTOR_TIMEOUT));
+	if (!rc) {
+		dev_err(ts->dev, "HID get descriptor timed out\n");
+		rc = -ETIME;
+		goto error;
+	}
+
+	memcpy(desc, ts->response_buf, sizeof(struct cyttsp5_hid_desc));
+
+	/* Check HID descriptor length and version */
+	if (le16_to_cpu(desc->hid_desc_len) != sizeof(*desc) ||
+	    le16_to_cpu(desc->bcd_version) != HID_VERSION) {
+		dev_err(dev, "Unsupported HID version\n");
+		return -ENODEV;
+	}
+
+	goto exit;
+
+error:
+	mutex_lock(&ts->system_lock);
+	ts->hid_cmd_state = HID_CMD_DONE;
+	mutex_unlock(&ts->system_lock);
+exit:
+	return rc;
+}
+
+static int fill_tch_abs(struct cyttsp5_tch_abs_params *tch_abs, int report_size,
+			int offset)
+{
+	tch_abs->ofs = offset / 8;
+	tch_abs->size = report_size / 8;
+	if (report_size % 8)
+		tch_abs->size += 1;
+	tch_abs->min = 0;
+	tch_abs->max = 1 << report_size;
+	tch_abs->bofs = offset - (tch_abs->ofs << 3);
+
+	return 0;
+}
+
+static int move_button_data(struct cyttsp5 *ts, struct cyttsp5_sysinfo *si)
+{
+	memcpy(si->xy_mode, ts->input_buf, BTN_INPUT_HEADER_SIZE);
+	memcpy(si->xy_data, &ts->input_buf[BTN_INPUT_HEADER_SIZE],
+	       BTN_REPORT_SIZE);
+
+	return 0;
+}
+
+static int move_touch_data(struct cyttsp5 *ts, struct cyttsp5_sysinfo *si)
+{
+	int max_tch = si->sensing_conf_data.max_tch;
+	int num_cur_tch;
+	int length;
+	struct cyttsp5_tch_abs_params *tch = &si->tch_hdr;
+
+	memcpy(si->xy_mode, ts->input_buf, TOUCH_INPUT_HEADER_SIZE);
+
+	cyttsp5_get_touch_axis(&num_cur_tch, tch->size,
+			       tch->max, si->xy_mode + 3 + tch->ofs, tch->bofs);
+	if (unlikely(num_cur_tch > max_tch))
+		num_cur_tch = max_tch;
+
+	length = num_cur_tch * TOUCH_REPORT_SIZE;
+
+	memcpy(si->xy_data, &ts->input_buf[TOUCH_INPUT_HEADER_SIZE], length);
+
+	return 0;
+}
+
+static irqreturn_t cyttsp5_handle_irq(int irq, void *handle)
+{
+	struct cyttsp5 *ts = handle;
+	int report_id;
+	int size;
+	int rc;
+
+	rc = cyttsp5_read(ts, ts->input_buf, CY_MAX_INPUT);
+	if (rc)
+		return IRQ_HANDLED;
+
+	size = get_unaligned_le16(&ts->input_buf[0]);
+
+	/* check reset */
+	if (size == 0) {
+		memcpy(ts->response_buf, ts->input_buf, 2);
+
+		mutex_lock(&ts->system_lock);
+		ts->hid_cmd_state = HID_CMD_DONE;
+		mutex_unlock(&ts->system_lock);
+		wake_up(&ts->wait_q);
+		return IRQ_HANDLED;
+	}
+
+	report_id = ts->input_buf[2];
+
+	if (report_id == HID_TOUCH_REPORT_ID) {
+		move_touch_data(ts, &ts->sysinfo);
+		cyttsp5_mt_attention(ts->dev);
+	} else if (report_id == HID_BTN_REPORT_ID) {
+		move_button_data(ts, &ts->sysinfo);
+		cyttsp5_btn_attention(ts->dev);
+	} else {
+		/* It is not an input but a command response */
+		memcpy(ts->response_buf, ts->input_buf, size);
+
+		mutex_lock(&ts->system_lock);
+		ts->hid_cmd_state = HID_CMD_DONE;
+		mutex_unlock(&ts->system_lock);
+		wake_up(&ts->wait_q);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static int cyttsp5_deassert_int(struct cyttsp5 *ts)
+{
+	u16 size;
+	u8 buf[2];
+	int rc;
+
+	rc = regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, 2);
+	if (rc < 0)
+		return rc;
+
+	size = get_unaligned_le16(&buf[0]);
+	if (size == 2 || size == 0)
+		return 0;
+
+	return -EINVAL;
+}
+
+static int cyttsp5_fill_all_touch(struct cyttsp5 *ts)
+{
+	struct cyttsp5_sysinfo *si = &ts->sysinfo;
+
+	fill_tch_abs(&si->tch_abs[CY_TCH_X], REPORT_SIZE_16,
+		     TOUCH_REPORT_DESC_X);
+	fill_tch_abs(&si->tch_abs[CY_TCH_Y], REPORT_SIZE_16,
+		     TOUCH_REPORT_DESC_Y);
+	fill_tch_abs(&si->tch_abs[CY_TCH_P], REPORT_SIZE_8,
+		     TOUCH_REPORT_DESC_P);
+	fill_tch_abs(&si->tch_abs[CY_TCH_T], REPORT_SIZE_5,
+		     TOUCH_REPORT_DESC_CONTACTID);
+	fill_tch_abs(&si->tch_hdr, REPORT_SIZE_5,
+		     TOUCH_REPORT_DESC_HDR_CONTACTCOUNT);
+	fill_tch_abs(&si->tch_abs[CY_TCH_MAJ], REPORT_SIZE_8,
+		     TOUCH_REPORT_DESC_MAJ);
+	fill_tch_abs(&si->tch_abs[CY_TCH_MIN], REPORT_SIZE_8,
+		     TOUCH_REPORT_DESC_MIN);
+
+	return 0;
+}
+
+static int cyttsp5_startup(struct cyttsp5 *ts)
+{
+	int rc;
+
+	rc = cyttsp5_deassert_int(ts);
+	if (rc) {
+		dev_err(ts->dev, "Error on deassert int r=%d\n", rc);
+		return -ENODEV;
+	}
+
+	/*
+	 * Launch the application as the device starts in bootloader mode
+	 * because of a power-on-reset
+	 */
+	rc = cyttsp5_hid_output_bl_launch_app(ts);
+	if (rc < 0) {
+		dev_err(ts->dev, "Error on launch app r=%d\n", rc);
+		return rc;
+	}
+
+	rc = cyttsp5_get_hid_descriptor(ts, &ts->hid_desc);
+	if (rc < 0) {
+		dev_err(ts->dev, "Error on getting HID descriptor r=%d\n", rc);
+		return rc;
+	}
+
+	rc = cyttsp5_fill_all_touch(ts);
+	if (rc < 0) {
+		dev_err(ts->dev, "Error on report descriptor r=%d\n", rc);
+		return rc;
+	}
+
+	rc = cyttsp5_hid_output_get_sysinfo(ts);
+	if (rc) {
+		dev_err(ts->dev, "Error on getting sysinfo r=%d\n", rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id cyttsp5_of_match[] = {
+	{ .compatible = "cypress,cyttsp5", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, cyttsp5_of_match);
+#endif
+
+static const struct i2c_device_id cyttsp5_i2c_id[] = {
+	{ CYTTSP5_NAME, 0, },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, cyttsp5_i2c_id);
+
+static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
+			 const char *name)
+{
+	struct cyttsp5 *ts;
+	struct cyttsp5_sysinfo *si;
+	int rc = 0, i;
+
+	ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
+	if (!ts)
+		return -ENOMEM;
+
+	/* Initialize device info */
+	ts->regmap = regmap;
+	ts->dev = dev;
+	si = &ts->sysinfo;
+	dev_set_drvdata(dev, ts);
+
+	/* Initialize mutexes and spinlocks */
+	mutex_init(&ts->system_lock);
+
+	/* Initialize wait queue */
+	init_waitqueue_head(&ts->wait_q);
+
+	/* Reset the gpio to be in a reset state */
+	ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(ts->reset_gpio)) {
+		rc = PTR_ERR(ts->reset_gpio);
+		dev_err(dev, "Failed to request reset gpio, error %d\n", rc);
+		return rc;
+	}
+	gpiod_set_value(ts->reset_gpio, 1);
+
+	/* Need a delay to have device up */
+	msleep(20);
+
+	rc = devm_request_threaded_irq(dev, irq, NULL, cyttsp5_handle_irq,
+				       IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+				       name, ts);
+	if (rc) {
+		dev_err(dev, "unable to request IRQ\n");
+		return rc;
+	}
+
+	rc = cyttsp5_startup(ts);
+	if (rc) {
+		dev_err(ts->dev, "Fail initial startup r=%d\n", rc);
+		return rc;
+	}
+
+	rc = cyttsp5_parse_dt_key_code(dev);
+	if (rc < 0) {
+		dev_err(ts->dev, "Error while parsing dts %d\n", rc);
+		return rc;
+	}
+
+	ts->input = devm_input_allocate_device(dev);
+	if (!ts->input) {
+		dev_err(dev, "Error, failed to allocate input device\n");
+		return -ENODEV;
+	}
+
+	ts->input->name = "cyttsp5";
+	scnprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
+	ts->input->phys = ts->phys;
+	ts->input->dev.parent = ts->dev;
+	input_set_drvdata(ts->input, ts);
+
+	touchscreen_parse_properties(ts->input, true, NULL);
+
+	__set_bit(EV_KEY, ts->input->evbit);
+	for (i = 0; i < si->num_btns; i++)
+		__set_bit(si->key_code[i], ts->input->keybit);
+
+	return cyttsp5_setup_input_device(dev);
+}
+
+static int cyttsp5_i2c_probe(struct i2c_client *client,
+			     const struct i2c_device_id *id)
+{
+	struct regmap *regmap;
+	static const struct regmap_config config = {
+		.reg_bits = 8,
+		.val_bits = 8,
+	};
+
+	regmap = devm_regmap_init_i2c(client, &config);
+	if (IS_ERR(regmap)) {
+		dev_err(&client->dev, "regmap allocation failed: %ld\n",
+			PTR_ERR(regmap));
+		return PTR_ERR(regmap);
+	}
+
+	return cyttsp5_probe(&client->dev, regmap, client->irq, client->name);
+}
+
+static int cyttsp5_remove(struct device *dev)
+{
+	struct cyttsp5 *ts = dev_get_drvdata(dev);
+
+	input_unregister_device(ts->input);
+
+	return 0;
+}
+
+static int cyttsp5_i2c_remove(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+
+	return cyttsp5_remove(dev);
+}
+
+static struct i2c_driver cyttsp5_i2c_driver = {
+	.driver = {
+		.name = CYTTSP5_NAME,
+		.of_match_table = of_match_ptr(cyttsp5_of_match),
+	},
+	.probe = cyttsp5_i2c_probe,
+	.remove = cyttsp5_i2c_remove,
+	.id_table = cyttsp5_i2c_id,
+};
+
+module_i2c_driver(cyttsp5_i2c_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Touchscreen driver for Cypress TrueTouch Gen 5 Product");
+MODULE_AUTHOR("Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>");
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH v5 0/2] Input: Add Cypress Gen5 Touchscreen driver
From: Mylène Josserand @ 2017-12-20 10:08 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8
  Cc: mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Hello,

Here is a V5 series to add the driver of the touchscreen Cypress,
TrueTouch Generation 5.
Based on last master branch of "input" kernel's tree.

This patch series has already been posted in several iterations:
    - v1: Sent on 2017/05/29
    - v2: Sent on 2017/08/18
    - v3: Sent on 2017/09/27
    - v4: Sent on 2017/12/01

As I did not have any comments on the last 3 versions, it would be
great to have some feedback in case there is something wrong with this
series?

Changes since v4:
   - Fixed kbuild errors about enum hid_cmd_state and .owner
Changes since v3:
   - Rebased on last input's branch
   - Changed the CRC table to use crc_itu_t_table instead of
   crc_ccitt_false_table which is not merged.
   - Added selection of CRC_ITU_T on KConfig
Changes since v2:
   - Removed pinctrl in dt-binding example which is uncessecary.
   - Added Acked-by and Reviewed-by received.
Changes since v1:
   - Updated the driver according to reviews. Most important modifications:
   removed unnecessary mutex, updated dev_err output, handled return cases
   in a better way, created a HID_ENUM, removed magic value, used an
   existing CRC table and used "linux-keycodes" instead of sub-nodes.
   - Updated the dt-bindings to use linux-keycodes and removed properties'
   description that comes from touchscreen's binding.

Patch 01: Add the basis of the driver for Cypress Gen5 Touchscreen.
Patch 02: Add the binding documentation for this driver.

Thank you in advance,
Mylène

Mylène Josserand (2):
  Input: Add driver for Cypress Generation 5 touchscreen
  dt-bindings: input: Add documentation for cyttsp5

 .../bindings/input/touchscreen/cypress,cyttsp5.txt |   39 +
 drivers/input/touchscreen/Kconfig                  |   16 +
 drivers/input/touchscreen/Makefile                 |    1 +
 drivers/input/touchscreen/cyttsp5.c                | 1112 ++++++++++++++++++++
 4 files changed, 1168 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cypress,cyttsp5.txt
 create mode 100644 drivers/input/touchscreen/cyttsp5.c

-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [-next PATCH 0/4] sysfs and DEVICE_ATTR_<foo>
From: Felipe Balbi @ 2017-12-20  9:46 UTC (permalink / raw)
  To: Joe Perches, linux-arm-kernel, linux-acpi, openipmi-developer,
	intel-gfx, linuxppc-dev, netdev, linux-nvme, platform-driver-x86,
	linux-s390, esc.storagedev, linux-scsi, linux-pm, linux-serial,
	linux-usb, linux-kernel, alsa-devel, linux-omap
  Cc: devel, linux-fbdev, linux-sh, dri-devel, linux-input, linux-media
In-Reply-To: <cover.1513706701.git.joe@perches.com>


Hi,

Joe Perches <joe@perches.com> writes:
>  drivers/usb/phy/phy-tahvo.c                        |  2 +-

Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>

-- 
balbi
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply

* Re: [PATCH v1] HID: sony: Print reversed MAC address via %pMR
From: Benjamin Tissoires @ 2017-12-20  9:40 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Colenbrander, Roelof, Jiri Kosina, linux-input@vger.kernel.org
In-Reply-To: <1513704018.7000.207.camel@linux.intel.com>

Hi Andy,

On Tue, Dec 19, 2017 at 6:20 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, 2017-12-13 at 02:22 +0000, Colenbrander, Roelof wrote:
>> On 12/11/2017 05:07 AM, Andy Shevchenko wrote:
>> > Reversed MAC addresses can be printed directly using %pMR specifier.
>
>> Looks good and in a quick test seems to function.
>>
>> Acked-by: Roderick Colenbrander <roderick.colenbranderer@sony.com>
>>
>
> Benjamin, perhaps it's good enough to being applied?

This question should be directed to Jiri :)

Anyway:
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

^ permalink raw reply

* [PATCH v2] HID: elecom: rewrite report fixup for EX-G and future mice
From: Tomasz Kramkowski @ 2017-12-19 20:44 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Benjamin Tissoires, Yuxuan Shui, Diego Elio Pettenò,
	Alex Manoussakis, linux-input, linux-kernel, Tomasz Kramkowski
In-Reply-To: <20171204205550.2621-1-tk@the-tk.com>

This patch rewrites the mouse report fixup used for the DEFT and HUGE
elecom trackballs in order to make it generic enough to fix other
elecom mice with similar issues. This patch also uses this new report
fixup function to fix the Elecom EX-G trackball which has 6 physical
buttons and a similar issue to the other two mice.

Elecom's track record has so far shown that they like to re-use the
same report descriptor for multiple different mice regardless of the
number of buttons the mouse has. This means that the missing buttons
on multiple mice can be fixed in one function without introducing
phantom buttons which would in turn cause the number of mouse buttons
to be misreported to userspace.

This patch drops the very verbose report descriptor "diff" comment for
a more abridged yet hopefully just as informative generic version.

Signed-off-by: Tomasz Kramkowski <tk@the-tk.com>
---
v2 changes:
* pass rsize directly to mouse_button_fixup
* add support for wireless EX-G variant
v1: https://marc.info/?i=20171204205550.2621-1-tk@the-tk.com
---
 drivers/hid/Kconfig      |  1 +
 drivers/hid/hid-elecom.c | 78 ++++++++++++++++++++++++++----------------------
 drivers/hid/hid-ids.h    |  2 ++
 drivers/hid/hid-quirks.c |  2 ++
 4 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 9058dbc4dd6e..19c499f5623d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -280,6 +280,7 @@ config HID_ELECOM
 	---help---
 	Support for ELECOM devices:
 	  - BM084 Bluetooth Mouse
+	  - EX-G Trackball (Wired and wireless)
 	  - DEFT Trackball (Wired and wireless)
 	  - HUGE Trackball (Wired and wireless)
 
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c
index 54aeea57d209..1a1ecc491c02 100644
--- a/drivers/hid/hid-elecom.c
+++ b/drivers/hid/hid-elecom.c
@@ -1,9 +1,15 @@
 /*
- *  HID driver for ELECOM devices.
+ *  HID driver for ELECOM devices:
+ *  - BM084 Bluetooth Mouse
+ *  - EX-G Trackball (Wired and wireless)
+ *  - DEFT Trackball (Wired and wireless)
+ *  - HUGE Trackball (Wired and wireless)
+ *
  *  Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com>
  *  Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com>
  *  Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu>
  *  Copyright (c) 2017 Alex Manoussakis <amanou@gnu.org>
+ *  Copyright (c) 2017 Tomasz Kramkowski <tk@the-tk.com>
  */
 
 /*
@@ -19,6 +25,34 @@
 
 #include "hid-ids.h"
 
+/*
+ * Certain ELECOM mice misreport their button count meaning that they only work
+ * correctly with the ELECOM mouse assistant software which is unavailable for
+ * Linux. A four extra INPUT reports and a FEATURE report are described by the
+ * report descriptor but it does not appear that these enable software to
+ * control what the extra buttons map to. The only simple and straightforward
+ * solution seems to involve fixing up the report descriptor.
+ *
+ * Report descriptor format:
+ * Positions 13, 15, 21 and 31 store the button bit count, button usage minimum,
+ * button usage maximum and padding bit count respectively.
+ */
+#define MOUSE_BUTTONS_MAX 8
+static void mouse_button_fixup(struct hid_device *hdev,
+			       __u8 *rdesc, unsigned int rsize,
+			       int nbuttons)
+{
+	if (rsize < 32 || rdesc[12] != 0x95 ||
+	    rdesc[14] != 0x75 || rdesc[15] != 0x01 ||
+	    rdesc[20] != 0x29 || rdesc[30] != 0x75)
+		return;
+	hid_info(hdev, "Fixing up Elecom mouse button count\n");
+	nbuttons = clamp(nbuttons, 0, MOUSE_BUTTONS_MAX);
+	rdesc[13] = nbuttons;
+	rdesc[21] = nbuttons;
+	rdesc[31] = MOUSE_BUTTONS_MAX - nbuttons;
+}
+
 static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 		unsigned int *rsize)
 {
@@ -31,45 +65,15 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 			rdesc[47] = 0x00;
 		}
 		break;
+	case USB_DEVICE_ID_ELECOM_EX_G_WIRED:
+	case USB_DEVICE_ID_ELECOM_EX_G_WIRELESS:
+		mouse_button_fixup(hdev, rdesc, *rsize, 6);
+		break;
 	case USB_DEVICE_ID_ELECOM_DEFT_WIRED:
 	case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS:
 	case USB_DEVICE_ID_ELECOM_HUGE_WIRED:
 	case USB_DEVICE_ID_ELECOM_HUGE_WIRELESS:
-		/* The DEFT/HUGE trackball has eight buttons, but its descriptor
-		 * only reports five, disabling the three Fn buttons on the top
-		 * of the mouse.
-		 *
-		 * Apply the following diff to the descriptor:
-		 *
-		 * Collection (Physical),              Collection (Physical),
-		 *     Report ID (1),                      Report ID (1),
-		 *     Report Count (5),           ->      Report Count (8),
-		 *     Report Size (1),                    Report Size (1),
-		 *     Usage Page (Button),                Usage Page (Button),
-		 *     Usage Minimum (01h),                Usage Minimum (01h),
-		 *     Usage Maximum (05h),        ->      Usage Maximum (08h),
-		 *     Logical Minimum (0),                Logical Minimum (0),
-		 *     Logical Maximum (1),                Logical Maximum (1),
-		 *     Input (Variable),                   Input (Variable),
-		 *     Report Count (1),           ->      Report Count (0),
-		 *     Report Size (3),                    Report Size (3),
-		 *     Input (Constant),                   Input (Constant),
-		 *     Report Size (16),                   Report Size (16),
-		 *     Report Count (2),                   Report Count (2),
-		 *     Usage Page (Desktop),               Usage Page (Desktop),
-		 *     Usage (X),                          Usage (X),
-		 *     Usage (Y),                          Usage (Y),
-		 *     Logical Minimum (-32768),           Logical Minimum (-32768),
-		 *     Logical Maximum (32767),            Logical Maximum (32767),
-		 *     Input (Variable, Relative),         Input (Variable, Relative),
-		 * End Collection,                     End Collection,
-		 */
-		if (*rsize == 213 && rdesc[13] == 5 && rdesc[21] == 5) {
-			hid_info(hdev, "Fixing up Elecom DEFT/HUGE Fn buttons\n");
-			rdesc[13] = 8; /* Button/Variable Report Count */
-			rdesc[21] = 8; /* Button/Variable Usage Maximum */
-			rdesc[29] = 0; /* Button/Constant Report Count */
-		}
+		mouse_button_fixup(hdev, rdesc, *rsize, 8);
 		break;
 	}
 	return rdesc;
@@ -77,6 +81,8 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 
 static const struct hid_device_id elecom_devices[] = {
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRED) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRELESS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRED) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 5da3d6256d25..d5daf2e638f7 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -370,6 +370,8 @@
 
 #define USB_VENDOR_ID_ELECOM		0x056e
 #define USB_DEVICE_ID_ELECOM_BM084	0x0061
+#define USB_DEVICE_ID_ELECOM_EX_G_WIRED	0x00fb
+#define USB_DEVICE_ID_ELECOM_EX_G_WIRELESS	0x00fc
 #define USB_DEVICE_ID_ELECOM_DEFT_WIRED	0x00fe
 #define USB_DEVICE_ID_ELECOM_DEFT_WIRELESS	0x00ff
 #define USB_DEVICE_ID_ELECOM_HUGE_WIRED	0x010c
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 015e0c10248b..6f5f9c2d30f9 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -335,6 +335,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
 #endif
 #if IS_ENABLED(CONFIG_HID_ELECOM)
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRED) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_EX_G_WIRELESS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRED) },
-- 
2.15.1


^ permalink raw reply related

* Re: [-next PATCH 0/4] sysfs and DEVICE_ATTR_<foo>
From: Corey Minyard @ 2017-12-19 19:26 UTC (permalink / raw)
  To: Joe Perches, linux-arm-kernel, linux-acpi, openipmi-developer,
	intel-gfx, linuxppc-dev, netdev, linux-nvme, platform-driver-x86,
	linux-s390, esc.storagedev, linux-scsi, linux-pm, linux-serial,
	linux-usb, linux-kernel, alsa-devel, linux-omap
  Cc: devel, linux-fbdev, linux-sh, dri-devel, linux-input, linux-media
In-Reply-To: <cover.1513706701.git.joe@perches.com>

On 12/19/2017 12:15 PM, Joe Perches wrote:
>   drivers/char/ipmi/ipmi_msghandler.c                | 17 +++---

For ipmi:

Acked-by: Corey Minyard <cminyard@mvista.com>

^ permalink raw reply

* Re: [PATCH v2] HID: sony: Fix up nyko core controller
From: Roderick Colenbrander @ 2017-12-19 19:07 UTC (permalink / raw)
  To: Scott Moreau; +Cc: linux-input
In-Reply-To: <1513131714-10907-1-git-send-email-oreaus@gmail.com>

(From personal email as work email, doesn't do plain text well..)

Acked-by: Roderick Colenbrander <roderick.colenbrander@sony.com>

On Tue, Dec 12, 2017 at 6:21 PM, Scott Moreau <oreaus@gmail.com> wrote:
> This fixes missing d-pad axis broken since e19a267b99. The axis mapping for
> the nyko controller has the d-pad as axis 0x39 instead of d-pad as buttons.
> This is handled by the default hid mapping so we return 0 in sony_mapping.
> This controller also has no accelerometer so avoid initializing it with
> a condition in sony_input_configured() to setup these controllers.
> ---
>  drivers/hid/hid-sony.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index b9dc3ac..1be0a35 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -1225,6 +1225,9 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi,
>         if (sc->quirks & NAVIGATION_CONTROLLER)
>                 return navigation_mapping(hdev, hi, field, usage, bit, max);
>
> +       if (sc->quirks & SINO_LITE_CONTROLLER)
> +               return 0;
> +
>         if (sc->quirks & SIXAXIS_CONTROLLER)
>                 return sixaxis_mapping(hdev, hi, field, usage, bit, max);
>
> @@ -2566,6 +2569,10 @@ static int sony_input_configured(struct hid_device *hdev,
>                 }
>
>                 sony_init_output_report(sc, sixaxis_send_output_report);
> +       } else if (sc->quirks & SINO_LITE_CONTROLLER) {
> +               hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID;
> +
> +               sony_init_output_report(sc, sixaxis_send_output_report);
>         } else if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
>                 /*
>                  * The Sony Sixaxis does not handle HID Output Reports on the
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" 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] HID: sony: Report DS4 version info through sysfs
From: Roderick Colenbrander @ 2017-12-19 19:04 UTC (permalink / raw)
  To: linux-input; +Cc: Benjamin Tissoires, Jiri Kosina, Roderick Colenbrander

From: Roderick Colenbrander <roderick.colenbrander@sony.com>

Report DS4 firmware and hardware version through sysfs for both
USB and Bluetooth. This information is important for userspace
in particular for device specific quirks (e.g. in Bluetooth stacks).

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
---
 drivers/hid/hid-sony.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index b9dc3ac4d4aa..432d9a47cab0 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -473,6 +473,7 @@ struct motion_output_report_02 {
 #define DS4_FEATURE_REPORT_0x02_SIZE 37
 #define DS4_FEATURE_REPORT_0x05_SIZE 41
 #define DS4_FEATURE_REPORT_0x81_SIZE 7
+#define DS4_FEATURE_REPORT_0xA3_SIZE 49
 #define DS4_INPUT_REPORT_0x11_SIZE 78
 #define DS4_OUTPUT_REPORT_0x05_SIZE 32
 #define DS4_OUTPUT_REPORT_0x11_SIZE 78
@@ -544,6 +545,8 @@ struct sony_sc {
 	struct power_supply *battery;
 	struct power_supply_desc battery_desc;
 	int device_id;
+	unsigned fw_version;
+	unsigned hw_version;
 	u8 *output_report_dmabuf;
 
 #ifdef CONFIG_SONY_FF
@@ -627,6 +630,29 @@ static ssize_t ds4_store_poll_interval(struct device *dev,
 static DEVICE_ATTR(bt_poll_interval, 0644, ds4_show_poll_interval,
 		ds4_store_poll_interval);
 
+static ssize_t sony_show_firmware_version(struct device *dev,
+				struct device_attribute
+				*attr, char *buf)
+{
+	struct hid_device *hdev = to_hid_device(dev);
+	struct sony_sc *sc = hid_get_drvdata(hdev);
+
+	return snprintf(buf, PAGE_SIZE, "0x%04x\n", sc->fw_version);
+}
+
+static DEVICE_ATTR(firmware_version, 0444, sony_show_firmware_version, NULL);
+
+static ssize_t sony_show_hardware_version(struct device *dev,
+				struct device_attribute
+				*attr, char *buf)
+{
+	struct hid_device *hdev = to_hid_device(dev);
+	struct sony_sc *sc = hid_get_drvdata(hdev);
+
+	return snprintf(buf, PAGE_SIZE, "0x%04x\n", sc->hw_version);
+}
+
+static DEVICE_ATTR(hardware_version, 0444, sony_show_hardware_version, NULL);
 
 static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc,
 			     unsigned int *rsize)
@@ -1646,6 +1672,31 @@ static void dualshock4_calibration_work(struct work_struct *work)
 	spin_unlock_irqrestore(&sc->lock, flags);
 }
 
+static int dualshock4_get_version_info(struct sony_sc *sc)
+{
+	u8 *buf;
+	int ret;
+
+	buf = kmalloc(DS4_FEATURE_REPORT_0xA3_SIZE, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	ret = hid_hw_raw_request(sc->hdev, 0xA3, buf,
+				 DS4_FEATURE_REPORT_0xA3_SIZE,
+				 HID_FEATURE_REPORT,
+				 HID_REQ_GET_REPORT);
+	if (ret < 0) {
+		kfree(buf);
+		return ret;
+	}
+
+	sc->hw_version = get_unaligned_le16(&buf[35]);
+	sc->fw_version = get_unaligned_le16(&buf[41]);
+
+	kfree(buf);
+	return 0;
+}
+
 static void sixaxis_set_leds_from_id(struct sony_sc *sc)
 {
 	static const u8 sixaxis_leds[10][4] = {
@@ -2619,6 +2670,28 @@ static int sony_input_configured(struct hid_device *hdev,
 			goto err_stop;
 		}
 
+		ret = dualshock4_get_version_info(sc);
+		if (ret < 0) {
+			hid_err(sc->hdev, "Failed to get version data from Dualshock 4\n");
+			goto err_stop;
+		}
+
+		ret = device_create_file(&sc->hdev->dev, &dev_attr_firmware_version);
+		if (ret) {
+			/* Make zero for cleanup reasons of sysfs entries. */
+			sc->fw_version = 0;
+			sc->hw_version = 0;
+			hid_err(sc->hdev, "can't create sysfs firmware_version attribute err: %d\n", ret);
+			goto err_stop;
+		}
+
+		ret = device_create_file(&sc->hdev->dev, &dev_attr_hardware_version);
+		if (ret) {
+			sc->hw_version = 0;
+			hid_err(sc->hdev, "can't create sysfs hardware_version attribute err: %d\n", ret);
+			goto err_stop;
+		}
+
 		/*
 		 * The Dualshock 4 touchpad supports 2 touches and has a
 		 * resolution of 1920x942 (44.86 dots/mm).
@@ -2695,6 +2768,10 @@ static int sony_input_configured(struct hid_device *hdev,
 	 */
 	if (sc->ds4_bt_poll_interval)
 		device_remove_file(&sc->hdev->dev, &dev_attr_bt_poll_interval);
+	if (sc->fw_version)
+		device_remove_file(&sc->hdev->dev, &dev_attr_firmware_version);
+	if (sc->hw_version)
+		device_remove_file(&sc->hdev->dev, &dev_attr_hardware_version);
 	if (sc->quirks & SONY_LED_SUPPORT)
 		sony_leds_remove(sc);
 	if (sc->quirks & SONY_BATTERY_SUPPORT)
@@ -2796,6 +2873,12 @@ static void sony_remove(struct hid_device *hdev)
 	if (sc->quirks & DUALSHOCK4_CONTROLLER_BT)
 		device_remove_file(&sc->hdev->dev, &dev_attr_bt_poll_interval);
 
+	if (sc->fw_version)
+		device_remove_file(&sc->hdev->dev, &dev_attr_firmware_version);
+
+	if (sc->hw_version)
+		device_remove_file(&sc->hdev->dev, &dev_attr_hardware_version);
+
 	sony_cancel_work_sync(sc);
 
 	kfree(sc->output_report_dmabuf);
-- 
2.13.6


^ permalink raw reply related

* Re: [-next PATCH 0/4] sysfs and DEVICE_ATTR_<foo>
From: Jani Nikula @ 2017-12-19 18:54 UTC (permalink / raw)
  To: Joe Perches, linux-arm-kernel, linux-acpi, openipmi-developer,
	intel-gfx, linuxppc-dev, netdev, linux-nvme, platform-driver-x86,
	linux-s390, esc.storagedev, linux-scsi, linux-pm, linux-serial,
	linux-usb, linux-kernel, alsa-devel, linux-omap
  Cc: devel, linux-fbdev, linux-sh, dri-devel, linux-input, linux-media
In-Reply-To: <cover.1513706701.git.joe@perches.com>

On Tue, 19 Dec 2017, Joe Perches <joe@perches.com> wrote:
>  drivers/gpu/drm/i915/i915_sysfs.c                  | 12 ++--

For i915,

Acked-by: Jani Nikula <jani.nikula@intel.com>


-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply

* Re: [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO
From: Borislav Petkov @ 2017-12-19 18:54 UTC (permalink / raw)
  To: Joe Perches
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Thomas Falcon, John Allen, Inaky Perez-Gonzalez, linux-wimax,
	James Smart, Dick Kennedy, Zhang Rui, Eduardo Valentin,
	Martin Schwidefsky, Heiko Carstens, Thomas Gleixner,
	H. Peter Anvin, x86, Dmitry Torokhov, James E.J. Bottomley,
	Martin K. Petersen
In-Reply-To: <1513709474.1234.66.camel@perches.com>

On Tue, Dec 19, 2017 at 10:51:14AM -0800, Joe Perches wrote:
> > The reason for the code churn being?
> 
> Consistency for easier grep by use-type.

Please explain that in the commit message so that we know why it was
changed.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply

* Re: [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO
From: Joe Perches @ 2017-12-19 18:51 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Thomas Falcon, John Allen, Inaky Perez-Gonzalez, linux-wimax,
	James Smart, Dick Kennedy, Zhang Rui, Eduardo Valentin,
	Martin Schwidefsky, Heiko Carstens, Thomas Gleixner,
	H. Peter Anvin, x86, Dmitry Torokhov, James E.J. Bottomley,
	Martin K. Petersen
In-Reply-To: <20171219184441.ixxh757tl44qvk5l@pd.tnic>

On Tue, 2017-12-19 at 19:44 +0100, Borislav Petkov wrote:
> On Tue, Dec 19, 2017 at 10:15:09AM -0800, Joe Perches wrote:
> > Convert DEVICE_ATTR uses to DEVICE_ATTR_WO where possible.
> > 
> > Done with perl script:
> > 
> > $ git grep -w --name-only DEVICE_ATTR | \
> >   xargs perl -i -e 'local $/; while (<>) { s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(?:\s*S_IWUSR\s*|\s*0200\s*)\)?\s*,\s*NULL\s*,\s*\s_store\s*\)/DEVICE_ATTR_WO(\1)/g; print;}'
[]
> > diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
[]
> > @@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
> >  	return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
> >  }
> >  
> > -static DEVICE_ATTR(reload, 0200, NULL, reload_store);
> > +static DEVICE_ATTR_WO(reload);
> >  static DEVICE_ATTR(version, 0400, version_show, NULL);
> >  static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
> >  
> 
> # cat /sys/devices/system/cpu/microcode/reload
> cat: /sys/devices/system/cpu/microcode/reload: Permission denied

Not different behavior.  It was and remains write only.

> The reason for the code churn being?

Consistency for easier grep by use-type.



^ permalink raw reply

* Re: [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO
From: Borislav Petkov @ 2017-12-19 18:44 UTC (permalink / raw)
  To: Joe Perches
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Thomas Falcon, John Allen, Inaky Perez-Gonzalez, linux-wimax,
	James Smart, Dick Kennedy, Zhang Rui, Eduardo Valentin,
	Martin Schwidefsky, Heiko Carstens, Thomas Gleixner,
	H. Peter Anvin, x86, Dmitry Torokhov, James E.J. Bottomley,
	Martin K. Petersen
In-Reply-To: <fa30f1ad73f76dafff816df40cacffe613aa2f48.1513706702.git.joe@perches.com>

On Tue, Dec 19, 2017 at 10:15:09AM -0800, Joe Perches wrote:
> Convert DEVICE_ATTR uses to DEVICE_ATTR_WO where possible.
> 
> Done with perl script:
> 
> $ git grep -w --name-only DEVICE_ATTR | \
>   xargs perl -i -e 'local $/; while (<>) { s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(?:\s*S_IWUSR\s*|\s*0200\s*)\)?\s*,\s*NULL\s*,\s*\s_store\s*\)/DEVICE_ATTR_WO(\1)/g; print;}'
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  arch/s390/kernel/smp.c                 | 2 +-
>  arch/x86/kernel/cpu/microcode/core.c   | 2 +-
>  drivers/input/touchscreen/elants_i2c.c | 2 +-
>  drivers/net/ethernet/ibm/ibmvnic.c     | 2 +-
>  drivers/net/wimax/i2400m/sysfs.c       | 3 +--
>  drivers/scsi/lpfc/lpfc_attr.c          | 3 +--
>  drivers/thermal/thermal_sysfs.c        | 2 +-
>  7 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
> index b8c1a85bcf2d..a919b2f0141d 100644
> --- a/arch/s390/kernel/smp.c
> +++ b/arch/s390/kernel/smp.c
> @@ -1151,7 +1151,7 @@ static ssize_t __ref rescan_store(struct device *dev,
>  	rc = smp_rescan_cpus();
>  	return rc ? rc : count;
>  }
> -static DEVICE_ATTR(rescan, 0200, NULL, rescan_store);
> +static DEVICE_ATTR_WO(rescan);
>  #endif /* CONFIG_HOTPLUG_CPU */
>  
>  static int __init s390_smp_init(void)
> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index c4fa4a85d4cb..09c74b0560dd 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
>  	return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
>  }
>  
> -static DEVICE_ATTR(reload, 0200, NULL, reload_store);
> +static DEVICE_ATTR_WO(reload);
>  static DEVICE_ATTR(version, 0400, version_show, NULL);
>  static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
>  

# cat /sys/devices/system/cpu/microcode/reload
cat: /sys/devices/system/cpu/microcode/reload: Permission denied

The reason for the code churn being?

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply

* [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO
From: Joe Perches @ 2017-12-19 18:15 UTC (permalink / raw)
  To: Borislav Petkov, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Thomas Falcon, John Allen, Inaky Perez-Gonzalez,
	linux-wimax, James Smart, Dick Kennedy, Zhang Rui,
	Eduardo Valentin
  Cc: Martin Schwidefsky, Heiko Carstens, Thomas Gleixner,
	H. Peter Anvin, x86, Dmitry Torokhov, James E.J. Bottomley,
	Martin K. Petersen, linux-s390, linux-kernel, linux-input, netdev,
	linuxppc-dev, linux-scsi, linux-pm
In-Reply-To: <cover.1513706701.git.joe@perches.com>

Convert DEVICE_ATTR uses to DEVICE_ATTR_WO where possible.

Done with perl script:

$ git grep -w --name-only DEVICE_ATTR | \
  xargs perl -i -e 'local $/; while (<>) { s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(?:\s*S_IWUSR\s*|\s*0200\s*)\)?\s*,\s*NULL\s*,\s*\s_store\s*\)/DEVICE_ATTR_WO(\1)/g; print;}'

Signed-off-by: Joe Perches <joe@perches.com>
---
 arch/s390/kernel/smp.c                 | 2 +-
 arch/x86/kernel/cpu/microcode/core.c   | 2 +-
 drivers/input/touchscreen/elants_i2c.c | 2 +-
 drivers/net/ethernet/ibm/ibmvnic.c     | 2 +-
 drivers/net/wimax/i2400m/sysfs.c       | 3 +--
 drivers/scsi/lpfc/lpfc_attr.c          | 3 +--
 drivers/thermal/thermal_sysfs.c        | 2 +-
 7 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index b8c1a85bcf2d..a919b2f0141d 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1151,7 +1151,7 @@ static ssize_t __ref rescan_store(struct device *dev,
 	rc = smp_rescan_cpus();
 	return rc ? rc : count;
 }
-static DEVICE_ATTR(rescan, 0200, NULL, rescan_store);
+static DEVICE_ATTR_WO(rescan);
 #endif /* CONFIG_HOTPLUG_CPU */
 
 static int __init s390_smp_init(void)
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index c4fa4a85d4cb..09c74b0560dd 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
 	return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
 }
 
-static DEVICE_ATTR(reload, 0200, NULL, reload_store);
+static DEVICE_ATTR_WO(reload);
 static DEVICE_ATTR(version, 0400, version_show, NULL);
 static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
 
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index a458e5ec9e41..819213e88f32 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1000,7 +1000,7 @@ static ssize_t show_iap_mode(struct device *dev,
 				"Normal" : "Recovery");
 }
 
-static DEVICE_ATTR(calibrate, S_IWUSR, NULL, calibrate_store);
+static DEVICE_ATTR_WO(calibrate);
 static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
 
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 1dc4aef37d3a..42b96e1a1b13 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -4411,7 +4411,7 @@ static ssize_t failover_store(struct device *dev, struct device_attribute *attr,
 	return count;
 }
 
-static DEVICE_ATTR(failover, 0200, NULL, failover_store);
+static DEVICE_ATTR_WO(failover);
 
 static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev)
 {
diff --git a/drivers/net/wimax/i2400m/sysfs.c b/drivers/net/wimax/i2400m/sysfs.c
index 1237109f251a..8c67df11105c 100644
--- a/drivers/net/wimax/i2400m/sysfs.c
+++ b/drivers/net/wimax/i2400m/sysfs.c
@@ -65,8 +65,7 @@ ssize_t i2400m_idle_timeout_store(struct device *dev,
 }
 
 static
-DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR,
-	    NULL, i2400m_idle_timeout_store);
+DEVICE_ATTR_WO(i2400m_idle_timeout);
 
 static
 struct attribute *i2400m_dev_attrs[] = {
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 517ff203cfde..6ddaf51a23f6 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -2418,8 +2418,7 @@ lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr,
 
 	return count;
 }
-static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
-		   lpfc_soft_wwn_enable_store);
+static DEVICE_ATTR_WO(lpfc_soft_wwn_enable);
 
 /**
  * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 2bc964392924..ba81c9080f6e 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -317,7 +317,7 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
 
 	return ret ? ret : count;
 }
-static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);
+static DEVICE_ATTR_WO(emul_temp);
 #endif
 
 static ssize_t
-- 
2.15.0

^ permalink raw reply related

* [-next PATCH 0/4] sysfs and DEVICE_ATTR_<foo>
From: Joe Perches @ 2017-12-19 18:15 UTC (permalink / raw)
  To: linux-arm-kernel, linux-acpi, openipmi-developer, intel-gfx,
	linuxppc-dev, netdev, linux-nvme, platform-driver-x86, linux-s390,
	esc.storagedev, linux-scsi, linux-pm, linux-serial, linux-usb,
	linux-kernel, alsa-devel, linux-omap
  Cc: devel, linux-fbdev, linux-sh, dri-devel, linux-input, linux-media

Joe Perches (4):
  sysfs.h: Use octal permissions
  treewide: Use DEVICE_ATTR_RW
  treewide: Use DEVICE_ATTR_RO
  treewide: Use DEVICE_ATTR_WO

 arch/arm/mach-pxa/sharpsl_pm.c                     |  4 +-
 arch/s390/kernel/smp.c                             |  2 +-
 arch/s390/kernel/topology.c                        |  3 +-
 arch/sh/drivers/push-switch.c                      |  2 +-
 arch/tile/kernel/sysfs.c                           | 12 ++--
 arch/x86/kernel/cpu/microcode/core.c               |  2 +-
 drivers/acpi/device_sysfs.c                        |  6 +-
 drivers/char/ipmi/ipmi_msghandler.c                | 17 +++---
 drivers/gpu/drm/i915/i915_sysfs.c                  | 12 ++--
 drivers/input/touchscreen/elants_i2c.c             |  2 +-
 drivers/net/ethernet/ibm/ibmvnic.c                 |  2 +-
 drivers/net/wimax/i2400m/sysfs.c                   |  3 +-
 drivers/nvme/host/core.c                           | 10 ++--
 drivers/platform/x86/compal-laptop.c               | 18 ++----
 drivers/s390/cio/css.c                             |  8 +--
 drivers/s390/cio/device.c                          | 10 ++--
 drivers/s390/crypto/ap_card.c                      |  2 +-
 drivers/scsi/hpsa.c                                | 10 ++--
 drivers/scsi/lpfc/lpfc_attr.c                      | 64 ++++++++--------------
 .../staging/media/atomisp/pci/atomisp2/hmm/hmm.c   |  8 +--
 drivers/thermal/thermal_sysfs.c                    | 17 +++---
 drivers/tty/serial/sh-sci.c                        |  2 +-
 drivers/usb/host/xhci-dbgcap.c                     |  2 +-
 drivers/usb/phy/phy-tahvo.c                        |  2 +-
 drivers/video/fbdev/auo_k190x.c                    |  4 +-
 drivers/video/fbdev/w100fb.c                       |  4 +-
 include/linux/sysfs.h                              | 14 ++---
 lib/test_firmware.c                                | 14 ++---
 lib/test_kmod.c                                    | 14 ++---
 sound/soc/omap/mcbsp.c                             |  4 +-
 sound/soc/soc-core.c                               |  2 +-
 sound/soc/soc-dapm.c                               |  2 +-
 32 files changed, 120 insertions(+), 158 deletions(-)

-- 
2.15.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply

* Re: [PATCH v1] HID: sony: Print reversed MAC address via %pMR
From: Andy Shevchenko @ 2017-12-19 17:20 UTC (permalink / raw)
  To: Colenbrander, Roelof, Jiri Kosina, Benjamin Tissoires,
	linux-input@vger.kernel.org
In-Reply-To: <1DD62093774CEE42AFC16E785A1088049E247090@USCULXMSG13.am.sony.com>

On Wed, 2017-12-13 at 02:22 +0000, Colenbrander, Roelof wrote:
> On 12/11/2017 05:07 AM, Andy Shevchenko wrote:
> > Reversed MAC addresses can be printed directly using %pMR specifier.

> Looks good and in a quick test seems to function.
> 
> Acked-by: Roderick Colenbrander <roderick.colenbranderer@sony.com>
> 

Benjamin, perhaps it's good enough to being applied?

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

^ permalink raw reply

* Re: [PATCH] touchscreen: mms114: add support for mms152
From: Andi Shyti @ 2017-12-19  9:10 UTC (permalink / raw)
  To: Simon Shields
  Cc: Dmitry Torokhov, linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20171219080409.GA27703-WP75azK+jQYgsBAKwltoeQ@public.gmane.org>

Hi Simon,

> > >  #ifdef CONFIG_OF
> > >  static const struct of_device_id mms114_dt_match[] = {
> > > -	{ .compatible = "melfas,mms114" },
> > > +	{
> > > +		.compatible = "melfas,mms114",
> > > +		.data = (void *)TYPE_MMS114,
> > > +	}, {
> > > +		.compatible = "melfas,mms152",
> > > +		.data = (void *)TYPE_MMS152,
> > 
> > You are not documenting the new "melfas,mms152" compatible in
> > Documentation/devicetree/bindings/input/touchscreen/mms114.txt
> 
> Yes I am - "melfas,mms152" is added to the documentation
> as part of this patch. Is there something wrong with what I've done
> there?

Oh yes, sorry! I missed it while snipping the code :)

Please ignore this comment, then.

Andi
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH] touchscreen: mms114: add support for mms152
From: Simon Shields @ 2017-12-19  8:04 UTC (permalink / raw)
  To: Andi Shyti
  Cc: Dmitry Torokhov, linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20171219062252.GC25647-8vUhnHFVuGn35fTxX1Dczw@public.gmane.org>

Hi Andi,

Thanks for the review.

On Tue, Dec 19, 2017 at 03:22:52PM +0900, Andi Shyti wrote:
> Hi Simon,
> 
> > +	if (data->pdata->type == TYPE_MMS152) {
> > +		/* MMS152 has no configuration or power on registers */
> > +		return 0;
> > +	}
> > +
> 
> Please drop the brackets here accorting to the
> Documentation/process/coding-style.rst file.
> 
> > +	pdata->type = (enum mms_type)of_device_get_match_data(dev);
> > +
> >  	if (of_property_read_u32(np, "x-size", &pdata->x_size)) {
> >  		dev_err(dev, "failed to get x-size property\n");
> >  		return NULL;
> > @@ -411,6 +437,7 @@ static struct mms114_platform_data *mms114_parse_dt(struct device *dev)
> >  	if (of_find_property(np, "y-invert", NULL))
> >  		pdata->y_invert = true;
> >  
> > +
> 
> Please do not add extra lines
> 
> >  	return pdata;
> >  }
> >  #else
> > @@ -456,7 +483,15 @@ static int mms114_probe(struct i2c_client *client,
> >  	data->input_dev = input_dev;
> >  	data->pdata = pdata;
> >  
> > -	input_dev->name = "MELFAS MMS114 Touchscreen";
> > +	switch (pdata->type) {
> > +	case TYPE_MMS114:
> > +		input_dev->name = "MELFAS MMS114 Touchscreen";
> > +		break;
> > +	case TYPE_MMS152:
> > +		input_dev->name = "MELFAS MMS152 Touchscreen";
> > +		break;
> > +	}
> > +
> >  	input_dev->id.bustype = BUS_I2C;
> >  	input_dev->dev.parent = &client->dev;
> >  	input_dev->open = mms114_input_open;
> > @@ -569,7 +604,13 @@ MODULE_DEVICE_TABLE(i2c, mms114_id);
> >  
> >  #ifdef CONFIG_OF
> >  static const struct of_device_id mms114_dt_match[] = {
> > -	{ .compatible = "melfas,mms114" },
> > +	{
> > +		.compatible = "melfas,mms114",
> > +		.data = (void *)TYPE_MMS114,
> > +	}, {
> > +		.compatible = "melfas,mms152",
> > +		.data = (void *)TYPE_MMS152,
> 
> You are not documenting the new "melfas,mms152" compatible in
> Documentation/devicetree/bindings/input/touchscreen/mms114.txt

Yes I am - "melfas,mms152" is added to the documentation
as part of this patch. Is there something wrong with what I've done
there?

> 
> Andi

I will send a v2 addressing the style issues.

Cheers,
Simon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH] touchscreen: mms114: add support for mms152
From: Andi Shyti @ 2017-12-19  6:22 UTC (permalink / raw)
  To: Simon Shields; +Cc: Dmitry Torokhov, linux-input, devicetree
In-Reply-To: <20171218124933.1803-1-simon@lineageos.org>

Hi Simon,

> +	if (data->pdata->type == TYPE_MMS152) {
> +		/* MMS152 has no configuration or power on registers */
> +		return 0;
> +	}
> +

Please drop the brackets here accorting to the
Documentation/process/coding-style.rst file.

> +	pdata->type = (enum mms_type)of_device_get_match_data(dev);
> +
>  	if (of_property_read_u32(np, "x-size", &pdata->x_size)) {
>  		dev_err(dev, "failed to get x-size property\n");
>  		return NULL;
> @@ -411,6 +437,7 @@ static struct mms114_platform_data *mms114_parse_dt(struct device *dev)
>  	if (of_find_property(np, "y-invert", NULL))
>  		pdata->y_invert = true;
>  
> +

Please do not add extra lines

>  	return pdata;
>  }
>  #else
> @@ -456,7 +483,15 @@ static int mms114_probe(struct i2c_client *client,
>  	data->input_dev = input_dev;
>  	data->pdata = pdata;
>  
> -	input_dev->name = "MELFAS MMS114 Touchscreen";
> +	switch (pdata->type) {
> +	case TYPE_MMS114:
> +		input_dev->name = "MELFAS MMS114 Touchscreen";
> +		break;
> +	case TYPE_MMS152:
> +		input_dev->name = "MELFAS MMS152 Touchscreen";
> +		break;
> +	}
> +
>  	input_dev->id.bustype = BUS_I2C;
>  	input_dev->dev.parent = &client->dev;
>  	input_dev->open = mms114_input_open;
> @@ -569,7 +604,13 @@ MODULE_DEVICE_TABLE(i2c, mms114_id);
>  
>  #ifdef CONFIG_OF
>  static const struct of_device_id mms114_dt_match[] = {
> -	{ .compatible = "melfas,mms114" },
> +	{
> +		.compatible = "melfas,mms114",
> +		.data = (void *)TYPE_MMS114,
> +	}, {
> +		.compatible = "melfas,mms152",
> +		.data = (void *)TYPE_MMS152,

You are not documenting the new "melfas,mms152" compatible in
Documentation/devicetree/bindings/input/touchscreen/mms114.txt

Andi

^ 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;
as well as URLs for NNTP newsgroup(s).