linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Iiro Valkonen <iiro.valkonen@atmel.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Trilok Soni <tsoni@codeaurora.org>, linux-input@vger.kernel.org
Subject: Re: [PATCH 1/5] Remove fixed config data from driver file; add config to platform data
Date: Thu, 10 Feb 2011 09:57:25 +0200	[thread overview]
Message-ID: <4D539A65.1030000@atmel.com> (raw)
In-Reply-To: <20110204085754.GE13046@core.coreip.homeip.net>

Hi Dmitry,

On 02/04/2011 10:57 AM, Dmitry Torokhov wrote:
> On Thu, Feb 03, 2011 at 04:01:17PM +0200, Iiro Valkonen wrote:
>> +	unsigned char *config;
> 
> This should be "const u8 *config". Also it would be a good idea to also
> pass length and validate it when dereferencing.
> 
> Thanks.
> 

thanks for the feedback, here's a patch where those issues are fixed.

-- 
Iiro

Input: qt602240_ts - Remove fixed config data from driver file; add config to platform data

From: Iiro Valkonen <iiro.valkonen@atmel.com>

As there is no common configuration settings that would work in every situation, remove the fixed config data from driver file; and add config data to platform data.

Signed-off-by: Iiro Valkonen <iiro.valkonen@atmel.com>
---
 drivers/input/touchscreen/qt602240_ts.c |  147 +++----------------------------
 include/linux/i2c/qt602240_ts.h         |    2 +
 2 files changed, 16 insertions(+), 133 deletions(-)

diff --git a/drivers/input/touchscreen/qt602240_ts.c b/drivers/input/touchscreen/qt602240_ts.c
index 3612678..115dcc4 100644
--- a/drivers/input/touchscreen/qt602240_ts.c
+++ b/drivers/input/touchscreen/qt602240_ts.c
@@ -199,122 +199,6 @@
 
 #define MXT_MAX_FINGER		10
 
