linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>,
	linux-input@vger.kernel.org, kernel@pengutronix.de,
	patchwork-lst@pengutronix.de
Subject: [PATCH v3 3/5] Input: exc3000 - fix firmware version query for device in bootloader
Date: Mon, 25 Jan 2021 19:25:25 +0100	[thread overview]
Message-ID: <20210125182527.1225245-4-l.stach@pengutronix.de> (raw)
In-Reply-To: <20210125182527.1225245-1-l.stach@pengutronix.de>

If the device is stuck in bootloader (maybe due to blank or corrupted
application firmware) it won't answer a query for the firmware version.
Fall back to returning the bootloader version in that case.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/input/touchscreen/exc3000.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index b008adc1031d..ae06290a4c45 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -260,6 +260,20 @@ static ssize_t fw_version_show(struct device *dev,
 	u8 response[EXC3000_LEN_FRAME];
 	int ret;
 
+	/* query bootloader info */
+	ret = exc3000_vendor_data_request(data,
+					  (u8[]){0x39, 0x02}, 2, response, 1);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * If the bootloader version is non-zero then the device is in
+	 * bootloader mode and won't answer a query for the application FW
+	 * version, so we just use the bootloader version info.
+	 */
+	if (response[2] || response[3])
+		return sprintf(buf, "%d.%d\n", response[2], response[3]);
+
 	ret = exc3000_vendor_data_request(data, (u8[]){'D'}, 1, response, 1);
 	if (ret < 0)
 		return ret;
-- 
2.20.1


  parent reply	other threads:[~2021-01-25 18:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25 18:25 [PATCH v3 0/5] exc3000 firmware update support Lucas Stach
2021-01-25 18:25 ` [PATCH v3 1/5] Input: exc3000 - split MT event handling from IRQ handler Lucas Stach
2021-03-08  5:43   ` Dmitry Torokhov
2021-01-25 18:25 ` [PATCH v3 2/5] Input: exc3000 - factor out vendor data request Lucas Stach
2021-03-08  5:43   ` Dmitry Torokhov
2021-01-25 18:25 ` Lucas Stach [this message]
2021-03-08  5:44   ` [PATCH v3 3/5] Input: exc3000 - fix firmware version query for device in bootloader Dmitry Torokhov
2021-01-25 18:25 ` [PATCH v3 4/5] Input: exc3000 - add type sysfs attribute Lucas Stach
2021-03-08  5:44   ` Dmitry Torokhov
2021-01-25 18:25 ` [PATCH v3 5/5] Input: exc3000 - add firmware update support Lucas Stach
2021-03-08  5:47   ` Dmitry Torokhov
2021-03-08  9:17     ` Lucas Stach
2021-03-05 10:50 ` [PATCH v3 0/5] exc3000 " Lucas Stach

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=20210125182527.1225245-4-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-input@vger.kernel.org \
    --cc=patchwork-lst@pengutronix.de \
    --cc=sebastian.reichel@collabora.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 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).