linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/4] Input: zforce - fix spelling errors
  2014-01-27 18:46 ` [PATCH 1/4] Input: zforce - fix spelling errors Luis Ortega
@ 2014-01-27 18:41   ` Heiko Stübner
  0 siblings, 0 replies; 11+ messages in thread
From: Heiko Stübner @ 2014-01-27 18:41 UTC (permalink / raw)
  To: Luis Ortega; +Cc: dmitry.torokhov, yongjun_wei, linux-input, linux-kernel

On Monday, 27. January 2014 19:46:10 Luis Ortega wrote:
> Fixed a few spelling errors.
> 
> Signed-off-by: Luis Ortega <luiorpe1@upv.es>

Acked-by: Heiko Stuebner <heiko@sntech.de>

> ---
>  drivers/input/touchscreen/zforce_ts.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/zforce_ts.c
> b/drivers/input/touchscreen/zforce_ts.c index 2175f34..c145c1d 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -64,7 +64,7 @@
>  #define RESPONSE_STATUS		0X1e
> 
>  /*
> - * Notifications are send by the touch controller without
> + * Notifications are sent by the touch controller without
>   * being requested by the driver and include for example
>   * touch indications
>   */
> @@ -103,8 +103,8 @@ struct zforce_point {
>   * @suspended		device suspended
>   * @access_mutex	serialize i2c-access, to keep multipart reads together
>   * @command_done	completion to wait for the command result
> - * @command_mutex	serialize commands send to the ic
> - * @command_waiting	the id of the command that that is currently waiting
> + * @command_mutex	serialize commands sent to the ic
> + * @command_waiting	the id of the command that is currently waiting
>   *			for a result
>   * @command_result	returned result of the command
>   */
> @@ -332,7 +332,7 @@ static int zforce_touch_event(struct zforce_ts *ts, u8
> *payload)
> 
>  	count = payload[0];
>  	if (count > ZFORCE_REPORT_POINTS) {
> -		dev_warn(&client->dev, "to many coordinates %d, expected max %d\n",
> +		dev_warn(&client->dev, "too many coordinates %d, expected max %d\n",
>  			 count, ZFORCE_REPORT_POINTS);
>  		count = ZFORCE_REPORT_POINTS;
>  	}
> @@ -798,7 +798,7 @@ static int zforce_probe(struct i2c_client *client,
>  		return ret;
>  	}
> 
> -	/* this gets the firmware version among other informations */
> +	/* this gets the firmware version among other information */
>  	ret = zforce_command_wait(ts, COMMAND_STATUS);
>  	if (ret < 0) {
>  		dev_err(&client->dev, "couldn't get status, %d\n", ret);


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Input: zforce - fix various small issues
@ 2014-01-27 18:46 Luis Ortega
  2014-01-27 18:46 ` [PATCH 1/4] Input: zforce - fix spelling errors Luis Ortega
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Luis Ortega @ 2014-01-27 18:46 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: heiko, yongjun_wei, linux-input, linux-kernel

As a kernel newbie and owner of a Barnes & Noble e-reader I was
curious to review this driver to learn more about the touchscreen.

The first two patches are fairly innocuous whereas the last two
slightly modify the code to fix two small issues I discovered.
I don't have the setup to test them but they look logically correct
to me.

[PATCH 1/4] Input: zforce - fix spelling errors
[PATCH 2/4] Input: zforce - fix lines exceeding 80 columns
[PATCH 3/4] Input: zforce - Remove unnecessary payload data checks
[PATCH 4/4] Input: zforce - reduce stack memory allocated to frames

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] Input: zforce - fix spelling errors
  2014-01-27 18:46 Input: zforce - fix various small issues Luis Ortega
@ 2014-01-27 18:46 ` Luis Ortega
  2014-01-27 18:41   ` Heiko Stübner
  2014-01-27 18:46 ` [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns Luis Ortega
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Luis Ortega @ 2014-01-27 18:46 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: heiko, yongjun_wei, linux-input, linux-kernel, Luis Ortega

Fixed a few spelling errors.

Signed-off-by: Luis Ortega <luiorpe1@upv.es>
---
 drivers/input/touchscreen/zforce_ts.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 2175f34..c145c1d 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -64,7 +64,7 @@
 #define RESPONSE_STATUS		0X1e
 
 /*
- * Notifications are send by the touch controller without
+ * Notifications are sent by the touch controller without
  * being requested by the driver and include for example
  * touch indications
  */
@@ -103,8 +103,8 @@ struct zforce_point {
  * @suspended		device suspended
  * @access_mutex	serialize i2c-access, to keep multipart reads together
  * @command_done	completion to wait for the command result
- * @command_mutex	serialize commands send to the ic
- * @command_waiting	the id of the command that that is currently waiting
+ * @command_mutex	serialize commands sent to the ic
+ * @command_waiting	the id of the command that is currently waiting
  *			for a result
  * @command_result	returned result of the command
  */
@@ -332,7 +332,7 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
 
 	count = payload[0];
 	if (count > ZFORCE_REPORT_POINTS) {
-		dev_warn(&client->dev, "to many coordinates %d, expected max %d\n",
+		dev_warn(&client->dev, "too many coordinates %d, expected max %d\n",
 			 count, ZFORCE_REPORT_POINTS);
 		count = ZFORCE_REPORT_POINTS;
 	}
@@ -798,7 +798,7 @@ static int zforce_probe(struct i2c_client *client,
 		return ret;
 	}
 
-	/* this gets the firmware version among other informations */
+	/* this gets the firmware version among other information */
 	ret = zforce_command_wait(ts, COMMAND_STATUS);
 	if (ret < 0) {
 		dev_err(&client->dev, "couldn't get status, %d\n", ret);
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns
  2014-01-27 18:46 Input: zforce - fix various small issues Luis Ortega
  2014-01-27 18:46 ` [PATCH 1/4] Input: zforce - fix spelling errors Luis Ortega
@ 2014-01-27 18:46 ` Luis Ortega
  2014-01-27 19:12   ` Heiko Stübner
  2014-01-27 18:46 ` [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks Luis Ortega
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Luis Ortega @ 2014-01-27 18:46 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: heiko, yongjun_wei, linux-input, linux-kernel, Luis Ortega

Fixed lines exceeding 80 characters long wherever possible,
as per the coding style.

Signed-off-by: Luis Ortega <luiorpe1@upv.es>
---
 drivers/input/touchscreen/zforce_ts.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index c145c1d..c1b6b82 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -235,7 +235,8 @@ static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger,
 			(finger & 0xff), ((finger >> 8) & 0xff),
 			(stylus & 0xff), ((stylus >> 8) & 0xff) };
 
-	dev_dbg(&client->dev, "set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
+	dev_dbg(&client->dev,
+		"set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
 		idle, finger, stylus);
 
 	return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
@@ -332,7 +333,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
 
 	count = payload[0];
 	if (count > ZFORCE_REPORT_POINTS) {
-		dev_warn(&client->dev, "too many coordinates %d, expected max %d\n",
+		dev_warn(&client->dev,
+			 "too many coordinates %d, expected max %d\n",
 			 count, ZFORCE_REPORT_POINTS);
 		count = ZFORCE_REPORT_POINTS;
 	}
@@ -494,8 +496,8 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
 	while (!gpio_get_value(pdata->gpio_int)) {
 		ret = zforce_read_packet(ts, payload_buffer);
 		if (ret < 0) {
-			dev_err(&client->dev, "could not read packet, ret: %d\n",
-				ret);
+			dev_err(&client->dev,
+				"could not read packet, ret: %d\n", ret);
 			break;
 		}
 
@@ -539,7 +541,8 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
 						payload[RESPONSE_DATA + 4];
 			ts->version_rev   = (payload[RESPONSE_DATA + 7] << 8) |
 						payload[RESPONSE_DATA + 6];
-			dev_dbg(&ts->client->dev, "Firmware Version %04x:%04x %04x:%04x\n",
+			dev_dbg(&ts->client->dev,
+				"Firmware Version %04x:%04x %04x:%04x\n",
 				ts->version_major, ts->version_minor,
 				ts->version_build, ts->version_rev);
 
@@ -552,7 +555,8 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
 			break;
 
 		default:
-			dev_err(&ts->client->dev, "unrecognized response id: 0x%x\n",
+			dev_err(&ts->client->dev,
+				"unrecognized response id: 0x%x\n",
 				payload[RESPONSE_ID]);
 			break;
 		}
@@ -618,7 +622,8 @@ static int zforce_suspend(struct device *dev)
 
 		enable_irq_wake(client->irq);
 	} else if (input->users) {
-		dev_dbg(&client->dev, "suspend without being a wakeup source\n");
+		dev_dbg(&client->dev,
+			"suspend without being a wakeup source\n");
 
 		ret = zforce_stop(ts);
 		if (ret)
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks
  2014-01-27 18:46 Input: zforce - fix various small issues Luis Ortega
  2014-01-27 18:46 ` [PATCH 1/4] Input: zforce - fix spelling errors Luis Ortega
  2014-01-27 18:46 ` [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns Luis Ortega
@ 2014-01-27 18:46 ` Luis Ortega
  2014-01-27 20:16   ` Heiko Stübner
  2014-01-27 18:46 ` [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames Luis Ortega
  2014-01-28  6:44 ` Input: zforce - fix various small issues Dmitry Torokhov
  4 siblings, 1 reply; 11+ messages in thread
From: Luis Ortega @ 2014-01-27 18:46 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: heiko, yongjun_wei, linux-input, linux-kernel, Luis Ortega

The function zforce_read_packet() reads 2 values (bytes) of payload
header, validates them and then proceeds to read the payload body.
The function stores all these in a u8 buffer.

The PAYLOAD_LENGTH check seems to be trying to detect an overflow error.
However, since we are just reading a u8 value from the buffer, these
checks are unnecessary and we should simply compare against zero.

Signed-off-by: Luis Ortega <luiorpe1@upv.es>
---
 drivers/input/touchscreen/zforce_ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index c1b6b82..e082d5c 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -423,7 +423,7 @@ static int zforce_read_packet(struct zforce_ts *ts, u8 *buf)
 		goto unlock;
 	}
 
-	if (buf[PAYLOAD_LENGTH] <= 0 || buf[PAYLOAD_LENGTH] > 255) {
+	if (buf[PAYLOAD_LENGTH] == 0) {
 		dev_err(&client->dev, "invalid payload length: %d\n",
 			buf[PAYLOAD_LENGTH]);
 		ret = -EIO;
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames
  2014-01-27 18:46 Input: zforce - fix various small issues Luis Ortega
                   ` (2 preceding siblings ...)
  2014-01-27 18:46 ` [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks Luis Ortega
@ 2014-01-27 18:46 ` Luis Ortega
  2014-01-27 20:22   ` Heiko Stübner
  2014-01-28  6:44 ` Input: zforce - fix various small issues Dmitry Torokhov
  4 siblings, 1 reply; 11+ messages in thread
From: Luis Ortega @ 2014-01-27 18:46 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: heiko, yongjun_wei, linux-input, linux-kernel, Luis Ortega

A frame is a u8 array with the following structure:
[PAYLOAD_HEADER, PAYLOAD_LENGTH, ...PAYLOAD_BODY...]

PAYLOAD_BODY can be at most 255 bytes long, as it's size is represented
by PAYLOAD_LENGTH. Therefore we can reduce the stack memory allocated to
payload_buffer[] roughly by half, from 512 to 257 bytes.

Signed-off-by: Luis Ortega <luiorpe1@upv.es>
---
 drivers/input/touchscreen/zforce_ts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index e082d5c..afb2492 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -33,6 +33,7 @@
 #define WAIT_TIMEOUT		msecs_to_jiffies(1000)
 
 #define FRAME_START		0xee
+#define FRAME_MAXSIZE		257
 
 /* Offsets of the different parts of the payload the controller sends */
 #define PAYLOAD_HEADER		0
@@ -475,7 +476,7 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
 	struct i2c_client *client = ts->client;
 	const struct zforce_ts_platdata *pdata = dev_get_platdata(&client->dev);
 	int ret;
-	u8 payload_buffer[512];
+	u8 payload_buffer[FRAME_MAXSIZE];
 	u8 *payload;
 
 	/*
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns
  2014-01-27 18:46 ` [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns Luis Ortega
@ 2014-01-27 19:12   ` Heiko Stübner
  2014-01-27 19:29     ` Luis Ortega
  0 siblings, 1 reply; 11+ messages in thread
From: Heiko Stübner @ 2014-01-27 19:12 UTC (permalink / raw)
  To: Luis Ortega; +Cc: dmitry.torokhov, yongjun_wei, linux-input, linux-kernel

On Monday, 27. January 2014 19:46:11 Luis Ortega wrote:
> Fixed lines exceeding 80 characters long wherever possible,
> as per the coding style.
> 
> Signed-off-by: Luis Ortega <luiorpe1@upv.es>

checkpatch did not complain on the initial submission, so I guess it's more an 
issue of taste. Nevertheless I don't have a preference for one way or the 
other, so

Acked-by: Heiko Stuebner <heiko@sntech.de>


> ---
>  drivers/input/touchscreen/zforce_ts.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/zforce_ts.c
> b/drivers/input/touchscreen/zforce_ts.c index c145c1d..c1b6b82 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -235,7 +235,8 @@ static int zforce_scan_frequency(struct zforce_ts *ts,
> u16 idle, u16 finger, (finger & 0xff), ((finger >> 8) & 0xff),
>  			(stylus & 0xff), ((stylus >> 8) & 0xff) };
> 
> -	dev_dbg(&client->dev, "set scan frequency to (idle: %d, finger: %d,
> stylus: %d)\n", +	dev_dbg(&client->dev,
> +		"set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
>  		idle, finger, stylus);
> 
>  	return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
> @@ -332,7 +333,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8
> *payload)
> 
>  	count = payload[0];
>  	if (count > ZFORCE_REPORT_POINTS) {
> -		dev_warn(&client->dev, "too many coordinates %d, expected max %d\n",
> +		dev_warn(&client->dev,
> +			 "too many coordinates %d, expected max %d\n",
>  			 count, ZFORCE_REPORT_POINTS);
>  		count = ZFORCE_REPORT_POINTS;
>  	}
> @@ -494,8 +496,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
> *dev_id) while (!gpio_get_value(pdata->gpio_int)) {
>  		ret = zforce_read_packet(ts, payload_buffer);
>  		if (ret < 0) {
> -			dev_err(&client->dev, "could not read packet, ret: %d\n",
> -				ret);
> +			dev_err(&client->dev,
> +				"could not read packet, ret: %d\n", ret);
>  			break;
>  		}
> 
> @@ -539,7 +541,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
> *dev_id) payload[RESPONSE_DATA + 4];
>  			ts->version_rev   = (payload[RESPONSE_DATA + 7] << 8) |
>  						payload[RESPONSE_DATA + 6];
> -			dev_dbg(&ts->client->dev, "Firmware Version %04x:%04x %04x:
%04x\n",
> +			dev_dbg(&ts->client->dev,
> +				"Firmware Version %04x:%04x %04x:%04x\n",
>  				ts->version_major, ts->version_minor,
>  				ts->version_build, ts->version_rev);
> 
> @@ -552,7 +555,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
> *dev_id) break;
> 
>  		default:
> -			dev_err(&ts->client->dev, "unrecognized response id: 0x%x\n",
> +			dev_err(&ts->client->dev,
> +				"unrecognized response id: 0x%x\n",
>  				payload[RESPONSE_ID]);
>  			break;
>  		}
> @@ -618,7 +622,8 @@ static int zforce_suspend(struct device *dev)
> 
>  		enable_irq_wake(client->irq);
>  	} else if (input->users) {
> -		dev_dbg(&client->dev, "suspend without being a wakeup source\n");
> +		dev_dbg(&client->dev,
> +			"suspend without being a wakeup source\n");
> 
>  		ret = zforce_stop(ts);
>  		if (ret)


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns
  2014-01-27 19:12   ` Heiko Stübner
@ 2014-01-27 19:29     ` Luis Ortega
  0 siblings, 0 replies; 11+ messages in thread
From: Luis Ortega @ 2014-01-27 19:29 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: Luis Ortega, Dmitry Torokhov, yongjun_wei, linux-input,
	linux-kernel

Yeah, I also ran checkpatch on the file and it had nothing to report.
Unfortunately those lines are slightly long and got word wrapped in my
editor, disrupting the flow of text. I thought fixing them wouldn't hurt.

On Mon, Jan 27, 2014 at 8:12 PM, Heiko Stübner <heiko@sntech.de> wrote:
> On Monday, 27. January 2014 19:46:11 Luis Ortega wrote:
>> Fixed lines exceeding 80 characters long wherever possible,
>> as per the coding style.
>>
>> Signed-off-by: Luis Ortega <luiorpe1@upv.es>
>
> checkpatch did not complain on the initial submission, so I guess it's more an
> issue of taste. Nevertheless I don't have a preference for one way or the
> other, so
>
> Acked-by: Heiko Stuebner <heiko@sntech.de>
>
>
>> ---
>>  drivers/input/touchscreen/zforce_ts.c | 19 ++++++++++++-------
>>  1 file changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/zforce_ts.c
>> b/drivers/input/touchscreen/zforce_ts.c index c145c1d..c1b6b82 100644
>> --- a/drivers/input/touchscreen/zforce_ts.c
>> +++ b/drivers/input/touchscreen/zforce_ts.c
>> @@ -235,7 +235,8 @@ static int zforce_scan_frequency(struct zforce_ts *ts,
>> u16 idle, u16 finger, (finger & 0xff), ((finger >> 8) & 0xff),
>>                       (stylus & 0xff), ((stylus >> 8) & 0xff) };
>>
>> -     dev_dbg(&client->dev, "set scan frequency to (idle: %d, finger: %d,
>> stylus: %d)\n", +     dev_dbg(&client->dev,
>> +             "set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
>>               idle, finger, stylus);
>>
>>       return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
>> @@ -332,7 +333,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8
>> *payload)
>>
>>       count = payload[0];
>>       if (count > ZFORCE_REPORT_POINTS) {
>> -             dev_warn(&client->dev, "too many coordinates %d, expected max %d\n",
>> +             dev_warn(&client->dev,
>> +                      "too many coordinates %d, expected max %d\n",
>>                        count, ZFORCE_REPORT_POINTS);
>>               count = ZFORCE_REPORT_POINTS;
>>       }
>> @@ -494,8 +496,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
>> *dev_id) while (!gpio_get_value(pdata->gpio_int)) {
>>               ret = zforce_read_packet(ts, payload_buffer);
>>               if (ret < 0) {
>> -                     dev_err(&client->dev, "could not read packet, ret: %d\n",
>> -                             ret);
>> +                     dev_err(&client->dev,
>> +                             "could not read packet, ret: %d\n", ret);
>>                       break;
>>               }
>>
>> @@ -539,7 +541,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
>> *dev_id) payload[RESPONSE_DATA + 4];
>>                       ts->version_rev   = (payload[RESPONSE_DATA + 7] << 8) |
>>                                               payload[RESPONSE_DATA + 6];
>> -                     dev_dbg(&ts->client->dev, "Firmware Version %04x:%04x %04x:
> %04x\n",
>> +                     dev_dbg(&ts->client->dev,
>> +                             "Firmware Version %04x:%04x %04x:%04x\n",
>>                               ts->version_major, ts->version_minor,
>>                               ts->version_build, ts->version_rev);
>>
>> @@ -552,7 +555,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
>> *dev_id) break;
>>
>>               default:
>> -                     dev_err(&ts->client->dev, "unrecognized response id: 0x%x\n",
>> +                     dev_err(&ts->client->dev,
>> +                             "unrecognized response id: 0x%x\n",
>>                               payload[RESPONSE_ID]);
>>                       break;
>>               }
>> @@ -618,7 +622,8 @@ static int zforce_suspend(struct device *dev)
>>
>>               enable_irq_wake(client->irq);
>>       } else if (input->users) {
>> -             dev_dbg(&client->dev, "suspend without being a wakeup source\n");
>> +             dev_dbg(&client->dev,
>> +                     "suspend without being a wakeup source\n");
>>
>>               ret = zforce_stop(ts);
>>               if (ret)
>
--
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	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks
  2014-01-27 18:46 ` [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks Luis Ortega
@ 2014-01-27 20:16   ` Heiko Stübner
  0 siblings, 0 replies; 11+ messages in thread
From: Heiko Stübner @ 2014-01-27 20:16 UTC (permalink / raw)
  To: Luis Ortega; +Cc: dmitry.torokhov, yongjun_wei, linux-input, linux-kernel

On Monday, 27. January 2014 19:46:12 Luis Ortega wrote:
> The function zforce_read_packet() reads 2 values (bytes) of payload
> header, validates them and then proceeds to read the payload body.
> The function stores all these in a u8 buffer.
> 
> The PAYLOAD_LENGTH check seems to be trying to detect an overflow error.
> However, since we are just reading a u8 value from the buffer, these
> checks are unnecessary and we should simply compare against zero.
> 
> Signed-off-by: Luis Ortega <luiorpe1@upv.es>

Acked-by: Heiko Stuebner <heiko@sntech.de>

on a bq Cervantes (imx6sl)
Tested-by: Heiko Stuebner <heiko@sntech.de>


> ---
>  drivers/input/touchscreen/zforce_ts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/zforce_ts.c
> b/drivers/input/touchscreen/zforce_ts.c index c1b6b82..e082d5c 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -423,7 +423,7 @@ static int zforce_read_packet(struct zforce_ts *ts, u8
> *buf) goto unlock;
>  	}
> 
> -	if (buf[PAYLOAD_LENGTH] <= 0 || buf[PAYLOAD_LENGTH] > 255) {
> +	if (buf[PAYLOAD_LENGTH] == 0) {
>  		dev_err(&client->dev, "invalid payload length: %d\n",
>  			buf[PAYLOAD_LENGTH]);
>  		ret = -EIO;


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames
  2014-01-27 18:46 ` [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames Luis Ortega
@ 2014-01-27 20:22   ` Heiko Stübner
  0 siblings, 0 replies; 11+ messages in thread
From: Heiko Stübner @ 2014-01-27 20:22 UTC (permalink / raw)
  To: Luis Ortega; +Cc: dmitry.torokhov, yongjun_wei, linux-input, linux-kernel

On Monday, 27. January 2014 19:46:13 Luis Ortega wrote:
> A frame is a u8 array with the following structure:
> [PAYLOAD_HEADER, PAYLOAD_LENGTH, ...PAYLOAD_BODY...]
> 
> PAYLOAD_BODY can be at most 255 bytes long, as it's size is represented
> by PAYLOAD_LENGTH. Therefore we can reduce the stack memory allocated to
> payload_buffer[] roughly by half, from 512 to 257 bytes.

Nice catch, thanks

Acked-by: Heiko Stuebner <heiko@sntech.de>

on a bq Cervantes (imx6sl)
Tested-by: Heiko Stuebner <heiko@sntech.de>


As a side-note, this change conflicts with one of my patches adding devicetree 
support to the driver [0], which Dmitry will hopefully also look at soon.

So one of us might need to respin his series depending on the ordering.



[0] http://permalink.gmane.org/gmane.linux.kernel.input/33587




> 
> Signed-off-by: Luis Ortega <luiorpe1@upv.es>
> ---
>  drivers/input/touchscreen/zforce_ts.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/zforce_ts.c
> b/drivers/input/touchscreen/zforce_ts.c index e082d5c..afb2492 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -33,6 +33,7 @@
>  #define WAIT_TIMEOUT		msecs_to_jiffies(1000)
> 
>  #define FRAME_START		0xee
> +#define FRAME_MAXSIZE		257
> 
>  /* Offsets of the different parts of the payload the controller sends */
>  #define PAYLOAD_HEADER		0
> @@ -475,7 +476,7 @@ static irqreturn_t zforce_irq_thread(int irq, void
> *dev_id) struct i2c_client *client = ts->client;
>  	const struct zforce_ts_platdata *pdata = dev_get_platdata(&client->dev);
>  	int ret;
> -	u8 payload_buffer[512];
> +	u8 payload_buffer[FRAME_MAXSIZE];
>  	u8 *payload;
> 
>  	/*


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Input: zforce - fix various small issues
  2014-01-27 18:46 Input: zforce - fix various small issues Luis Ortega
                   ` (3 preceding siblings ...)
  2014-01-27 18:46 ` [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames Luis Ortega
@ 2014-01-28  6:44 ` Dmitry Torokhov
  4 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2014-01-28  6:44 UTC (permalink / raw)
  To: Luis Ortega; +Cc: heiko, yongjun_wei, linux-input, linux-kernel

On Mon, Jan 27, 2014 at 07:46:09PM +0100, Luis Ortega wrote:
> As a kernel newbie and owner of a Barnes & Noble e-reader I was
> curious to review this driver to learn more about the touchscreen.
> 
> The first two patches are fairly innocuous whereas the last two
> slightly modify the code to fix two small issues I discovered.
> I don't have the setup to test them but they look logically correct
> to me.
> 
> [PATCH 1/4] Input: zforce - fix spelling errors
> [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns
> [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks
> [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames

Applied all 4, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-01-28  6:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 18:46 Input: zforce - fix various small issues Luis Ortega
2014-01-27 18:46 ` [PATCH 1/4] Input: zforce - fix spelling errors Luis Ortega
2014-01-27 18:41   ` Heiko Stübner
2014-01-27 18:46 ` [PATCH 2/4] Input: zforce - fix lines exceeding 80 columns Luis Ortega
2014-01-27 19:12   ` Heiko Stübner
2014-01-27 19:29     ` Luis Ortega
2014-01-27 18:46 ` [PATCH 3/4] Input: zforce - Remove unnecessary payload data checks Luis Ortega
2014-01-27 20:16   ` Heiko Stübner
2014-01-27 18:46 ` [PATCH 4/4] Input: zforce - reduce stack memory allocated to frames Luis Ortega
2014-01-27 20:22   ` Heiko Stübner
2014-01-28  6:44 ` Input: zforce - fix various small issues Dmitry Torokhov

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).