From patchwork Fri Dec 22 18:31:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 757695 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 685EFBA30; Fri, 22 Dec 2023 18:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dolcini.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dolcini.it Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id 43E5E21EB5; Fri, 22 Dec 2023 19:31:18 +0100 (CET) From: Francesco Dolcini To: Dmitry Torokhov Cc: Emanuele Ghidoli , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Francesco Dolcini Subject: [PATCH v3 1/2] Input: ilitek_ts_i2c - avoid wrong input subsystem sync Date: Fri, 22 Dec 2023 19:31:13 +0100 Message-Id: <20231222183114.30775-2-francesco@dolcini.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222183114.30775-1-francesco@dolcini.it> References: <20231222183114.30775-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Emanuele Ghidoli For different reasons i2c transaction may fail or report id message content may be wrong. Avoid sync the input subsystem if message cannot be parsed. An input subsystem sync without points is interpreted as "nothing is touching the screen" while normally this is not the case. Fixes: 42370681bd46 ("Input: Add support for ILITEK Lego Series") Reviewed-by: Francesco Dolcini Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini --- v3: added reviewed by --- drivers/input/touchscreen/ilitek_ts_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/ilitek_ts_i2c.c b/drivers/input/touchscreen/ilitek_ts_i2c.c index fc4e39b6651a..250133f0d68f 100644 --- a/drivers/input/touchscreen/ilitek_ts_i2c.c +++ b/drivers/input/touchscreen/ilitek_ts_i2c.c @@ -203,9 +203,9 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) ilitek_touch_down(ts, id, x, y); } -err_sync_frame: input_mt_sync_frame(input); input_sync(input); +err_sync_frame: return error; } From patchwork Fri Dec 22 18:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 757971 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D8A0612E; Fri, 22 Dec 2023 18:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dolcini.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dolcini.it Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id A3E5821EB7; Fri, 22 Dec 2023 19:31:18 +0100 (CET) From: Francesco Dolcini To: Dmitry Torokhov Cc: Emanuele Ghidoli , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Francesco Dolcini Subject: [PATCH v3 2/2] Input: ilitek_ts_i2c - add report id message validation Date: Fri, 22 Dec 2023 19:31:14 +0100 Message-Id: <20231222183114.30775-3-francesco@dolcini.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222183114.30775-1-francesco@dolcini.it> References: <20231222183114.30775-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Emanuele Ghidoli Ilitek touch IC driver answer to plain i2c read request, after it has generated an interrupt request, with a report id message starting with an identifier and a series of points. If a request is sent unsolicited by an interrupt request the answer do not contain this identifier. Add a test to discard these messages, making the driver robust to spurious interrupt requests. Fixes: 42370681bd46 ("Input: Add support for ILITEK Lego Series") Reviewed-by: Francesco Dolcini Signed-off-by: Emanuele Ghidoli Signed-off-by: Francesco Dolcini --- v3: added reviewed by --- drivers/input/touchscreen/ilitek_ts_i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/input/touchscreen/ilitek_ts_i2c.c b/drivers/input/touchscreen/ilitek_ts_i2c.c index 250133f0d68f..557362490244 100644 --- a/drivers/input/touchscreen/ilitek_ts_i2c.c +++ b/drivers/input/touchscreen/ilitek_ts_i2c.c @@ -37,6 +37,8 @@ #define ILITEK_TP_CMD_GET_MCU_VER 0x61 #define ILITEK_TP_CMD_GET_IC_MODE 0xC0 +#define ILITEK_TP_I2C_REPORT_ID 0x48 + #define REPORT_COUNT_ADDRESS 61 #define ILITEK_SUPPORT_MAX_POINT 40 @@ -163,6 +165,11 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) goto err_sync_frame; } + if (buf[0] != ILITEK_TP_I2C_REPORT_ID) { + dev_err(dev, "get touch info failed. Wrong id: 0x%02X\n", buf[0]); + goto err_sync_frame; + } + report_max_point = buf[REPORT_COUNT_ADDRESS]; if (report_max_point > ts->max_tp) { dev_err(dev, "FW report max point:%d > panel info. max:%d\n",