Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: mcs5000_ts: Delete an error message for a failed memory allocation in mcs5000_ts_probe()
From: SF Markus Elfring @ 2018-01-21 18:19 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Günter Röck, Wolfram Sang
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 19:14:15 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/mcs5000_ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c
index 8868573133ab..ca3c5f78ab55 100644
--- a/drivers/input/touchscreen/mcs5000_ts.c
+++ b/drivers/input/touchscreen/mcs5000_ts.c
@@ -198,10 +198,8 @@ static int mcs5000_ts_probe(struct i2c_client *client,
 		return -EINVAL;
 
 	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		dev_err(&client->dev, "Failed to allocate memory\n");
+	if (!data)
 		return -ENOMEM;
-	}
 
 	data->client = client;
 
-- 
2.16.0


^ permalink raw reply related

* [PATCH 0/2] Input-egalax_ts: Adjustments for egalax_ts_probe()
From: SF Markus Elfring @ 2018-01-21 18:49 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Günter Röck; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 19:46:54 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an error message for a failed memory allocation
  Improve a size determination

 drivers/input/touchscreen/egalax_ts.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

-- 
2.16.0


^ permalink raw reply

* [PATCH 1/2] Input: egalax_ts: Delete an error message for a failed memory allocation in egalax_ts_probe()
From: SF Markus Elfring @ 2018-01-21 18:50 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Günter Röck; +Cc: LKML, kernel-janitors
In-Reply-To: <52f0c32d-2cf9-bef3-4fb3-4120c5b758c4@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 19:34:38 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/egalax_ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 752ae9cf4514..29ec1166626d 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -172,10 +172,8 @@ static int egalax_ts_probe(struct i2c_client *client,
 	int error;
 
 	ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL);
-	if (!ts) {
-		dev_err(&client->dev, "Failed to allocate memory\n");
+	if (!ts)
 		return -ENOMEM;
-	}
 
 	input_dev = devm_input_allocate_device(&client->dev);
 	if (!input_dev) {
-- 
2.16.0

^ permalink raw reply related

* [PATCH 2/2] Input: egalax_ts: Improve a size determination in egalax_ts_probe()
From: SF Markus Elfring @ 2018-01-21 18:51 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Günter Röck; +Cc: LKML, kernel-janitors
In-Reply-To: <52f0c32d-2cf9-bef3-4fb3-4120c5b758c4@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 19:40:30 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/egalax_ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 29ec1166626d..da8b46ee2c1c 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -171,7 +171,7 @@ static int egalax_ts_probe(struct i2c_client *client,
 	struct input_dev *input_dev;
 	int error;
 
-	ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL);
+	ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
 	if (!ts)
 		return -ENOMEM;
 
-- 
2.16.0


^ permalink raw reply related

* [PATCH] Input: eeti_ts: Delete an error message for a failed memory allocation in eeti_ts_probe()
From: SF Markus Elfring @ 2018-01-21 19:05 UTC (permalink / raw)
  To: linux-input, Daniel Mack, Dmitry Torokhov, Günter Röck
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:00:03 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/eeti_ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 2facad75eb6d..337f171e0f86 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -161,10 +161,8 @@ static int eeti_ts_probe(struct i2c_client *client,
 	 */
 
 	eeti = devm_kzalloc(dev, sizeof(*eeti), GFP_KERNEL);
-	if (!eeti) {
-		dev_err(dev, "failed to allocate driver data\n");
+	if (!eeti)
 		return -ENOMEM;
-	}
 
 	input = devm_input_allocate_device(dev);
 	if (!input) {
-- 
2.16.0

^ permalink raw reply related

* [PATCH] Input: edt-ft5x06: Delete an error message for a failed memory allocation in edt_ft5x06_ts_probe()
From: SF Markus Elfring @ 2018-01-21 19:19 UTC (permalink / raw)
  To: linux-input, Andi Shyti, Dmitry Torokhov, Günter Röck,
	Martin Kepplinger, Rob Herring, Simon Budig,
	Stefan Schöfegger
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:10:03 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/edt-ft5x06.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index c53a3d7239e7..9d2799c90150 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -978,10 +978,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
 
 	tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL);
-	if (!tsdata) {
-		dev_err(&client->dev, "failed to allocate driver data.\n");
+	if (!tsdata)
 		return -ENOMEM;
-	}
 
 	chip_data = of_device_get_match_data(&client->dev);
 	if (!chip_data)
-- 
2.16.0

^ permalink raw reply related

* [PATCH 0/2] Input: da9034-ts: Adjustments for da9034_touch_probe()
From: SF Markus Elfring @ 2018-01-21 19:46 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:42:24 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an error message for a failed memory allocation
  Improve a size determination

 drivers/input/touchscreen/da9034-ts.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

-- 
2.16.0


^ permalink raw reply

* [PATCH 1/2] Input: da9034-ts: Delete an error message for a failed memory allocation in da9034_touch_probe()
From: SF Markus Elfring @ 2018-01-21 19:47 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: LKML, kernel-janitors
In-Reply-To: <44ae37ef-deaa-c963-e0f7-c407159afa0c@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:32:48 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/da9034-ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c
index 8264822dc4b9..b30cfe1e62da 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -305,10 +305,8 @@ static int da9034_touch_probe(struct platform_device *pdev)
 
 	touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch),
 			     GFP_KERNEL);
-	if (!touch) {
-		dev_err(&pdev->dev, "failed to allocate driver data\n");
+	if (!touch)
 		return -ENOMEM;
-	}
 
 	touch->da9034_dev = pdev->dev.parent;
 
-- 
2.16.0


^ permalink raw reply related

* [PATCH 2/2] Input: da9034-ts: Improve a size determination in da9034_touch_probe()
From: SF Markus Elfring @ 2018-01-21 19:48 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: LKML, kernel-janitors
In-Reply-To: <44ae37ef-deaa-c963-e0f7-c407159afa0c@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:36:20 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/da9034-ts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c
index b30cfe1e62da..c9c423aebe1e 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -303,8 +303,7 @@ static int da9034_touch_probe(struct platform_device *pdev)
 	struct input_dev *input_dev;
 	int error;
 
-	touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch),
-			     GFP_KERNEL);
+	touch = devm_kzalloc(&pdev->dev, sizeof(*touch), GFP_KERNEL);
 	if (!touch)
 		return -ENOMEM;
 
-- 
2.16.0


^ permalink raw reply related

* Proposal
From: Ms Melisa Mehmet @ 2018-01-21 18:17 UTC (permalink / raw)




-- 
Hello 

i want to invest in your region i have some funds under my management
please let me know if we can work together on this investment plan.

Regards 
Melisa Mehmet

^ permalink raw reply

* Re: [PATCH] Input: trackpoint - force 3 buttons if 0 button is reported
From: ulrik.debie-os @ 2018-01-21 20:10 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Aaron Ma, linux-input, linux-kernel
In-Reply-To: <20180116230713.rppztybwe5ufhoxo@dtor-ws>

On Tue, Jan 16, 2018 at 03:07:13PM -0800, Dmitry Torokhov wrote:
Hi Dmitry,

> 
> On Sat, Jan 13, 2018 at 10:34:19AM +0800, Aaron Ma wrote:
> > Will your patch go to stable kernel?
> > If yes, that's fine.
> 
> Hmm, it looks like we need this patch after all as we do have screwy
> Lenovos with apparently 0x01 devices reporting 0 buttons. From
> https://bugzilla.kernel.org/show_bug.cgi?id=196253
> 
>  thinkpad_acpi: ThinkPad BIOS R0DET87W (1.87 ), EC unknown
>  thinkpad_acpi: Lenovo ThinkPad E470, model 20H1004SGE
> 
>  psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 0/0
> 
> I'll ask them to try my patch and if it is indeed 0x01 device I'll apply
> your patch.

It is quite strange. In the past,for commit 293b915fd9be 
"Input: trackpoint - assume 3 buttons when buttons detection fails" there was
success reported for lenovo e470 and I see the same success report in that
bugzilla ticket.  I can also report success on lenovo e570.

But some seem to have problems, could it be that they are not including that
commit in the kernel they are running ? Or did a bios upgrade change the
behaviour ?
It would be best when we have a confirmation from a e470 owner that without the
proposed patch from Aaron the middle button does not work on his e470, and it
works with it.


Kind regards,
Ulrik

^ permalink raw reply

* Re: [PATCH 5/7] Input: libps2 - add debugging statements
From: ulrik.debie-os @ 2018-01-21 20:22 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Benjamin Tissoires, Hans de Goede, Lyude Paul, linux-input,
	linux-kernel
In-Reply-To: <20180119194111.185590-6-dmitry.torokhov@gmail.com>


Hi,

the patch series looks nice, but best to also include the procedure
described here in Documentation/input somewhere. I would not expect
everyone to dig into git commit logs to find the howto :)

Best regards,
Ulrik


