All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johnny Chuang <johnny.chuang@emc.com.tw>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Daniel Kurtz <djkurtz@gmail.com>,
	Jennifer Tsai <jennifer.tsai@emc.com.tw>,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Cc: James Chen <james.chen@emc.com.tw>,
	Paul Liang <paul.liang@emc.com.tw>,
	Jeff Chuang <jeff.chuang@emc.com.tw>,
	Agnes Cheng <agnescheng@google.com>,
	Johnny Chuang <johnny.chuang@emc.com.tw>
Subject: [PATCH v3] Input: elants_i2c - get product id on recovery mode for FW update
Date: Fri, 23 Sep 2016 16:01:17 +0800	[thread overview]
Message-ID: <1474617677-4785-1-git-send-email-johnny.chuang@emc.com.tw> (raw)
In-Reply-To: <1472028265-5018-1-git-send-email-johnny.chuang@emc.com.tw>

This CL takes the responsibility for getting product/hardware id
on recovery mode.
It will fix firmware update script could not find correspond firmware
file name on recovery mode.
BTW, firmware must need to support reading product/hardware id
on boot code.

Signed-off-by: Johnny Chuang <johnny.chuang@emc.com.tw>
---
 drivers/input/touchscreen/elants_i2c.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index ac09855..02aec28 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -298,7 +298,7 @@ static u16 elants_i2c_parse_version(u8 *buf)
 	return get_unaligned_be32(buf) >> 4;
 }
 
-static int elants_i2c_query_fw_id(struct elants_data *ts)
+static int elants_i2c_query_hw_version(struct elants_data *ts)
 {
 	struct i2c_client *client = ts->client;
 	int error, retry_cnt;
@@ -318,8 +318,13 @@ static int elants_i2c_query_fw_id(struct elants_data *ts)
 			error, (int)sizeof(resp), resp);
 	}
 
-	dev_err(&client->dev,
-		"Failed to read fw id or fw id is invalid\n");
+	if (error) {
+		dev_err(&client->dev,
+			"Failed to read fw id: %d\n", error);
+		return error;
+	}
+
+	dev_err(&client->dev, "Invalid fw id: %#04x\n", ts->hw_version);
 
 	return -EINVAL;
 }
@@ -508,7 +513,7 @@ static int elants_i2c_fastboot(struct i2c_client *client)
 static int elants_i2c_initialize(struct elants_data *ts)
 {
 	struct i2c_client *client = ts->client;
-	int error, retry_cnt;
+	int error, error2, retry_cnt;
 	const u8 hello_packet[] = { 0x55, 0x55, 0x55, 0x55 };
 	const u8 recov_packet[] = { 0x55, 0x55, 0x80, 0x80 };
 	u8 buf[HEADER_SIZE];
@@ -553,18 +558,22 @@ static int elants_i2c_initialize(struct elants_data *ts)
 		}
 	}
 
+	/* hw version is available even if device in recovery state */
+	error2 = elants_i2c_query_hw_version(ts);
 	if (!error)
-		error = elants_i2c_query_fw_id(ts);
+		error = error2;
+
 	if (!error)
 		error = elants_i2c_query_fw_version(ts);
+	if (!error)
+		error = elants_i2c_query_test_version(ts);
+	if (!error)
+		error = elants_i2c_query_bc_version(ts);
+	if (!error)
+		error = elants_i2c_query_ts_info(ts);
 
-	if (error) {
+	if (error)
 		ts->iap_mode = ELAN_IAP_RECOVERY;
-	} else {
-		elants_i2c_query_test_version(ts);
-		elants_i2c_query_bc_version(ts);
-		elants_i2c_query_ts_info(ts);
-	}
 
 	return 0;
 }
-- 
1.8.3.2

  parent reply	other threads:[~2016-09-23  8:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24  8:44 [PATCH] Input: elants_i2c - get product id on recovery mode for FW update Johnny Chuang
2016-08-25  8:31 ` kbuild test robot
2016-08-25  8:31   ` kbuild test robot
2016-08-25 10:11 ` Johnny Chuang
2016-08-25 16:40   ` Dmitry Torokhov
2016-09-23  8:01 ` Johnny Chuang [this message]
2016-09-23 21:30   ` [PATCH v3] " Dmitry Torokhov
2016-09-26  2:30     ` Johnny.Chuang
2016-09-26  2:30       ` Johnny.Chuang
2016-09-27  2:54       ` 'Dmitry Torokhov'

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=1474617677-4785-1-git-send-email-johnny.chuang@emc.com.tw \
    --to=johnny.chuang@emc.com.tw \
    --cc=agnescheng@google.com \
    --cc=djkurtz@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=james.chen@emc.com.tw \
    --cc=jeff.chuang@emc.com.tw \
    --cc=jennifer.tsai@emc.com.tw \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.liang@emc.com.tw \
    /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.