From patchwork Thu Mar 22 16:43:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 10301895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF91060385 for ; Thu, 22 Mar 2018 16:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A325C287BE for ; Thu, 22 Mar 2018 16:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94A63287CF; Thu, 22 Mar 2018 16:44:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BCBD287CE for ; Thu, 22 Mar 2018 16:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751594AbeCVQos (ORCPT ); Thu, 22 Mar 2018 12:44:48 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:38202 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbeCVQor (ORCPT ); Thu, 22 Mar 2018 12:44:47 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id E078E265E52 From: Sebastian Reichel To: Sebastian Reichel , Nick Dyer , Dmitry Torokhov , linux-input@vger.kernel.org Cc: Henrik Rydberg , linux-kernel@vger.kernel.org, kernel@collabora.com, Nandor Han , Sebastian Reichel Subject: [PATCHv1] Input: atmel_mxt_ts - fix the firmware update Date: Thu, 22 Mar 2018 17:43:30 +0100 Message-Id: <20180322164330.24809-1-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.16.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nandor Han The automatic update mechanism will trigger an update if the info block CRCs are different between maxtouch configuration file (maxtouch.cfg) and chip. The driver compared the CRCs without retrieving the chip CRC, resulting always in a failure and firmware flashing action triggered. The patch will fix this issue by retrieving the chip info block CRC before the check. Suggested-by: Todd Weyenberg Signed-off-by: Nandor Han Signed-off-by: Sebastian Reichel --- drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7659bc48f1db..ab936e6b0286 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1728,6 +1728,25 @@ static int mxt_get_object_table(struct mxt_data *data) return error; } +static int mxt_get_info_block_crc(struct mxt_data *data) +{ + size_t table_size; + int error; + u8 info_block_crc[MXT_INFO_CHECKSUM_SIZE]; + + table_size = data->info.object_num * sizeof(struct mxt_object); + + /* Read the info block CRC */ + error = __mxt_read_reg(data->client, MXT_OBJECT_START + table_size, + sizeof(info_block_crc), info_block_crc); + if (!error) { + data->info_crc = info_block_crc[0] | (info_block_crc[1] << 8) | + (info_block_crc[2] << 16); + } + + return error; +} + static int mxt_read_t9_resolution(struct mxt_data *data) { struct i2c_client *client = data->client; @@ -2077,6 +2096,14 @@ static int mxt_initialize(struct mxt_data *data) return error; } + /* Get info block CRC */ + error = mxt_get_info_block_crc(data); + if (error) { + dev_err(&client->dev, "Error %d reading info block CRC\n", + error); + return error; + } + error = mxt_acquire_irq(data); if (error) goto err_free_object_table;