On Fri, Jan 19, 2018 at 11:41:09AM -0800, Dmitry Torokhov wrote:
> Date:   Fri, 19 Jan 2018 11:41:09 -0800
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> To: Benjamin Tissoires <benjamin.tissoires@redhat.com>, Hans de Goede
>  <hdegoede@redhat.com>, Lyude Paul <lyude@redhat.com>
> Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: [PATCH 5/7] Input: libps2 - add debugging statements
> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog
> X-Mailing-List: linux-input@vger.kernel.org
> 
> Debugging via i8042.debug and analyzing raw PS/2 data stream may be
> cumbersome as you need to locate the boundaries of commands, decipher the
> sliced commands, etc, etc. Let's add a bit more high level debug statements
> for ps2_sendbyte(), ps2_command(), and ps2_sliced_command().
> 
> We do not introduce a new module parameter, but rater rely on the kernel
> having dynamic debug facility enabled (which most everyone has nowadays).
> Enable with:
> 
> echo "file libps2.c +pf" > /sys/kernel/debug/dynamic_debug/control
> 
> or add "libps2.dyndbg=+pf" to the kernel command line.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/serio/libps2.c | 52 +++++++++++++++++++++++++++++++++-----------
>  1 file changed, 39 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
> index e96ae477f0b56..82befae4dab04 100644
> --- a/drivers/input/serio/libps2.c
> +++ b/drivers/input/serio/libps2.c
> @@ -26,22 +26,20 @@ MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
>  MODULE_DESCRIPTION("PS/2 driver library");
>  MODULE_LICENSE("GPL");
>  
> -/*
> - * ps2_sendbyte() sends a byte to the device and waits for acknowledge.
> - * It doesn't handle retransmission, though it could - because if there
> - * is a need for retransmissions device has to be replaced anyway.
> - *
> - * ps2_sendbyte() can only be called from a process context.
> - */
> -
> -int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout)
> +static int ps2_do_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout)
>  {
> +	int error;
> +
>  	serio_pause_rx(ps2dev->serio);
>  	ps2dev->nak = 1;
>  	ps2dev->flags |= PS2_FLAG_ACK;
>  	serio_continue_rx(ps2dev->serio);
>  
> -	if (serio_write(ps2dev->serio, byte) == 0)
> +	error = serio_write(ps2dev->serio, byte);
> +	if (error)
> +		dev_dbg(&ps2dev->serio->dev,
> +			"failed to write %#02x: %d\n", byte, error);
> +	else
>  		wait_event_timeout(ps2dev->wait,
>  				   !(ps2dev->flags & PS2_FLAG_ACK),
>  				   msecs_to_jiffies(timeout));
> @@ -52,6 +50,24 @@ int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout)
>  
>  	return -ps2dev->nak;
>  }
> +
> +/*
> + * ps2_sendbyte() sends a byte to the device and waits for acknowledge.
> + * It doesn't handle retransmission, though it could - because if there
> + * is a need for retransmissions device has to be replaced anyway.
> + *
> + * ps2_sendbyte() can only be called from a process context.
> + */
> +
> +int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout)
> +{
> +	int retval;
> +
> +	retval = ps2_do_sendbyte(ps2dev, byte, timeout);
> +	dev_dbg(&ps2dev->serio->dev, "%02x - %x\n", byte, ps2dev->nak);
> +
> +	return retval;
> +}
>  EXPORT_SYMBOL(ps2_sendbyte);
>  
>  void ps2_begin_command(struct ps2dev *ps2dev)
> @@ -186,6 +202,7 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
>  	unsigned int receive = (command >> 8) & 0xf;
>  	int rc = -1;
>  	int i;
> +	u8 send_param[16];
>  
>  	if (receive > sizeof(ps2dev->cmdbuf)) {
>  		WARN_ON(1);
> @@ -197,6 +214,8 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
>  		return -1;
>  	}
>  
> +	memcpy(send_param, param, send);
> +
>  	serio_pause_rx(ps2dev->serio);
>  	ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
>  	ps2dev->cmdcnt = receive;
> @@ -210,14 +229,14 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
>  	 * ACKing the reset command, and so it can take a long
>  	 * time before the ACK arrives.
>  	 */
> -	if (ps2_sendbyte(ps2dev, command & 0xff,
> -			 command == PS2_CMD_RESET_BAT ? 1000 : 200)) {
> +	if (ps2_do_sendbyte(ps2dev, command & 0xff,
> +			    command == PS2_CMD_RESET_BAT ? 1000 : 200)) {
>  		serio_pause_rx(ps2dev->serio);
>  		goto out_reset_flags;
>  	}
>  
>  	for (i = 0; i < send; i++) {
> -		if (ps2_sendbyte(ps2dev, param[i], 200)) {
> +		if (ps2_do_sendbyte(ps2dev, param[i], 200)) {
>  			serio_pause_rx(ps2dev->serio);
>  			goto out_reset_flags;
>  		}
> @@ -253,6 +272,12 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
>  	ps2dev->flags = 0;
>  	serio_continue_rx(ps2dev->serio);
>  
> +	dev_dbg(&ps2dev->serio->dev,
> +		"%02x [%*ph] - %x/%08lx [%*ph]\n",
> +		command & 0xff, send, send_param,
> +		ps2dev->nak, ps2dev->flags,
> +		receive, param ?: send_param);
> +
>  	return rc;
>  }
>  EXPORT_SYMBOL(__ps2_command);
> @@ -296,6 +321,7 @@ int ps2_sliced_command(struct ps2dev *ps2dev, u8 command)
>  	}
>  
>  out:
> +	dev_dbg(&ps2dev->serio->dev, "%02x - %d\n", command, retval);
>  	ps2_end_command(ps2dev);
>  	return retval;
>  }
> -- 
> 2.16.0.rc1.238.g530d649a79-goog
> 
> --
> 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 0/3] Input-cyttsp4_core: Adjustments for some function implementations
From: SF Markus Elfring @ 2018-01-21 20:26 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 21:23:45 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Delete two error messages for a failed memory allocation in cyttsp4_probe()
  Delete an unnecessary return statement in three functions
  Adjust 13 checks for null pointers

 drivers/input/touchscreen/cyttsp4_core.c | 33 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

-- 
2.16.0


^ permalink raw reply

* [PATCH 1/3] Input: cyttsp4_core: Delete two error messages for a failed memory allocation in cyttsp4_probe()
From: SF Markus Elfring @ 2018-01-21 20:27 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors
In-Reply-To: <61183426-0b2a-4b93-933c-a2dfd487d92b@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:57:40 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/cyttsp4_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index 727c3232517c..f0bf3cc20e9d 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -2037,14 +2037,12 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops,
 
 	cd = kzalloc(sizeof(*cd), GFP_KERNEL);
 	if (!cd) {
-		dev_err(dev, "%s: Error, kzalloc\n", __func__);
 		rc = -ENOMEM;
 		goto error_alloc_data;
 	}
 
 	cd->xfer_buf = kzalloc(xfer_buf_size, GFP_KERNEL);
 	if (!cd->xfer_buf) {
-		dev_err(dev, "%s: Error, kzalloc\n", __func__);
 		rc = -ENOMEM;
 		goto error_free_cd;
 	}
-- 
2.16.0

^ permalink raw reply related

* [PATCH 2/3] Input: cyttsp4_core: Delete an unnecessary return statement in three functions
From: SF Markus Elfring @ 2018-01-21 20:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors
In-Reply-To: <61183426-0b2a-4b93-933c-a2dfd487d92b@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 21:13:21 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/cyttsp4_core.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index f0bf3cc20e9d..35f48b66ff36 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -956,8 +956,6 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch)
 	cyttsp4_final_sync(md->input, si->si_ofs.tch_abs[CY_TCH_T].max, ids);
 
 	md->num_prv_tch = num_cur_tch;
-
-	return;
 }
 
 /* read xy_data for all current touches */
@@ -1272,8 +1270,6 @@ static void cyttsp4_watchdog_timer(struct timer_list *t)
 	dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__);
 
 	schedule_work(&cd->watchdog_work);
-
-	return;
 }
 
 static int cyttsp4_request_exclusive(struct cyttsp4 *cd, void *ownptr,
@@ -1492,7 +1488,6 @@ static void cyttsp4_watchdog_work(struct work_struct *work)
 	cyttsp4_start_wd_timer(cd);
 cyttsp4_timer_watchdog_exit_error:
 	mutex_unlock(&cd->system_lock);
-	return;
 }
 
 static int cyttsp4_core_sleep_(struct cyttsp4 *cd)
-- 
2.16.0

^ permalink raw reply related

* [PATCH 3/3] Input: cyttsp4_core: Adjust 13 checks for null pointers
From: SF Markus Elfring @ 2018-01-21 20:30 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors
In-Reply-To: <61183426-0b2a-4b93-933c-a2dfd487d92b@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 21:15:11 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/cyttsp4_core.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index 35f48b66ff36..32a4a45554fe 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -213,7 +213,7 @@ static int cyttsp4_si_get_cydata(struct cyttsp4 *cd)
 			si->si_ofs.cydata_size);
 
 	p = krealloc(si->si_ptrs.cydata, si->si_ofs.cydata_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate cydata memory\n",
 			__func__);
 		return -ENOMEM;