-/* Initial register values recommended from chip vendor */
-static const u8 init_vals_ver_20[] = {
-	/* MXT_GEN_COMMAND(6) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_GEN_POWER(7) */
-	0x20, 0xff, 0x32,
-	/* MXT_GEN_ACQUIRE(8) */
-	0x08, 0x05, 0x05, 0x00, 0x00, 0x00, 0x05, 0x14,
-	/* MXT_TOUCH_MULTI(9) */
-	0x00, 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00,
-	0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x64,
-	/* MXT_TOUCH_KEYARRAY(15) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00,
-	/* MXT_SPT_GPIOPWM(19) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00,
-	/* MXT_PROCI_GRIPFACE(20) */
-	0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x1e, 0x14, 0x04,
-	0x1e, 0x00,
-	/* MXT_PROCG_NOISE(22) */
-	0x05, 0x00, 0x00, 0x19, 0x00, 0xe7, 0xff, 0x04, 0x32, 0x00,
-	0x01, 0x0a, 0x0f, 0x14, 0x00, 0x00, 0xe8,
-	/* MXT_TOUCH_PROXIMITY(23) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00,
-	/* MXT_PROCI_ONETOUCH(24) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_SPT_SELFTEST(25) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00,
-	/* MXT_PROCI_TWOTOUCH(27) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_SPT_CTECONFIG(28) */
-	0x00, 0x00, 0x00, 0x04, 0x08,
-};
-
-static const u8 init_vals_ver_21[] = {
-	/* MXT_GEN_COMMAND(6) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_GEN_POWER(7) */
-	0x20, 0xff, 0x32,
-	/* MXT_GEN_ACQUIRE(8) */
-	0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
-	/* MXT_TOUCH_MULTI(9) */
-	0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
-	0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_TOUCH_KEYARRAY(15) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00,
-	/* MXT_SPT_GPIOPWM(19) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_PROCI_GRIPFACE(20) */
-	0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
-	0x0f, 0x0a,
-	/* MXT_PROCG_NOISE(22) */
-	0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
-	0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
-	/* MXT_TOUCH_PROXIMITY(23) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00,
-	/* MXT_PROCI_ONETOUCH(24) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_SPT_SELFTEST(25) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00,
-	/* MXT_PROCI_TWOTOUCH(27) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_SPT_CTECONFIG(28) */
-	0x00, 0x00, 0x00, 0x08, 0x10, 0x00,
-};
-
-static const u8 init_vals_ver_22[] = {
-	/* MXT_GEN_COMMAND(6) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_GEN_POWER(7) */
-	0x20, 0xff, 0x32,
-	/* MXT_GEN_ACQUIRE(8) */
-	0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
-	/* MXT_TOUCH_MULTI(9) */
-	0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
-	0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00,
-	/* MXT_TOUCH_KEYARRAY(15) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00,
-	/* MXT_SPT_GPIOPWM(19) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_PROCI_GRIPFACE(20) */
-	0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
-	0x0f, 0x0a,
-	/* MXT_PROCG_NOISE(22) */
-	0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
-	0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
-	/* MXT_TOUCH_PROXIMITY(23) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_PROCI_ONETOUCH(24) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_SPT_SELFTEST(25) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00,
-	/* MXT_PROCI_TWOTOUCH(27) */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* MXT_SPT_CTECONFIG(28) */
-	0x00, 0x00, 0x00, 0x08, 0x10, 0x00,
-};
-
 struct mxt_info {
 	u8 family_id;
 	u8 variant_id;
@@ -714,26 +598,18 @@ end:
 
 static int mxt_check_reg_init(struct mxt_data *data)
 {
+	const struct mxt_platform_data *pdata = data->pdata;
 	struct mxt_object *object;
 	struct device *dev = &data->client->dev;
 	int index = 0;
-	int i, j;
-	u8 version = data->info.version;
+	int i, j, config_offset;
 	u8 *init_vals;
 
-	switch (version) {
-	case MXT_VER_20:
-		init_vals = (u8 *)init_vals_ver_20;
-		break;
-	case MXT_VER_21:
-		init_vals = (u8 *)init_vals_ver_21;
-		break;
-	case MXT_VER_22:
-		init_vals = (u8 *)init_vals_ver_22;
-		break;
-	default:
-		dev_err(dev, "Firmware version %d doesn't support\n", version);
-		return -EINVAL;
+	if (pdata->config) {
+		init_vals = (u8 *)pdata->config;
+	} else {
+		dev_err(dev, "No cfg data defined, skipping reg init\n");
+		return 0;
 	}
 
 	for (i = 0; i < data->info.object_num; i++) {
@@ -742,9 +618,14 @@ static int mxt_check_reg_init(struct mxt_data *data)
 		if (!mxt_object_writable(object->type))
 			continue;
 
-		for (j = 0; j < object->size + 1; j++)
+		for (j = 0; j < object->size + 1; j++) {
+			config_offset = index + j;
+			if (config_offset > pdata->config_length) {
+				dev_err(dev, "Not enough config data!\n");
+				return -EINVAL;
+			}
 			mxt_write_object(data, object->type, j,
-					init_vals[index + j]);
+					init_vals[config_offset]);
 
 		index += object->size + 1;
 	}
diff --git a/include/linux/i2c/qt602240_ts.h b/include/linux/i2c/qt602240_ts.h
index 0b4c72f..219392a 100644
--- a/include/linux/i2c/qt602240_ts.h
+++ b/include/linux/i2c/qt602240_ts.h
@@ -33,6 +33,8 @@ struct mxt_platform_data {
 	unsigned int threshold;
 	unsigned int voltage;
 	unsigned char orient;
+	const u8 *config;
+	unsigned int config_length;
 };
 
 #endif /* __LINUX_MAXTOUCH_TS_H */
-- 
1.7.0.4



  reply	other threads:[~2011-02-10  7:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24 16:52 [PATCH] input: Modify the qt602240 driver to be compatible with mXT1386 device Iiro Valkonen
2011-01-24 17:07 ` Dmitry Torokhov
2011-01-25 10:33   ` [PATCH 1/2] input: Modify the qt602240 driver to be compatible with mXT1386 device - renames Iiro Valkonen
2011-01-25 11:00     ` Trilok Soni
2011-01-27 11:32       ` Trilok Soni
2011-02-01  8:45         ` Valkonen, Iiro
2011-02-03  7:29           ` Dmitry Torokhov
2011-01-25 10:37   ` [PATCH 2/2] input: Modify the qt602240 driver to be compatible with mXT1386 device - functional changes Iiro Valkonen
2011-01-29  8:27     ` Dmitry Torokhov
2011-02-01  8:17       ` Valkonen, Iiro
2011-02-01  8:32         ` Dmitry Torokhov
2011-02-01  8:53     ` Valkonen, Iiro
2011-02-03  7:43       ` Dmitry Torokhov
2011-02-03 14:01         ` [PATCH 1/5] Remove fixed config data from driver file; add config to platform data Iiro Valkonen
2011-02-04  8:57           ` Dmitry Torokhov
2011-02-10  7:57             ` Iiro Valkonen [this message]
2011-02-18 14:21               ` Iiro Valkonen
2011-02-18 16:48                 ` Dmitry Torokhov
2011-02-03 14:02         ` [PATCH 2/5] Read whole message instead of just the first byte to make CHG low Iiro Valkonen
2011-02-04  8:54           ` Dmitry Torokhov
2011-02-03 14:04         ` [PATCH 3/5] Skip matrix size check Iiro Valkonen
2011-02-04  8:59           ` Dmitry Torokhov
2011-02-11 13:32             ` Iiro Valkonen
2011-02-11 17:38               ` Dmitry Torokhov
2011-02-03 14:10         ` [PATCH 4/5] Try IRQF_TRIGGER_NONE if IRQF_TRIGGER_FALLING returns error Iiro Valkonen
2011-02-04  8:53           ` Dmitry Torokhov
2011-02-10  8:03             ` Iiro Valkonen
2011-02-03 14:13         ` [PATCH 5/5] Add chip I2C addresses to header file Iiro Valkonen
2011-02-03 14:49           ` Mark Brown
2011-02-04  8:37             ` Iiro Valkonen
2011-02-04  8:43               ` Dmitry Torokhov
2011-02-04 14:25               ` Mark Brown

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=4D539A65.1030000@atmel.com \
    --to=iiro.valkonen@atmel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=tsoni@codeaurora.org \
    /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).