Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1370007ybj; Thu, 7 May 2020 23:03:54 -0700 (PDT) X-Google-Smtp-Source: APiQypLzQBOFmgOkRYnhLHBmwz3zww5hW4pUYnPKquFayk0mts9zuK8cfzBQ6IUHHqL6xlJU0mLa X-Received: by 2002:aa7:dcd7:: with SMTP id w23mr844754edu.300.1588917834241; Thu, 07 May 2020 23:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588917834; cv=none; d=google.com; s=arc-20160816; b=tSGX10x05Mxve3WJ85t9zFcG6bCAET0TBKmRVORtCMbS5P/vdrpRrerioqSSUQsd30 oV4UBYQ7mvnOq38YVYMEk28iPILcZBhzaUVkbCmCQdpa+9+QWFFrDpp7KScKzFbsRCuV q6JkOm8dGoaFYrj2+aXxFMA/OCdzqLOoZ6wKsd/WerWEYJouUf17bjaw0wW7lAjlMSKR GeHrX2B1qb5oDeA6YQrHyhU2jLbCr/9GkvQnIGbJGltnRH298LEmhx0U7zkInH0gZlDc kjZbW1+0bMsKYpQEaFKEGkBbhFSkggf9CABp0zYz0hDkRSa+l+0JZ86EMakJxHUs3ppR /uFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=nwie3gsv6y3A4/+1N/Mjv8JlT0pC8Pl2wPh1kK3D9vE=; b=PLps6yU5e1xL/BEXMbJ0Dr1nk5v1Mtko7VCM+s5QzGRpddUhk4A6dQ+vTCgWTBckF3 ZJqqlJTtF8TCtQQAhna7txhxbS1OIi7LF2R8QPwCPFossmOeoUJRM4mUxYpDkLPuUrjG zu7+B4fxL4jcOWJLzrfR9aBUUl1QB6I994LTwB979JV2mgtDaZLAQcRIktRp0b7RDhXR nJe1RBQxB6aXTBtMrK/5pVjrLgqes2JsswCXoaKqrsPL4OZ+HRlArGE5wDwri/0Gqq1a A/+WhiRHP+vIkWhwL8rc10Ea+++sx6puMhmLhlmTq6vx2pezEpiBE1fGUxjI4SKLZBlp BRFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si381021edm.108.2020.05.07.23.03.31; Thu, 07 May 2020 23:03:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbgEHGAw (ORCPT + 99 others); Fri, 8 May 2020 02:00:52 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:21956 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbgEHF5V (ORCPT ); Fri, 8 May 2020 01:57:21 -0400 IronPort-SDR: VNTh+qtmXJ2y1073y4XPJZE0KiM5jVaXv4SYaF6e2vggFs3uf70IQu8IY6O5oKNdvw5XzBgY1Y 8x6sZqMgcDuR+N9Ce23TT4miPgx8UyJgUcSJ5+t4jyKHiax+mBkSpTqmRVgiwBo5vZRg8+2SqU bD23jlTxrjk7pSkiLQVi/duAYUl4MZyWz8K/7VrM3OLFPXgKyQOe+yYR9C3qra+62hQWmT9lqv xYCL6baj3q80h5bZq1ZIp6QvpeH+JNd55Zw/yKcL5e3/ZzeI75ZSBhtlnMAoRoPxlDHhQ+Cu/l fjI= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48651902" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:18 -0800 IronPort-SDR: ltE0ZwoC3R5bRPsD+OTehOiLRU8BsmP7rEb48qc7UPRFIWy3Hq3DItZMRwYCix/vOx837PJzjp H/mf3mLPXmMbxlQp3NfI+sH34+WV/Co8WFX28oOOy9sMY3Zl6xjRNO8b4KZUPJskI6JweXChit 5F0CYbN7G4qwG1QOW4KnMw0JVBhgWJwa+o0EBuhVk3IUXrqkh8kFIwypIjRIYfTP3tJ+0GjOEr gs34TjncMR4gLxe+JgD/QS2GeeGPgnKbyOe3HqpiQ3oreqqhSRy4Oy3ajSXyKbvWbgysKCA8Zn ZPI= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 04/56] Input: atmel_mxt_ts - split large i2c transfers into blocks Date: Thu, 7 May 2020 22:56:04 -0700 Message-ID: <20200508055656.96389-5-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Dyer On some firmware variants, the size of the info block exceeds what can be read in a single transfer. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 74c4f5277cfa403d43fafc404119dc57a08677db) [gdavis: Forward port and fix conflicts due to v4.14.51 commit 960fe000b1d3 ("Input: atmel_mxt_ts - fix the firmware update").] Signed-off-by: George G. Davis [jiada: Change mxt_read_blks() to __mxt_read_reg(), original __mxt_read_reg() to __mxt_read_chunk()] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 3f1ebe14802f..7e6a66e3e1e0 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -40,7 +40,7 @@ #define MXT_OBJECT_START 0x07 #define MXT_OBJECT_SIZE 6 #define MXT_INFO_CHECKSUM_SIZE 3 -#define MXT_MAX_BLOCK_WRITE 256 +#define MXT_MAX_BLOCK_WRITE 255 /* Object types */ #define MXT_DEBUG_DIAGNOSTIC_T37 37 @@ -624,8 +624,8 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock) return 0; } -static int __mxt_read_reg(struct i2c_client *client, - u16 reg, u16 len, void *val) +static int __mxt_read_chunk(struct i2c_client *client, + u16 reg, u16 len, void *val) { struct i2c_msg xfer[2]; u8 buf[2]; @@ -659,6 +659,28 @@ static int __mxt_read_reg(struct i2c_client *client, return ret; } +static int __mxt_read_reg(struct i2c_client *client, + u16 reg, u16 len, void *buf) +{ + u16 offset = 0; + int error; + u16 size; + + while (offset < len) { + size = min(MXT_MAX_BLOCK_WRITE, len - offset); + + error = __mxt_read_chunk(client, + reg + offset, + size, buf + offset); + if (error) + return error; + + offset += size; + } + + return 0; +} + static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, const void *val) { -- 2.17.1