@@ -288,7 +288,7 @@ static int cyttsp4_si_get_test_data(struct cyttsp4 *cd)
 	si->si_ofs.test_size = si->si_ofs.pcfg_ofs - si->si_ofs.test_ofs;
 
 	p = krealloc(si->si_ptrs.test, si->si_ofs.test_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate test memory\n",
 			__func__);
 		return -ENOMEM;
@@ -347,7 +347,7 @@ static int cyttsp4_si_get_pcfg_data(struct cyttsp4 *cd)
 	si->si_ofs.pcfg_size = si->si_ofs.opcfg_ofs - si->si_ofs.pcfg_ofs;
 
 	p = krealloc(si->si_ptrs.pcfg, si->si_ofs.pcfg_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate pcfg memory\n",
 			__func__);
 		return -ENOMEM;
@@ -399,7 +399,7 @@ static int cyttsp4_si_get_opcfg_data(struct cyttsp4 *cd)
 	si->si_ofs.opcfg_size = si->si_ofs.ddata_ofs - si->si_ofs.opcfg_ofs;
 
 	p = krealloc(si->si_ptrs.opcfg, si->si_ofs.opcfg_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate opcfg memory\n",
 			__func__);
 		return -ENOMEM;
@@ -488,7 +488,7 @@ static int cyttsp4_si_get_ddata(struct cyttsp4 *cd)
 	si->si_ofs.ddata_size = si->si_ofs.mdata_ofs - si->si_ofs.ddata_ofs;
 
 	p = krealloc(si->si_ptrs.ddata, si->si_ofs.ddata_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: fail alloc ddata memory\n", __func__);
 		return -ENOMEM;
 	}
@@ -515,7 +515,7 @@ static int cyttsp4_si_get_mdata(struct cyttsp4 *cd)
 	si->si_ofs.mdata_size = si->si_ofs.map_sz - si->si_ofs.mdata_ofs;
 
 	p = krealloc(si->si_ptrs.mdata, si->si_ofs.mdata_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: fail alloc mdata memory\n", __func__);
 		return -ENOMEM;
 	}
@@ -548,16 +548,16 @@ static int cyttsp4_si_get_btn_data(struct cyttsp4 *cd)
 
 		p = krealloc(si->btn, si->si_ofs.btn_keys_size,
 				GFP_KERNEL|__GFP_ZERO);
-		if (p == NULL) {
+		if (!p) {
 			dev_err(cd->dev, "%s: %s\n", __func__,
 				"fail alloc btn_keys memory");
 			return -ENOMEM;
 		}
 		si->btn = p;
 
-		if (cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS] == NULL)
+		if (!cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS])
 			num_defined_keys = 0;
-		else if (cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS]->data == NULL)
+		else if (!cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS]->data)
 			num_defined_keys = 0;
 		else
 			num_defined_keys = cd->cpdata->sett
@@ -592,19 +592,19 @@ static int cyttsp4_si_get_op_data_ptrs(struct cyttsp4 *cd)
 	void *p;
 
 	p = krealloc(si->xy_mode, si->si_ofs.mode_size, GFP_KERNEL|__GFP_ZERO);
-	if (p == NULL)
+	if (!p)
 		return -ENOMEM;
 	si->xy_mode = p;
 
 	p = krealloc(si->xy_data, si->si_ofs.data_size, GFP_KERNEL|__GFP_ZERO);
-	if (p == NULL)
+	if (!p)
 		return -ENOMEM;
 	si->xy_data = p;
 
 	p = krealloc(si->btn_rec_data,
 			si->si_ofs.btn_rec_size * si->si_ofs.num_btns,
 			GFP_KERNEL|__GFP_ZERO);
-	if (p == NULL)
+	if (!p)
 		return -ENOMEM;
 	si->btn_rec_data = p;
 
@@ -1977,7 +1977,7 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd)
 	dev_vdbg(dev, "%s: Create the input device and register it\n",
 		__func__);
 	md->input = input_allocate_device();
-	if (md->input == NULL) {
+	if (!md->input) {
 		dev_err(dev, "%s: Error, failed to allocate input device\n",
 			__func__);
 		rc = -ENOSYS;
-- 
2.16.0


^ permalink raw reply related

* Re: [PATCH] Revert "Input: trackpoint - add new trackpoint firmware ID"
From: ulrik.debie-os @ 2018-01-21 20:37 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Aaron Ma, Greg KH, Sebastian Schmidt, linux-input
In-Reply-To: <20180116234919.c7xgfllsf62g4fw4@dtor-ws>

On Tue, Jan 16, 2018 at 03:49:19PM -0800, Dmitry Torokhov wrote:
> 
> Hi Ulrik,
> 
> 
> On Sun, Jan 14, 2018 at 09:39:59PM +0100, ulrik.debie-os@e2big.org wrote:
> > Hi Dmitry, Sebastian,
> > Nack for the patch..
> 
> NAK because of the issue pointed by Sebastian, or bigger disagreement?
I originally had 2 reasons:
1) issue pointed out by Sebastian, of course easy to fix
2) The remark I had below which was because I did not understand yet the reason
why you made this patch in the first place. I now understand it is not the 
purpose to change anything for the Lenovo e470/e570 and it will also not change
anything for those if you at least fix nr 1) 


Thanks,
best regards,
Ulrik

