public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Henrik Rydberg" <rydberg@euromail.se>
To: Daniel Kurtz <djkurtz@chromium.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Nick Dyer <nick.dyer@itdev.co.uk>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Benson Leung <bleung@chromium.org>,
	Yufeng Shen <miletus@chromium.org>
Subject: Re: [PATCH 08/16 v2] Input: atmel_mxt_ts - refactor mxt_object_show
Date: Wed, 11 Apr 2012 18:25:22 +0200	[thread overview]
Message-ID: <20120411162522.GA6980@polaris.bitmath.org> (raw)
In-Reply-To: <1333039766-8617-9-git-send-email-djkurtz@chromium.org>

On Fri, Mar 30, 2012 at 12:49:18AM +0800, Daniel Kurtz wrote:
> Read each object with a single i2c transaction instead of byte-by-byte.
> 
> Also, don't read T5, which is the message processor object.  Reading
> it is counter-productive since it either holds garbage (there is no
> pending message), or, it holds a real message which should be handled
> by the messages handling code (the isr).
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c |   43 ++++++++++++------------------
>  1 files changed, 17 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index b6e7109..a865967 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -262,7 +262,6 @@ struct mxt_data {
>  static bool mxt_object_readable(unsigned int type)
>  {
>  	switch (type) {
> -	case MXT_GEN_MESSAGE_T5:
>  	case MXT_GEN_COMMAND_T6:
>  	case MXT_GEN_POWER_T7:
>  	case MXT_GEN_ACQUIRE_T8:
> @@ -459,6 +458,13 @@ mxt_get_object(struct mxt_data *data, u8 type)
>  	return NULL;
>  }
>  
> +static int mxt_read_object(struct mxt_data *data, struct mxt_object *object,
> +			   void *val)
> +{
> +	return mxt_read_reg(data->client, object->start_address, object->size,
> +			    val);
> +}
> +
>  static int mxt_read_message(struct mxt_data *data,
>  				 struct mxt_message *message)
>  {
> @@ -474,20 +480,6 @@ static int mxt_read_message(struct mxt_data *data,
>  			    message);
>  }
>  
> -static int mxt_read_object(struct mxt_data *data,
> -				u8 type, u8 offset, u8 *val)
> -{
> -	struct mxt_object *object;
> -	u16 reg;
> -
> -	object = mxt_get_object(data, type);
> -	if (!object)
> -		return -EINVAL;
> -
> -	reg = object->start_address;
> -	return mxt_read_reg(data->client, reg + offset, 1, val);
> -}
> -
>  static int mxt_write_object(struct mxt_data *data,
>  				 u8 type, u8 offset, u8 val)
>  {
> @@ -885,17 +877,16 @@ static void mxt_calc_resolution(struct mxt_data *data)
>  }
>  
>  static ssize_t mxt_object_show(struct device *dev,
> -				    struct device_attribute *attr, char *buf)
> +			       struct device_attribute *attr, char *buf)
>  {
>  	struct mxt_data *data = dev_get_drvdata(dev);
> -	struct mxt_object *object;
>  	int count = 0;
>  	int i, j;
>  	int error;
> -	u8 val;
> +	u8 obuf[256];

How large buffer do you need?

>  
>  	for (i = 0; i < data->info.object_num; i++) {
> -		object = data->object_table + i;
> +		struct mxt_object *object = &data->object_table[i];
>  
>  		count += snprintf(buf + count, PAGE_SIZE - count,
>  				"Object[%d] (Type %d)\n",
> @@ -905,20 +896,20 @@ static ssize_t mxt_object_show(struct device *dev,
>  
>  		if (!mxt_object_readable(object->type)) {
>  			count += snprintf(buf + count, PAGE_SIZE - count,
> -					"\n");
> +					  "\n");
>  			if (count >= PAGE_SIZE)
>  				return PAGE_SIZE - 1;

Odd return value - why not use scnprintf()?

>  			continue;
>  		}
>  
> -		for (j = 0; j < object->size; j++) {
> -			error = mxt_read_object(data,
> -						object->type, j, &val);
> -			if (error)
> -				return error;
> +		error = mxt_read_object(data, object, obuf);
> +		if (error)
> +			return error;
>  
> +		for (j = 0; j < object->size; j++) {
>  			count += snprintf(buf + count, PAGE_SIZE - count,
> -					"\t[%2d]: %02x (%d)\n", j, val, val);
> +					  "\t[%2d]: %02x (%d)\n", j, obuf[j],
> +					  obuf[j]);
>  			if (count >= PAGE_SIZE)
>  				return PAGE_SIZE - 1;

Ditto.

>  		}
> -- 
> 1.7.7.3
> 

Thanks,
Henrik

  reply	other threads:[~2012-04-11 16:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 16:49 [PATCH 00/16 v2] cleanup atmel_mxt_ts Daniel Kurtz
2012-03-29 16:49 ` [PATCH 01/16 v2] Input: atmel_mxt_ts - use CONFIG_PM_SLEEP Daniel Kurtz
2012-03-29 16:49 ` [PATCH 02/16 v2] Input: atmel_mxt_ts - only allow root to update firmware Daniel Kurtz
2012-03-29 16:49 ` [PATCH 03/16 v2] Input: atmel_mxt_ts - refactor mxt_read/write_reg to take a length Daniel Kurtz
2012-04-11  9:05   ` Henrik Rydberg
2012-04-14  4:12     ` Daniel Kurtz
2012-03-29 16:49 ` [PATCH 04/16 v2] Input: atmel_mxt_ts - store actual size and instance Daniel Kurtz
2012-03-29 16:49 ` [PATCH 05/16 v2] Input: atmel_mxt_ts - verify object size in mxt_write_object Daniel Kurtz
2012-03-29 16:49 ` [PATCH 06/16 v2] Input: atmel_mxt_ts - do not read extra (checksum) byte Daniel Kurtz
2012-03-29 16:49 ` [PATCH 07/16 v2] Input: atmel_mxt_ts - dump each message on just 1 line Daniel Kurtz
2012-03-29 16:49 ` [PATCH 08/16 v2] Input: atmel_mxt_ts - refactor mxt_object_show Daniel Kurtz
2012-04-11 16:25   ` Henrik Rydberg [this message]
2012-03-29 16:49 ` [PATCH 09/16 v2] Input: atmel_mxt_ts - optimize writing of object table entries Daniel Kurtz
2012-04-13  9:13   ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 10/16 v2] Input: atmel_mxt_ts - refactor get info Daniel Kurtz
2012-03-29 16:49 ` [PATCH 11/16 v2] Input: atmel_mxt_ts - refactor reading object table Daniel Kurtz
2012-04-13  9:11   ` Henrik Rydberg
2012-04-13  9:21     ` Daniel Kurtz
2012-04-13  9:34       ` Henrik Rydberg
2012-04-13 10:10         ` Daniel Kurtz
2012-04-13 11:09           ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 12/16 v2] Input: atmel_mxt_ts - simplify event reporting Daniel Kurtz
2012-03-29 16:49 ` [PATCH 13/16 v2] Input: atmel_mxt_ts - cache T9 reportid range when reading object table Daniel Kurtz
2012-03-29 16:49 ` [PATCH 14/16 v2] Input: atmel_mxt_ts - parse vector field of data packets Daniel Kurtz
2012-03-29 16:49 ` [PATCH 15/16 v2] Input: atmel_mxt_ts - send all MT-B slots in one input report Daniel Kurtz
2012-04-13  9:20   ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 16/16 v2] Input: atmel_mxt_ts - parse T6 reports Daniel Kurtz
2012-04-09 13:14 ` [PATCH 00/16 v2] cleanup atmel_mxt_ts Daniel Kurtz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120411162522.GA6980@polaris.bitmath.org \
    --to=rydberg@euromail.se \
    --cc=bleung@chromium.org \
    --cc=djkurtz@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jy0922.shim@samsung.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miletus@chromium.org \
    --cc=nick.dyer@itdev.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox