Received: by 10.213.65.68 with SMTP id h4csp843480imn; Thu, 22 Mar 2018 09:46:04 -0700 (PDT) X-Google-Smtp-Source: AG47ELsbkSd6/ZwLPA8OhmZE9bnDSIuuFpWLGaVHl/MipDDM9bHuy3MM28ZQba0wMSMyUPrR/61l X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr7740494plc.214.1521737164489; Thu, 22 Mar 2018 09:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521737164; cv=none; d=google.com; s=arc-20160816; b=SWr9gfkTVYbefNPORZ9G9IxGopkhC92Xu4pNlmx4aaWt1bbcSXfzx6r8SpwftWUlE0 g/EB/dg8dSzrFya/BY1WskhEvh4HA66AuFTEhFfx9+X8ObYlRmoHAQhL2BaxgPF37Mc2 Ibx2gq+s38A/0ezmj9Paukq/XeEDAQWSyHz/I1F2y5+OezsP89BfBP9/i99yK8De/JEB w2Y6BdvgNUUvFfDnk5Is304DzUHtq2X8GBp0Nz/l7O4/4rXsQFJ3KEsVt8eZXwFhN2Ww jupz0VSeevR7GV1E2kIp+6Pn3ulxEyY4IKe5+DwjGjUF6GqKrZDE/aHb6rqPNzEBBjkc z4JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yUhliwzzrLHKGoBdscCpghTK0gBUiDbNN+pirLQih3s=; b=Q2rz9h8hbrsCKVCZ+xjJwgH1MSzDTHhzmRruyfilyGwOyKRrc3CmNMRCoYYwl/jGR0 KvMss8aZ8Y+EY4z5mdsvbqMYT2ze23RK9OdgkhzUD3DeLkIAK9nvK1Awd6U/Er0JYbjT H1WKpZe4edHi2j71T7TLJ70ZwpihSjx7mhoWM1zHiPel01abunVLW3nnlz62CEN51Dd4 ybLmFkCWO9i3/wKWqfcu/sUA7LVo+1KFA4o+jvC3917LYWL/KThbIMdoWwIKEWiVmwjQ B35KO41L4I2t+TkU6NO0ZhYHp8ejxS/pCrTsF9I/TkoLmzCsrrdpCUTkxexF0eWR8Zp5 zFGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si3886085pgn.459.2018.03.22.09.45.49; Thu, 22 Mar 2018 09:46:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751894AbeCVQot (ORCPT + 99 others); Thu, 22 Mar 2018 12:44:49 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.16.2