> 
> > As Sebastian pointed out, the trackpoint detection will always report an error. (see below)
> > 
> > I builded your original patch and it resulted in detection as generic mouse for the trackpoint:
> > 
> > [    0.838143] serio: i8042 KBD port at 0x60,0x64 irq 1
> > [    0.838146] serio: i8042 AUX port at 0x60,0x64 irq 12
> > [    0.838267] mousedev: PS/2 mouse device common for all mice
> > [    9.321140] psmouse serio1: synaptics: queried max coordinates: x [..5676], y [..4758]
> > [    9.367095] psmouse serio1: synaptics: queried min coordinates: x [1266..], y [1096..]
> > [    9.367103] psmouse serio1: synaptics: The touchpad can support a better bus than the too old PS/2 protocol. Make sure MOUSE_PS2_SYNAPTICS_SMBUS and RMI4_SMB are enabled to get a better touchpad experience.
> > [    9.455953] psmouse serio1: synaptics: Touchpad model: 1, fw: 8.2, id: 0x1e2b1, caps: 0xf007a3/0x943300/0x12e800/0x410000, board id: 3157, fw id: 2405942
> > [    9.455970] psmouse serio1: synaptics: serio: Synaptics pass-through port at isa0060/serio1/input0
> > [    9.514117] input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio1/input/input7
> > [   11.458443] input: PS/2 Generic Mouse as /devices/platform/i8042/serio1/serio2/input/input18
> > 
> > When I fixed your patch, it resulted in: (timing difference is because a dvd was inserted before)
> > [    0.843661] serio: i8042 KBD port at 0x60,0x64 irq 1
> > [    0.843664] serio: i8042 AUX port at 0x60,0x64 irq 12
> > [    0.843793] mousedev: PS/2 mouse device common for all mice
> > [    3.822411] psmouse serio1: synaptics: queried max coordinates: x [..5676], y [..4758]
> > [    3.868196] psmouse serio1: synaptics: queried min coordinates: x [1266..], y [1096..]
> > [    3.868203] psmouse serio1: synaptics: The touchpad can support a better bus than the too old PS/2 protocol. Make sure MOUSE_PS2_SYNAPTICS_SMBUS and RMI4_SMB are enabled to get a better touchpad experience.
> > [    3.961024] psmouse serio1: synaptics: Touchpad model: 1, fw: 8.2, id: 0x1e2b1, caps: 0xf007a3/0x943300/0x12e800/0x410000, board id: 3157, fw id: 2405942
> > [    3.961038] psmouse serio1: synaptics: serio: Synaptics pass-through port at isa0060/serio1/input0
> > [    4.017290] input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio1/input/input7
> > [    4.407930] psmouse serio2: trackpoint: failed to get extended button data, assuming 3 buttons
> > [    8.460022] psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 3/3
> > [    8.740439] input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio1/serio2/input/input18
> > 
> > functionally both versions (with/without bug) resulted in a functional trackpoint with 3 buttons.
> > 
> > Sebastian, with regards to your middle button question, as you can see in the output I've such hardware. (lenovo e570).
> > 
> > Dimitrios, wasn't it your intention that this hardware would be detected as NON IBM ? Apparently it
> > is IBM and still fails "Read Extended Button Status".
> 
> Only devices reporting 0x02, 0x03 or 0x04 as the first byte of the
> xetended ID command should be identified as non-IBM. If device responds
> with 0x01 then we have to assume it is proper IBM. Your appears to be
> reporting 0x01 0x0e, like the real trackpoint would. Unfortunately it
> seems Lenovo managed to mess up the firmware in those.
> 
> Thanks.
> 
> > 
> > Kind regards,
> > Ulrik
> > 
> > On Sat, Jan 06, 2018 at 10:52:01PM -0800, Dmitry Torokhov wrote:
> > > Date:   Sat, 6 Jan 2018 22:52:01 -0800
> > > From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > To: Aaron Ma <aaron.ma@canonical.com>
> > > Cc: Greg KH <gregkh@linuxfoundation.org>, Sebastian Schmidt <yath@yath.de>,
> > >  linux-input@vger.kernel.org
> > > Subject: Re: [PATCH] Revert "Input: trackpoint - add new trackpoint
> > >  firmware ID"
> > > X-Mailing-List: linux-input@vger.kernel.org
> > > 
> > > On Fri, Jan 05, 2018 at 08:23:13AM -0800, Dmitry Torokhov wrote:
> > > > Hi Aaron,
> > > > 
> > > > On Fri, Jan 05, 2018 at 09:29:26PM +0800, Aaron Ma wrote:
> > > > > Hi Dmitry:
> > > > > 
> > > > > Got the official info from Lenovo:
> > > > > Lenovo introduced new TrackPoint compatible sticks ( ELAN/Alps/NXP
> > > > > sticks) from 2016.
> > > > > These new devices only support the minimum commands described in the
> > > > > spec, which has been used in the current Windows driver.
> > > > 
> > > > What is the exact list of the commands supported by each variant?
> > > > 
> > > > > 
> > > > > Legacy TrackPoint: 0101 – 0E01
> > > > > ALPS: 0102 – FF02
> > > > > ELAN:0103 – FF03
> > > > > NXP: 0104 – FF04
> > > > > 
> > > > > 2.4.18 READ SECONDARY ID (x"E1")
> > > > > This command will read the secondary device ID of the pointing device (2
> > > > > bytes).  The least significant byte is sent first.  For the first byte,
> > > > > the legacy TrackPoint controller from IBM will always return x"01", the
> > > > > pointing stick from ALPS will always return x"02", the pointing stick
> > > > > from Elan will always return x"03”, and the pointing stick from NXP will
> > > > > always return 0x”04".  And a second byte which denotes a specific set of
> > > > > functional specifications.  Differing ROM versions are used to denote
> > > > > changes within a given functional set.
> > > > 
> > > > Can you/Lenovo share the updated spec?
> > > > 
> > > > > 
> > > > > The new devices (include Legacy ID:01) will not support the sysfs like
> > > > > speed.
> > > > > 
> > > > > So it is not right to revert the commit, it is about to add another 0x04
> > > > > ID in it.
> > > > > 
> > > > > Old sysfs could be stayed for old legacy device ID:01 or removed.
> > > > 
> > > > No, because there are devices that have trackpoints properly
> > > > implementing the protocol, before Lenovo started their "innovation".
> > > > 
> > > > Do we have any way to distinguish between properly implemented
> > > > trackpoints and Lenovo "improved" ones? I played with gen3 Carbon, and
> > > > while it does not error out on "speed" attribute, unlike gen5, it still
> > > > has no visible effects. Additionally, the "press to select"
> > > > functionality seems to be disabled, and trying to enable it via sysfs
> > > > results in register content being reverted to the original "disabled"
> > > > setting in a second or two. Setting to swap X and Y axes does not work
> > > > either, not sure about other bits of that control register.
> > > > "sensitivity" does work though, again unlike my gen5.
> > > > 
> > > > Thanks.
> > > > 
> > > > -- 
> > > > Dmitry
> > > 
> > > Guys, could you please try the patch below? It will not solve the
> > > "speed" issue on 0x01 devices, but hopefully we won't be exposing
> > > non-existing controls on others.
> > > 
> > > Thanks!
> > > 
> > > -- 
> > > Dmitry
> > > 
> > > 
> > > Input: trackpoint - only expose supported controls for Elan, ALPS and NXP
> > > 
> > > From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > 
> > > The newer trackpoints from ALPS, Elan and NXP implement a very limited
> > > subset of extended commands and controls that the original trackpoints
> > > implemented, so we should not be exposing not working controls in sysfs.
> > > The newer trackpoints also do not implement "Power On Reset" or "Read
> > > Extended Button Status", so we should not be using these commands during
> > > initialization.
> > > 
> > > While we are at it, let's change "unsigned char" to u8 for byte data or
> > > bool for booleans and use better suited error codes instead of -1.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > ---
> > >  drivers/input/mouse/trackpoint.c |  241 +++++++++++++++++++++++---------------
> > >  drivers/input/mouse/trackpoint.h |   34 +++--
> > >  2 files changed, 168 insertions(+), 107 deletions(-)
> > > 
> > > diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
> > > index 0871010f18d5..0ca80f465359 100644
> > > --- a/drivers/input/mouse/trackpoint.c
> > > +++ b/drivers/input/mouse/trackpoint.c
> > > @@ -19,6 +19,13 @@
> > >  #include "psmouse.h"
> > >  #include "trackpoint.h"
> > >  
> > > +static const char * const trackpoint_variants[] = {
> > > +	[TP_VARIANT_IBM]	= "IBM",
> > > +	[TP_VARIANT_ALPS]	= "ALPS",
> > > +	[TP_VARIANT_ELAN]	= "Elan",
> > > +	[TP_VARIANT_NXP]	= "NXP",
> > > +};
> > > +
> > >  /*
> > >   * Power-on Reset: Resets all trackpoint parameters, including RAM values,
> > >   * to defaults.
> > > @@ -26,7 +33,7 @@
> > >   */
> > >  static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
> > >  {
> > > -	unsigned char results[2];
> > > +	u8 results[2];
> > >  	int tries = 0;
> > >  
> > >  	/* Issue POR command, and repeat up to once if 0xFC00 received */
> > > @@ -38,7 +45,7 @@ static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
> > >  
> > >  	/* Check for success response -- 0xAA00 */
> > >  	if (results[0] != 0xAA || results[1] != 0x00)
> > > -		return -1;
> > > +		return -ENODEV;
> > >  
> > >  	return 0;
> > >  }
> > > @@ -46,8 +53,7 @@ static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
> > >  /*
> > >   * Device IO: read, write and toggle bit
> > >   */
> > > -static int trackpoint_read(struct ps2dev *ps2dev,
> > > -			   unsigned char loc, unsigned char *results)
> > > +static int trackpoint_read(struct ps2dev *ps2dev, u8 loc, u8 *results)
> > >  {
> > >  	if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) ||
> > >  	    ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) {
> > > @@ -57,8 +63,7 @@ static int trackpoint_read(struct ps2dev *ps2dev,
> > >  	return 0;
> > >  }
> > >  
> > > -static int trackpoint_write(struct ps2dev *ps2dev,
> > > -			    unsigned char loc, unsigned char val)
> > > +static int trackpoint_write(struct ps2dev *ps2dev, u8 loc, u8 val)
> > >  {
> > >  	if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) ||
> > >  	    ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) ||
> > > @@ -70,8 +75,7 @@ static int trackpoint_write(struct ps2dev *ps2dev,
> > >  	return 0;
> > >  }
> > >  
> > > -static int trackpoint_toggle_bit(struct ps2dev *ps2dev,
> > > -				 unsigned char loc, unsigned char mask)
> > > +static int trackpoint_toggle_bit(struct ps2dev *ps2dev, u8 loc, u8 mask)
> > >  {
> > >  	/* Bad things will happen if the loc param isn't in this range */
> > >  	if (loc < 0x20 || loc >= 0x2F)
> > > @@ -87,11 +91,11 @@ static int trackpoint_toggle_bit(struct ps2dev *ps2dev,
> > >  	return 0;
> > >  }
> > >  
> > > -static int trackpoint_update_bit(struct ps2dev *ps2dev, unsigned char loc,
> > > -				 unsigned char mask, unsigned char value)
> > > +static int trackpoint_update_bit(struct ps2dev *ps2dev,
> > > +				 u8 loc, u8 mask, u8 value)
> > >  {
> > >  	int retval = 0;
> > > -	unsigned char data;
> > > +	u8 data;
> > >  
> > >  	trackpoint_read(ps2dev, loc, &data);
> > >  	if (((data & mask) == mask) != !!value)
> > > @@ -105,17 +109,18 @@ static int trackpoint_update_bit(struct ps2dev *ps2dev, unsigned char loc,
> > >   */
> > >  struct trackpoint_attr_data {
> > >  	size_t field_offset;
> > > -	unsigned char command;
> > > -	unsigned char mask;
> > > -	unsigned char inverted;
> > > -	unsigned char power_on_default;
> > > +	u8 command;
> > > +	u8 mask;
> > > +	bool inverted;
> > > +	u8 power_on_default;
> > >  };
> > >  
> > > -static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf)
> > > +static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse,
> > > +					void *data, char *buf)
> > >  {
> > >  	struct trackpoint_data *tp = psmouse->private;
> > >  	struct trackpoint_attr_data *attr = data;
> > > -	unsigned char value = *(unsigned char *)((char *)tp + attr->field_offset);
> > > +	u8 value = *(u8 *)((void *)tp + attr->field_offset);
> > >  
> > >  	if (attr->inverted)
> > >  		value = !value;
> > > @@ -128,8 +133,8 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
> > >  {
> > >  	struct trackpoint_data *tp = psmouse->private;
> > >  	struct trackpoint_attr_data *attr = data;
> > > -	unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
> > > -	unsigned char value;
> > > +	u8 *field = (void *)tp + attr->field_offset;
> > > +	u8 value;
> > >  	int err;
> > >  
> > >  	err = kstrtou8(buf, 10, &value);
> > > @@ -157,17 +162,14 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
> > >  {
> > >  	struct trackpoint_data *tp = psmouse->private;
> > >  	struct trackpoint_attr_data *attr = data;
> > > -	unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
> > > -	unsigned int value;
> > > +	bool *field = (void *)tp + attr->field_offset;
> > > +	bool value;
> > >  	int err;
> > >  
> > > -	err = kstrtouint(buf, 10, &value);
> > > +	err = kstrtobool(buf, &value);
> > >  	if (err)
> > >  		return err;
> > >  
> > > -	if (value > 1)
> > > -		return -EINVAL;
> > > -
> > >  	if (attr->inverted)
> > >  		value = !value;
> > >  
> > > @@ -193,30 +195,6 @@ PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO,				\
> > >  		    &trackpoint_attr_##_name,				\
> > >  		    trackpoint_show_int_attr, trackpoint_set_bit_attr)
> > >  
> > > -#define TRACKPOINT_UPDATE_BIT(_psmouse, _tp, _name)			\
> > > -do {									\
> > > -	struct trackpoint_attr_data *_attr = &trackpoint_attr_##_name;	\
> > > -									\
> > > -	trackpoint_update_bit(&_psmouse->ps2dev,			\
> > > -			_attr->command, _attr->mask, _tp->_name);	\
> > > -} while (0)
> > > -
> > > -#define TRACKPOINT_UPDATE(_power_on, _psmouse, _tp, _name)		\
> > > -do {									\
> > > -	if (!_power_on ||						\
> > > -	    _tp->_name != trackpoint_attr_##_name.power_on_default) {	\
> > > -		if (!trackpoint_attr_##_name.mask)			\
> > > -			trackpoint_write(&_psmouse->ps2dev,		\
> > > -				 trackpoint_attr_##_name.command,	\
> > > -				 _tp->_name);				\
> > > -		else							\
> > > -			TRACKPOINT_UPDATE_BIT(_psmouse, _tp, _name);	\
> > > -	}								\
> > > -} while (0)
> > > -
> > > -#define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name)				\
> > > -	(_tp->_name = trackpoint_attr_##_name.power_on_default)
> > > -
> > >  TRACKPOINT_INT_ATTR(sensitivity, TP_SENS, TP_DEF_SENS);
> > >  TRACKPOINT_INT_ATTR(speed, TP_SPEED, TP_DEF_SPEED);
> > >  TRACKPOINT_INT_ATTR(inertia, TP_INERTIA, TP_DEF_INERTIA);
> > > @@ -229,13 +207,33 @@ TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME);
> > >  TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV);
> > >  TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME);
> > >  
> > > -TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0,
> > > +TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, false,
> > >  		    TP_DEF_PTSON);
> > > -TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, 0,
> > > +TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, false,
> > >  		    TP_DEF_SKIPBACK);
> > > -TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, 1,
> > > +TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, true,
> > >  		    TP_DEF_EXT_DEV);
> > >  
> > > +static bool trackpoint_is_attr_available(struct psmouse *psmouse,
> > > +					 struct attribute *attr)
> > > +{
> > > +	struct trackpoint_data *tp = psmouse->private;
> > > +
> > > +	return tp->variant_id == TP_VARIANT_IBM ||
> > > +		attr == &psmouse_attr_sensitivity.dattr.attr ||
> > > +		attr == &psmouse_attr_press_to_select.dattr.attr;
> > > +}
> > > +
> > > +static umode_t trackpoint_is_attr_visible(struct kobject *kobj,
> > > +					  struct attribute *attr, int n)
> > > +{
> > > +	struct device *dev = container_of(kobj, struct device, kobj);
> > > +	struct serio *serio = to_serio_port(dev);
> > > +	struct psmouse *psmouse = serio_get_drvdata(serio);
> > > +
> > > +	return trackpoint_is_attr_available(psmouse, attr) ? attr->mode : 0;
> > > +}
> > > +
> > >  static struct attribute *trackpoint_attrs[] = {
> > >  	&psmouse_attr_sensitivity.dattr.attr,
> > >  	&psmouse_attr_speed.dattr.attr,
> > > @@ -255,24 +253,56 @@ static struct attribute *trackpoint_attrs[] = {
> > >  };
> > >  
> > >  static struct attribute_group trackpoint_attr_group = {
> > > -	.attrs = trackpoint_attrs,
> > > +	.is_visible	= trackpoint_is_attr_visible,
> > > +	.attrs		= trackpoint_attrs,
> > >  };
> > >  
> > > -static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *firmware_id)
> > > -{
> > > -	unsigned char param[2] = { 0 };
> > > +#define TRACKPOINT_UPDATE(_power_on, _psmouse, _tp, _name)		\
> > > +do {									\
> > > +	struct trackpoint_attr_data *_attr = &trackpoint_attr_##_name;	\
> > > +									\
> > > +	if ((!_power_on || _tp->_name != _attr->power_on_default) &&	\
> > > +	    trackpoint_is_attr_available(_psmouse,			\
> > > +				&psmouse_attr_##_name.dattr.attr)) {	\
> > > +		if (!_attr->mask)					\
> > > +			trackpoint_write(&_psmouse->ps2dev,		\
> > > +					 _attr->command, _tp->_name);	\
> > > +		else							\
> > > +			trackpoint_update_bit(&_psmouse->ps2dev,	\
> > > +					_attr->command, _attr->mask,	\
> > > +					_tp->_name);			\
> > > +	}								\
> > > +} while (0)
> > >  
> > > -	if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
> > > -		return -1;
> > > +#define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name)			\
> > > +do {									\
> > > +	_tp->_name = trackpoint_attr_##_name.power_on_default;		\
> > > +} while (0)
> > >  
> > > -	/* add new TP ID. */
> > > -	if (!(param[0] & TP_MAGIC_IDENT))
> > > -		return -1;
> > > +static int trackpoint_start_protocol(struct psmouse *psmouse,
> > > +				     u8 *variant_id, u8 *firmware_id)
> > > +{
> > > +	u8 param[2] = { 0 };
> > > +	int error;
> > >  
> > > -	if (firmware_id)
> > > -		*firmware_id = param[1];
> > > +	error = ps2_command(&psmouse->ps2dev,
> > > +			    param, MAKE_PS2_CMD(0, 2, TP_READ_ID));
> > > +	if (error)
> > > +		return error;
> > > +
> > > +	switch (param[0]) {
> > > +	case TP_VARIANT_IBM:
> > > +	case TP_VARIANT_ALPS:
> > > +	case TP_VARIANT_ELAN:
> > > +	case TP_VARIANT_NXP:
> > > +		if (variant_id)
> > > +			*variant_id = param[0];
> > > +		if (firmware_id)
> > > +			*firmware_id = param[1];
> > > +		break;
> > > +	}
> > >  
> > > -	return 0;
> > > +	return -ENODEV;
> > 
> > always report error .. not good.
> > 
> > >  }
> > >  
> > >  /*
> > > @@ -285,7 +315,7 @@ static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state)
> > >  {
> > >  	struct trackpoint_data *tp = psmouse->private;
> > >  
> > > -	if (!in_power_on_state) {
> > > +	if (!in_power_on_state && tp->variant_id == TP_VARIANT_IBM) {
> > >  		/*
> > >  		 * Disable features that may make device unusable
> > >  		 * with this driver.
> > > @@ -347,7 +377,8 @@ static void trackpoint_defaults(struct trackpoint_data *tp)
> > >  
> > >  static void trackpoint_disconnect(struct psmouse *psmouse)
> > >  {
> > > -	sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group);
> > > +	device_remove_group(&psmouse->ps2dev.serio->dev,
> > > +			    &trackpoint_attr_group);
> > >  
> > >  	kfree(psmouse->private);
> > >  	psmouse->private = NULL;
> > > @@ -355,14 +386,20 @@ static void trackpoint_disconnect(struct psmouse *psmouse)
> > >  
> > >  static int trackpoint_reconnect(struct psmouse *psmouse)
> > >  {
> > > -	int reset_fail;
> > > +	struct trackpoint_data *tp = psmouse->private;
> > > +	int error;
> > > +	bool was_reset;
> > >  
> > > -	if (trackpoint_start_protocol(psmouse, NULL))
> > > -		return -1;
> > > +	error = trackpoint_start_protocol(psmouse, NULL, NULL);
> > > +	if (error)
> > > +		return error;
> > >  
> > > -	reset_fail = trackpoint_power_on_reset(&psmouse->ps2dev);
> > > -	if (trackpoint_sync(psmouse, !reset_fail))
> > > -		return -1;
> > > +	was_reset = tp->variant_id == TP_VARIANT_IBM &&
> > > +		    trackpoint_power_on_reset(&psmouse->ps2dev) == 0;
> > > +
> > > +	error = trackpoint_sync(psmouse, was_reset);
> > > +	if (error)
> > > +		return error;
> > >  
> > >  	return 0;
> > >  }
> > > @@ -370,46 +407,62 @@ static int trackpoint_reconnect(struct psmouse *psmouse)
> > >  int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
> > >  {
> > >  	struct ps2dev *ps2dev = &psmouse->ps2dev;
> > > -	unsigned char firmware_id;
> > > -	unsigned char button_info;
> > > +	struct trackpoint_data *tp;
> > > +	u8 variant_id;
> > > +	u8 firmware_id;
> > > +	u8 button_info;
> > >  	int error;
> > >  
> > > -	if (trackpoint_start_protocol(psmouse, &firmware_id))
> > > -		return -1;
> > > +	error = trackpoint_start_protocol(psmouse, &variant_id, &firmware_id);
> > > +	if (error)
> > > +		return error;
> > >  
> > >  	if (!set_properties)
> > >  		return 0;
> > >  
> > > -	if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) {
> > > -		psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n");
> > > -		button_info = 0x33;
> > > -	}
> > > -
> > > -	psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
> > > -	if (!psmouse->private)
> > > +	tp = kzalloc(sizeof(*tp), GFP_KERNEL);
> > > +	if (!tp)
> > >  		return -ENOMEM;
> > >  
> > > -	psmouse->vendor = "IBM";
> > > +	trackpoint_defaults(tp);
> > > +	tp->variant_id = variant_id;
> > > +	tp->firmware_id = firmware_id;
> > > +
> > > +	psmouse->private = tp;
> > > +
> > > +	psmouse->vendor = trackpoint_variants[variant_id];
> > >  	psmouse->name = "TrackPoint";
> > >  
> > >  	psmouse->reconnect = trackpoint_reconnect;
> > >  	psmouse->disconnect = trackpoint_disconnect;
> > >  
> > > +	if (variant_id != TP_VARIANT_IBM) {
> > > +		/* Newer variants do not support extended button query. */
> > > +		button_info = 0x33;
> > > +	} else {
> > > +		error = trackpoint_read(ps2dev, TP_EXT_BTN, &button_info);
> > > +		if (error) {
> > > +			psmouse_warn(psmouse,
> > > +				     "failed to get extended button data, assuming 3 buttons\n");
> > > +			button_info = 0x33;
> > > +		}
> > > +	}
> > > +
> > >  	if ((button_info & 0x0f) >= 3)
> > > -		__set_bit(BTN_MIDDLE, psmouse->dev->keybit);
> > > +		input_set_capability(psmouse->dev, EV_KEY, BTN_MIDDLE);
> > >  
> > >  	__set_bit(INPUT_PROP_POINTER, psmouse->dev->propbit);
> > >  	__set_bit(INPUT_PROP_POINTING_STICK, psmouse->dev->propbit);
> > >  
> > > -	trackpoint_defaults(psmouse->private);
> > > -
> > > -	error = trackpoint_power_on_reset(ps2dev);
> > > -
> > > -	/* Write defaults to TP only if reset fails. */
> > > -	if (error)
> > > +	if (variant_id != TP_VARIANT_IBM ||
> > > +	    trackpoint_power_on_reset(ps2dev) != 0) {
> > > +		/*
> > > +		 * Write defaults to TP if we did not reset the trackpoint.
> > > +		 */
> > >  		trackpoint_sync(psmouse, false);
> > > +	}
> > >  
> > > -	error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
> > > +	error = device_add_group(&ps2dev->serio->dev, &trackpoint_attr_group);
> > >  	if (error) {
> > >  		psmouse_err(psmouse,
> > >  			    "failed to create sysfs attributes, error: %d\n",
> > > @@ -420,8 +473,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
> > >  	}
> > >  
> > >  	psmouse_info(psmouse,
> > > -		     "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
> > > -		     firmware_id,
> > > +		     "%s TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
> > > +		     psmouse->vendor, firmware_id,
> > >  		     (button_info & 0xf0) >> 4, button_info & 0x0f);
> > >  
> > >  	return 0;
> > > diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h
> > > index 88055755f82e..10a039148234 100644
> > > --- a/drivers/input/mouse/trackpoint.h
> > > +++ b/drivers/input/mouse/trackpoint.h
> > > @@ -21,10 +21,16 @@
> > >  #define TP_COMMAND		0xE2	/* Commands start with this */
> > >  
> > >  #define TP_READ_ID		0xE1	/* Sent for device identification */
> > > -#define TP_MAGIC_IDENT		0x03	/* Sent after a TP_READ_ID followed */
> > > -					/* by the firmware ID */
> > > -					/* Firmware ID includes 0x1, 0x2, 0x3 */
> > >  
> > > +/*
> > > + * Valid first byte responses to the "Read Secondary ID" (0xE1) command.
> > > + * 0x01 was the original IBM trackpoint, others implement very limited
> > > + * subset of trackpoint features.
> > > + */
> > > +#define TP_VARIANT_IBM		0x01
> > > +#define TP_VARIANT_ALPS		0x02
> > > +#define TP_VARIANT_ELAN		0x03
> > > +#define TP_VARIANT_NXP		0x04
> > >  
> > >  /*
> > >   * Commands
> > > @@ -136,18 +142,20 @@
> > >  
> > >  #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
> > >  
> > > -struct trackpoint_data
> > > -{
> > > -	unsigned char sensitivity, speed, inertia, reach;
> > > -	unsigned char draghys, mindrag;
> > > -	unsigned char thresh, upthresh;
> > > -	unsigned char ztime, jenks;
> > > -	unsigned char drift_time;
> > > +struct trackpoint_data {
> > > +	u8 variant_id;
> > > +	u8 firmware_id;
> > > +
> > > +	u8 sensitivity, speed, inertia, reach;
> > > +	u8 draghys, mindrag;
> > > +	u8 thresh, upthresh;
> > > +	u8 ztime, jenks;
> > > +	u8 drift_time;
> > >  
> > >  	/* toggles */
> > > -	unsigned char press_to_select;
> > > -	unsigned char skipback;
> > > -	unsigned char ext_dev;
> > > +	bool press_to_select;
> > > +	bool skipback;
> > > +	bool ext_dev;
> > >  };
> > >  
> > >  #ifdef CONFIG_MOUSE_PS2_TRACKPOINT
> > > --
> > > 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
> 
> -- 
> Dmitry
> --
> 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

* Re: [PATCH] Revert "Input: trackpoint - add new trackpoint firmware ID"
From: Dmitry Torokhov @ 2018-01-21 21:08 UTC (permalink / raw)
  To: ulrik.debie-os; +Cc: Aaron Ma, Greg KH, Sebastian Schmidt, linux-input
In-Reply-To: <20180121203700.GC23310@beacon.debie>

On January 21, 2018 12:37:01 PM PST, ulrik.debie-os@e2big.org wrote:
>On Tue, Jan 16, 2018 at 03:49:19PM -0800, Dmitry Torokhov wrote:
>> 
>> Hi Ulrik,
>> 
>> 
>> On Sun, Jan 14, 2018 at 09:39:59PM +0100, ulrik.debie-os@e2big.org
>wrote:
>> > Hi Dmitry, Sebastian,
>> > Nack for the patch..
>> 
>> NAK because of the issue pointed by Sebastian, or bigger
>disagreement?
>I originally had 2 reasons:
>1) issue pointed out by Sebastian, of course easy to fix
>2) The remark I had below which was because I did not understand yet
>the reason
>why you made this patch in the first place. I now understand it is not
>the 
>purpose to change anything for the Lenovo e470/e570 and it will also
>not change
>anything for those if you at least fix nr 1) 

