linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Fuzzey <mfuzzey@parkeon.com>
To: Henrik Rydberg <rydberg@euromail.se>,
	Nick Dyer <nick.dyer@itdev.co.uk>,
	linux-input@vger.kernel.org
Subject: [PATCH] Input: atmel_mxt_ts: Configuration data unnecessarily uploaded at each probe.
Date: Mon, 09 Feb 2015 19:30:59 +0100	[thread overview]
Message-ID: <20150209183059.26064.89422.stgit@localhost> (raw)

mxt_update_cfg() first checks the info block CRC (data->info_crc) and
always does an upload irrespective of configuration CRC if it does not match.

However the info_crc is never initialised from the information provided
by the firmware which causes an upload to be done at each probe if
configuration data firmware is available.

Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
---
 drivers/input/touchscreen/atmel_mxt_ts.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index aaacf8b..0666759 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1413,21 +1413,26 @@ static int mxt_get_object_table(struct mxt_data *data)
 	int i;
 	u8 reportid;
 	u16 end_address;
+	u8 *crc_ptr;
 
 	table_size = data->info.object_num * sizeof(struct mxt_object);
-	object_table = kzalloc(table_size, GFP_KERNEL);
+	object_table = kzalloc(table_size + MXT_INFO_CHECKSUM_SIZE, GFP_KERNEL);
 	if (!object_table) {
 		dev_err(&data->client->dev, "Failed to allocate memory\n");
 		return -ENOMEM;
 	}
 
-	error = __mxt_read_reg(client, MXT_OBJECT_START, table_size,
+	error = __mxt_read_reg(client, MXT_OBJECT_START,
+			table_size + MXT_INFO_CHECKSUM_SIZE,
 			object_table);
 	if (error) {
 		kfree(object_table);
 		return error;
 	}
 
+	crc_ptr = (u8 *)object_table + table_size;
+	data->info_crc = crc_ptr[0] | (crc_ptr[1] << 8) | (crc_ptr[2] << 16);
+
 	/* Valid Report IDs start counting from 1 */
 	reportid = 1;
 	data->mem_size = 0;


                 reply	other threads:[~2015-02-09 19:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150209183059.26064.89422.stgit@localhost \
    --to=mfuzzey@parkeon.com \
    --cc=linux-input@vger.kernel.org \
    --cc=nick.dyer@itdev.co.uk \
    --cc=rydberg@euromail.se \
    /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;
as well as URLs for NNTP newsgroup(s).