All of lore.kernel.org
 help / color / mirror / Atom feed
From: Irina Tirdea <irina.tirdea@intel.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Bastien Nocera <hadess@hadess.net>,
	Aleksei Mamlin <mamlinav@gmail.com>,
	Karsten Merker <merker@debian.org>,
	linux-input@vger.kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	Octavian Purdila <octavian.purdila@intel.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Irina Tirdea <irina.tirdea@intel.com>
Subject: [PATCH v9 1/9] Input: goodix - use actual config length for each device type
Date: Mon, 12 Oct 2015 18:24:29 +0300	[thread overview]
Message-ID: <1444663477-30062-2-git-send-email-irina.tirdea@intel.com> (raw)
In-Reply-To: <1444663477-30062-1-git-send-email-irina.tirdea@intel.com>

Each of the Goodix devices supported by this driver has a fixed size for
the configuration information registers. The size varies depending on the
device and is specified in the datasheet.

Use the proper configuration length as specified in the datasheet for
each device model, so we do not read more than the actual size of the
configuration registers.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Acked-by: Bastien Nocera <hadess@hadess.net>
Tested-by: Bastien Nocera <hadess@hadess.net>
Tested-by: Aleksei Mamlin <mamlinav@gmail.com>
---
 drivers/input/touchscreen/goodix.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 4d113c9..56d0330 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -36,6 +36,7 @@ struct goodix_ts_data {
 	unsigned int max_touch_num;
 	unsigned int int_trigger_type;
 	bool rotated_screen;
+	int cfg_len;
 };
 
 #define GOODIX_MAX_HEIGHT		4096
@@ -45,6 +46,8 @@ struct goodix_ts_data {
 #define GOODIX_MAX_CONTACTS		10
 
 #define GOODIX_CONFIG_MAX_LENGTH	240
+#define GOODIX_CONFIG_911_LENGTH	186
+#define GOODIX_CONFIG_967_LENGTH	228
 
 /* Register defines */
 #define GOODIX_READ_COOR_ADDR		0x814E
@@ -115,6 +118,23 @@ static int goodix_i2c_read(struct i2c_client *client,
 	return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);
 }
 
+static int goodix_get_cfg_len(u16 id)
+{
+	switch (id) {
+	case 911:
+	case 9271:
+	case 9110:
+	case 927:
+	case 928:
+		return GOODIX_CONFIG_911_LENGTH;
+	case 912:
+	case 967:
+		return GOODIX_CONFIG_967_LENGTH;
+	default:
+		return GOODIX_CONFIG_MAX_LENGTH;
+	}
+}
+
 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
 {
 	int touch_num;
@@ -230,8 +250,7 @@ static void goodix_read_config(struct goodix_ts_data *ts)
 	int error;
 
 	error = goodix_i2c_read(ts->client, GOODIX_REG_CONFIG_DATA,
-				config,
-				GOODIX_CONFIG_MAX_LENGTH);
+				config, ts->cfg_len);
 	if (error) {
 		dev_warn(&ts->client->dev,
 			 "Error reading config (%d), using defaults\n",
@@ -398,6 +417,8 @@ static int goodix_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
+	ts->cfg_len = goodix_get_cfg_len(id_info);
+
 	goodix_read_config(ts);
 
 	error = goodix_request_input_dev(ts, version_info, id_info);
-- 
1.9.1


  reply	other threads:[~2015-10-12 15:25 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 15:24 [PATCH v9 0/9] Goodix touchscreen enhancements Irina Tirdea
2015-10-12 15:24 ` Irina Tirdea
2015-10-12 15:24 ` Irina Tirdea [this message]
2015-10-12 15:24 ` [PATCH v9 2/9] Input: goodix - reset device at init Irina Tirdea
2015-10-12 16:48   ` Dmitry Torokhov
2015-10-13  6:38     ` Tirdea, Irina
2015-10-13  7:08       ` Dmitry Torokhov
2015-10-13  7:08         ` Dmitry Torokhov
2015-10-13  8:54         ` Tirdea, Irina
2015-10-13 10:07           ` mika.westerberg
2015-10-14  6:23             ` Dmitry Torokhov
2015-10-14 11:18               ` mika.westerberg
2015-10-14 13:44                 ` mika.westerberg
2015-10-14 13:44                   ` mika.westerberg-VuQAYsv1563Yd54FQh9/CA
2015-10-19 14:32                   ` Tirdea, Irina
2015-10-19 14:52                     ` mika.westerberg
2015-10-30 16:33                       ` Dmitry Torokhov
2015-10-31 17:28                         ` Dmitry Torokhov
2015-11-02 10:17                         ` mika.westerberg
2015-11-02 10:17                           ` mika.westerberg-VuQAYsv1563Yd54FQh9/CA
2015-10-12 15:24 ` [PATCH v9 3/9] Input: goodix - write configuration data to device Irina Tirdea
2015-10-12 15:24 ` [PATCH v9 4/9] Input: goodix - add power management support Irina Tirdea
2015-10-12 15:24 ` [PATCH v9 5/9] Input: goodix - use goodix_i2c_write_u8 instead of i2c_master_send Irina Tirdea
2015-10-12 15:24 ` [PATCH v9 6/9] Input: goodix - add support for ESD Irina Tirdea
2015-10-12 15:24 ` [PATCH v9 7/9] Input: goodix - add sysfs interface to dump config Irina Tirdea
2015-10-12 15:24 ` [PATCH v9 8/9] Input: goodix - add runtime power management support Irina Tirdea
2015-10-12 15:24 ` [PATCH v9 9/9] Input: goodix - sort includes using inverse Xmas tree order Irina Tirdea
2015-10-12 15:39   ` Mark Rutland
2015-10-12 15:39     ` Mark Rutland
2015-10-12 15:40     ` Bastien Nocera
2015-10-12 15:51       ` Mark Rutland
2015-10-12 15:51         ` Mark Rutland
2015-10-12 15:53         ` Bastien Nocera
2015-10-12 16:30           ` Dmitry Torokhov
2015-10-12 16:30             ` Dmitry Torokhov
2015-10-13  6:42             ` Tirdea, Irina
2015-10-13  6:42               ` Tirdea, Irina
2015-10-26 15:06 ` [PATCH v9 0/9] Goodix touchscreen enhancements Bastien Nocera
2015-10-26 15:06   ` Bastien Nocera
2015-10-26 18:21   ` Karsten Merker
2015-10-26 18:40     ` Bastien Nocera
2015-10-26 23:32     ` Dmitry Torokhov
2015-10-27  9:13       ` Tirdea, Irina
2015-10-27  9:13         ` Tirdea, Irina
2015-10-27  9:15     ` Tirdea, Irina
2015-10-27  9:15       ` Tirdea, Irina

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=1444663477-30062-2-git-send-email-irina.tirdea@intel.com \
    --to=irina.tirdea@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hadess@hadess.net \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mamlinav@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=merker@debian.org \
    --cc=octavian.purdila@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.