I see. Yes, I did fix the problem mentioned by sensation of course, I did not bother posting updated patch because the change is trivial.


Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH 0/2] Input: auo-pixcir-ts: Adjustments for two function implementations
From: SF Markus Elfring @ 2018-01-21 21:14 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Heiko Stübner; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 22:10:44 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an error message for a failed memory allocation
    in auo_pixcir_parse_dt()
  Delete an unnecessary return statement in auo_pixcir_input_close()

 drivers/input/touchscreen/auo-pixcir-ts.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

-- 
2.16.0


^ permalink raw reply

* Re: [PATCH] Input: trackpoint - force 3 buttons if 0 button is reported
From: Dmitry Torokhov @ 2018-01-21 21:14 UTC (permalink / raw)
  To: ulrik.debie-os; +Cc: Aaron Ma, linux-input, linux-kernel
In-Reply-To: <20180121201049.GA23310@beacon.debie>

On January 21, 2018 12:10:50 PM PST, ulrik.debie-os@e2big.org wrote:
>On Tue, Jan 16, 2018 at 03:07:13PM -0800, Dmitry Torokhov wrote:
>Hi Dmitry,
>
>> 
>> On Sat, Jan 13, 2018 at 10:34:19AM +0800, Aaron Ma wrote:
>> > Will your patch go to stable kernel?
>> > If yes, that's fine.
>> 
>> Hmm, it looks like we need this patch after all as we do have screwy
>> Lenovos with apparently 0x01 devices reporting 0 buttons. From
>> https://bugzilla.kernel.org/show_bug.cgi?id=196253
>> 
>>  thinkpad_acpi: ThinkPad BIOS R0DET87W (1.87 ), EC unknown
>>  thinkpad_acpi: Lenovo ThinkPad E470, model 20H1004SGE
>> 
>>  psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons:
>0/0
>> 
>> I'll ask them to try my patch and if it is indeed 0x01 device I'll
>apply
>> your patch.
>
>It is quite strange. In the past,for commit 293b915fd9be 
>"Input: trackpoint - assume 3 buttons when buttons detection fails"
>there was
>success reported for lenovo e470 and I see the same success report in
>that
>bugzilla ticket.  I can also report success on lenovo e570.
>
>But some seem to have problems, could it be that they are not including
>that
>commit in the kernel they are running ? Or did a bios upgrade change
>the
>behaviour ?
>It would be best when we have a confirmation from a e470 owner that
>without the
>proposed patch from Aaron the middle button does not work on his e470,
>and it
>works with it.

I suppose Lenovo changed the firmware, because if you take a look at bugzilla link I provided there is a box that does not fail the command but indeed responds with 0 as number of buttons. It still reports device ID 0x010e.

Hi Ulrik,
Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH 1/2] Input: auo-pixcir-ts: Delete an error message for a failed memory allocation in auo_pixcir_parse_dt()
From: SF Markus Elfring @ 2018-01-21 21:15 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Heiko Stübner; +Cc: LKML, kernel-janitors
In-Reply-To: <df18b548-f95e-e315-9e77-f379af7909e8@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 22:02:32 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/auo-pixcir-ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index 6592fc5d48b4..398e27c48a51 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -487,10 +487,8 @@ static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
 		return ERR_PTR(-ENOENT);
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		dev_err(dev, "failed to allocate platform data\n");
+	if (!pdata)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	pdata->gpio_int = of_get_gpio(np, 0);
 	if (!gpio_is_valid(pdata->gpio_int)) {
-- 
2.16.0

^ permalink raw reply related

* [PATCH 2/2] Input: auo-pixcir-ts: Delete an unnecessary return statement in auo_pixcir_input_close()
From: SF Markus Elfring @ 2018-01-21 21:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Heiko Stübner; +Cc: LKML, kernel-janitors
In-Reply-To: <df18b548-f95e-e315-9e77-f379af7909e8@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 22:06:28 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/auo-pixcir-ts.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index 398e27c48a51..df8ca856393b 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -408,8 +408,6 @@ static void auo_pixcir_input_close(struct input_dev *dev)
 	struct auo_pixcir_ts *ts = input_get_drvdata(dev);
 
 	auo_pixcir_stop(ts);
-
-	return;
 }
 
 static int __maybe_unused auo_pixcir_suspend(struct device *dev)
