summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/exc3000.c
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2021-03-07 21:40:01 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2021-03-07 21:56:49 -0800
commitc929ac9eb85acf9217eb812369bbd4cf65a772e0 (patch)
treecb3a856d21bea8e6f61c6fc2a1e0c404f3a09a91 /drivers/input/touchscreen/exc3000.c
parent102feb1ddfd00d0c6115ae3372058012dc16418c (diff)
Input: exc3000 - fix firmware version query for device in bootloader
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> Link: https://lore.kernel.org/r/20210125182527.1225245-4-l.stach@pengutronix.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen/exc3000.c')
-rw-r--r--drivers/input/touchscreen/exc3000.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index e55fb79c7fde..66682a0c37d7 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -263,6 +263,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;