-- 
2.16.0


^ permalink raw reply related

* [PATCH] Input: atmel_mxt_ts: Delete error messages for a failed memory allocation in two functions
From: SF Markus Elfring @ 2018-01-21 21:33 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Nick Dyer; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 22:25:31 +0100

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 7659bc48f1db..f38711e9c256 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1507,10 +1507,8 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
 			MXT_INFO_CHECKSUM_SIZE;
 	config_mem_size = data->mem_size - cfg_start_ofs;
 	config_mem = kzalloc(config_mem_size, GFP_KERNEL);
-	if (!config_mem) {
-		dev_err(dev, "Failed to allocate memory\n");
+	if (!config_mem)
 		return -ENOMEM;
-	}
 
 	ret = mxt_prepare_cfg_mem(data, cfg, data_pos, cfg_start_ofs,
 				  config_mem, config_mem_size);
@@ -1612,10 +1610,8 @@ static int mxt_get_object_table(struct mxt_data *data)
 
 	table_size = data->info.object_num * sizeof(struct mxt_object);
 	object_table = kzalloc(table_size, GFP_KERNEL);
-	if (!object_table) {
-		dev_err(&data->client->dev, "Failed to allocate memory\n");
+	if (!object_table)
 		return -ENOMEM;
-	}
 
 	error = __mxt_read_reg(client, MXT_OBJECT_START, table_size,
 			object_table);
@@ -1714,7 +1710,6 @@ static int mxt_get_object_table(struct mxt_data *data)
 	data->msg_buf = kcalloc(data->max_reportid,
 				data->T5_msg_size, GFP_KERNEL);
 	if (!data->msg_buf) {
-		dev_err(&client->dev, "Failed to allocate message buffer\n");
 		error = -ENOMEM;
 		goto free_object_table;
 	}
-- 
2.16.0


^ permalink raw reply related

* Re: [PATCH 0/2] Input: auo-pixcir-ts: Adjustments for two function implementations
From: Heiko Stübner @ 2018-01-21 21:35 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-input, Dmitry Torokhov, LKML, kernel-janitors
In-Reply-To: <df18b548-f95e-e315-9e77-f379af7909e8@users.sourceforge.net>

Am Sonntag, 21. Januar 2018, 22:14:15 CET schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Jan 2018 22:10:44 +0100
> 
> Two update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (2):
>   Delete an error message for a failed memory allocation
>     in auo_pixcir_parse_dt()
>   Delete an unnecessary return statement in auo_pixcir_input_close()

if it helps, both
Reviewed-by: Heiko Stuebner <heiko@sntech.de>

^ permalink raw reply

* [PATCH v3] input: bcm5974 - Add driver for Apple Magic Trackpad 2
From: Stephan Müller @ 2018-01-21 22:06 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov, Henrik Rydberg
  Cc: linux-input, marek.wyborski, linux-kernel
In-Reply-To: <40764439.8xGR6LbaWR@positron.chronox.de>

Hi,

Changes v3:
* port to 4.15-rc8
* small code cleanups (isolation of type casts to functions pertaining
  to the Apple Magic Trackpad 2
* clean up all checkpatch.pl errors and warnings (except those
  where the patch uses the structure of existing code fragments)
* updated horizontal and vertical limits to capture start of movements
  in the outer areas of the pad

---8<---

Add support for Apple Magic Trackpad 2 in bcm5974 (MacBook Tochpad) driver.
The Magic Trackpad 2 needs to be switched into the finger-reporting-mode,
just like the other macbook touchpads as well. But the format is different
to the ones before. The Header is 12 Bytes long and each reported finger
is additional 9 Bytes. The data order reported by the hardware is
different as well.

Signed-off-by: Marek Wyborski <marek.wyborski@emwesoft.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 drivers/input/mouse/bcm5974.c | 127 +++++++++++++++++++++++++++++++++++++
+----
 1 file changed, 116 insertions(+), 11 deletions(-)

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index d0122134f320..11868321992c 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -96,6 +96,8 @@
 #define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI	0x0272
 #define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO	0x0273
 #define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS	0x0274
+/* MagicTrackpad2 (2015) */
+#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2	0x0265
 
 #define BCM5974_DEVICE(prod) {					\
 	.match_flags = (USB_DEVICE_ID_MATCH_DEVICE |		\
@@ -161,6 +163,8 @@ static const struct usb_device_id bcm5974_table[] = {
 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
+	/* MagicTrackpad2 */
+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_MAGICTRACKPAD2),
 	/* Terminating entry */
 	{}
 };
@@ -190,7 +194,8 @@ enum tp_type {
 	TYPE1,			/* plain trackpad */
 	TYPE2,			/* button integrated in trackpad */
 	TYPE3,			/* additional header fields since June 2013 */
-	TYPE4			/* additional header field for pressure data */
+	TYPE4,			/* additional header field for pressure data */
+	TYPE5			/* format for magic trackpad 2 */
 };
 
 /* trackpad finger data offsets, le16-aligned */
@@ -198,12 +203,14 @@ enum tp_type {
 #define HEADER_TYPE2		(15 * sizeof(__le16))
 #define HEADER_TYPE3		(19 * sizeof(__le16))
 #define HEADER_TYPE4		(23 * sizeof(__le16))
+#define HEADER_TYPE5		(6  * sizeof(__le16))
 
 /* trackpad button data offsets */
 #define BUTTON_TYPE1		0
 #define BUTTON_TYPE2		15
 #define BUTTON_TYPE3		23
 #define BUTTON_TYPE4		31
+#define BUTTON_TYPE5		1
 
 /* list of device capability bits */
 #define HAS_INTEGRATED_BUTTON	1
@@ -213,18 +220,21 @@ enum tp_type {
 #define FSIZE_TYPE2		(14 * sizeof(__le16))
 #define FSIZE_TYPE3		(14 * sizeof(__le16))
 #define FSIZE_TYPE4		(15 * sizeof(__le16))
+#define FSIZE_TYPE5		(9)
 
 /* offset from header to finger struct */
 #define DELTA_TYPE1		(0 * sizeof(__le16))
 #define DELTA_TYPE2		(0 * sizeof(__le16))
 #define DELTA_TYPE3		(0 * sizeof(__le16))
 #define DELTA_TYPE4		(1 * sizeof(__le16))
+#define DELTA_TYPE5		(0 * sizeof(__le16))
 
 /* usb control message mode switch data */
 #define USBMSG_TYPE1		8, 0x300, 0, 0, 0x1, 0x8
 #define USBMSG_TYPE2		8, 0x300, 0, 0, 0x1, 0x8
 #define USBMSG_TYPE3		8, 0x300, 0, 0, 0x1, 0x8
 #define USBMSG_TYPE4		2, 0x302, 2, 1, 0x1, 0x0
+#define USBMSG_TYPE5		2, 0x302, 1, 1, 0x1, 0x0
 
 /* Wellspring initialization constants */
 #define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID		1
@@ -247,6 +257,18 @@ struct tp_finger {
 	__le16 multi;		/* one finger: varies, more fingers: constant */
 } __attribute__((packed,aligned(2)));
 
+/* trackpad finger structure for type5 (magic trackpad), le16-aligned */
+struct tp_finger_type5 {
+	u8 abs_x;		/* absolute x coodinate */
+	u8 abs_x_y;		/* absolute x,y coodinate */
+	u8 abs_y[2];		/* absolute y coodinate */
+	u8 touch_major;		/* touch area, major axis */
+	u8 touch_minor;		/* touch area, minor axis */
+	u8 size;		/* tool area, size */
+	u8 pressure;		/* pressure on forcetouch touchpad */
+	u8 orientation_origin;	/* orientation and id */
+} __attribute__((packed,aligned(2)));
+
 /* trackpad finger data size, empirically at least ten fingers */
 #define MAX_FINGERS		16
 #define MAX_FINGER_ORIENTATION	16384
@@ -497,6 +519,19 @@ static const struct bcm5974_config bcm5974_config_table[] 
= {
 		{ SN_COORD, -203, 6803 },
 		{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
 	},
+	{
+		USB_DEVICE_ID_APPLE_MAGICTRACKPAD2,
+		USB_DEVICE_ID_APPLE_MAGICTRACKPAD2,
+		USB_DEVICE_ID_APPLE_MAGICTRACKPAD2,
+		HAS_INTEGRATED_BUTTON,
+		0, sizeof(struct bt_data),
+		0x83, DATAFORMAT(TYPE5),
+		{ SN_PRESSURE, 0, 300 },
+		{ SN_WIDTH, 0, 2048 },
+		{ SN_COORD, -9000, 9000 },
+		{ SN_COORD, -6803, 6803 },
+		{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
+	},
 	{}
 };
 
@@ -539,9 +574,13 @@ static void setup_events_to_report(struct input_dev 
*input_dev,
 	/* finger touch area */
 	set_abs(input_dev, ABS_MT_TOUCH_MAJOR, &cfg->w);
 	set_abs(input_dev, ABS_MT_TOUCH_MINOR, &cfg->w);
+
 	/* finger approach area */
-	set_abs(input_dev, ABS_MT_WIDTH_MAJOR, &cfg->w);
-	set_abs(input_dev, ABS_MT_WIDTH_MINOR, &cfg->w);
+	if (cfg->tp_type != TYPE5) {
+		set_abs(input_dev, ABS_MT_WIDTH_MAJOR, &cfg->w);
+		set_abs(input_dev, ABS_MT_WIDTH_MINOR, &cfg->w);
+	}
+
 	/* finger orientation */
 	set_abs(input_dev, ABS_MT_ORIENTATION, &cfg->o);
 	/* finger position */
@@ -596,6 +635,25 @@ static void report_finger_data(struct input_dev *input, 
int slot,
 	input_report_abs(input, ABS_MT_POSITION_Y, pos->y);
 }
 
+static void report_finger_data_type5(struct input_dev *input, int slot,
+				     const struct input_mt_pos *pos,
+				     const struct tp_finger *f)
+{
+	const struct tp_finger_type5 *f5 = (const struct tp_finger_type5 *)f;
+
+	input_mt_slot(input, slot);
+	input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
+
+	input_report_abs(input, ABS_MT_TOUCH_MAJOR,
+			 raw2int(f5->touch_major) << 2);
+	input_report_abs(input, ABS_MT_TOUCH_MINOR,
+			 raw2int(f5->touch_minor) << 2);
+	input_report_abs(input, ABS_MT_ORIENTATION,
+		MAX_FINGER_ORIENTATION - ((f5->orientation_origin & 0xf0) << 6));
+	input_report_abs(input, ABS_MT_POSITION_X, pos->x << 1);
+	input_report_abs(input, ABS_MT_POSITION_Y, pos->y << 1);
+}
+
 static void report_synaptics_data(struct input_dev *input,
 				  const struct bcm5974_config *cfg,
 				  const struct tp_finger *f, int raw_n)
@@ -615,11 +673,34 @@ static void report_synaptics_data(struct input_dev 
*input,
 	input_report_abs(input, ABS_TOOL_WIDTH, abs_w);
 }
 
+static void report_synaptics_data_type5(struct input_dev *input,
+					const struct bcm5974_config *cfg,
+					const struct tp_finger *f,
+					int raw_n)
+{
+	const struct tp_finger_type5 *f5 = (const struct tp_finger_type5 *)f;
+	int abs_p = 0, abs_w = 0;
+
+	if (raw_n) {
+		int p = f5->pressure;
+		int w = f5->size;
+
+		if (p && w) {
+			abs_p = p;
+			abs_w = w;
+		}
+	}
+
+	input_report_abs(input, ABS_PRESSURE, abs_p);
+	input_report_abs(input, ABS_TOOL_WIDTH, abs_w);
+}
+
 /* report trackpad data as logical trackpad state */
 static int report_tp_state(struct bcm5974 *dev, int size)
 {
 	const struct bcm5974_config *c = &dev->cfg;
 	const struct tp_finger *f;
+	const struct tp_finger_type5 *f_type5;
 	struct input_dev *input = dev->input;
 	int raw_n, i, n = 0;
 
@@ -629,23 +710,47 @@ static int report_tp_state(struct bcm5974 *dev, int 
size)
 	raw_n = (size - c->tp_header) / c->tp_fsize;
 
 	for (i = 0; i < raw_n; i++) {
+
 		f = get_tp_finger(dev, i);
-		if (raw2int(f->touch_major) == 0)
-			continue;
-		dev->pos[n].x = raw2int(f->abs_x);
-		dev->pos[n].y = c->y.min + c->y.max - raw2int(f->abs_y);
+
+		if (c->tp_type != TYPE5) {
+			if (raw2int(f->touch_major) == 0)
+				continue;
+			dev->pos[n].x = raw2int(f->abs_x);
+			dev->pos[n].y = c->y.min + c->y.max - raw2int(f->abs_y);
+		} else {
+			u16 tmp_x;
+			u32 tmp_y;
+
+			f_type5 = (const struct tp_finger_type5 *) f;
+			if (f_type5->pressure == 0)
+				continue;
+			tmp_x = le16_to_cpu(*((__le16 *)f_type5)) & 0x1fff;
+			dev->pos[n].x = (s16) (tmp_x << 3) >> 3;
+			tmp_y = (s32) le32_to_cpu(*((__le32 *)f_type5));
+			dev->pos[n].y = -(s32) (tmp_y << 6) >> 19;
+		}
 		dev->index[n++] = f;
 	}
 
 	input_mt_assign_slots(input, dev->slots, dev->pos, n, 0);
 
-	for (i = 0; i < n; i++)
-		report_finger_data(input, dev->slots[i],
-				   &dev->pos[i], dev->index[i]);
+	for (i = 0; i < n; i++) {
+		if (c->tp_type != TYPE5)
+			report_finger_data(input, dev->slots[i],
+					   &dev->pos[i], dev->index[i]);
+		else
+			report_finger_data_type5(input, dev->slots[i],
+						 &dev->pos[i], dev->index[i]);
+	}
 
 	input_mt_sync_frame(input);
 
-	report_synaptics_data(input, c, get_tp_finger(dev, 0), raw_n);
+	if (c->tp_type != TYPE5)
+		report_synaptics_data(input, c, get_tp_finger(dev, 0), raw_n);
+	else
+		report_synaptics_data_type5(input, c, get_tp_finger(dev, 0),
+					    raw_n);
 
 	/* later types report button events via integrated button only */
 	if (c->caps & HAS_INTEGRATED_BUTTON) {
-- 
2.14.3





^ permalink raw reply related


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