Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp592595pja; Thu, 19 Mar 2020 08:01:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsZISzAbpBJfkV/PvBCpC85SAkXG1O7bNnwNzxTOUKC3lD809XOBkxQpi4VSQsf2NxmwwRr X-Received: by 2002:a9d:5c0c:: with SMTP id o12mr2660863otk.145.1584630089169; Thu, 19 Mar 2020 08:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584630089; cv=none; d=google.com; s=arc-20160816; b=ZqWc4eCtiZarD5ZkT4+zooLpqyLPjxQTFJeyDhXFfm9AGITk/sSG5uVreuY7AVhOdP lCb1k78QcV31GF7UwBc1EZ9ZF/aNSNjP1EPNt3byRBY+sRZ5eeqZfznRxW4E6Y8aSGTp hKUAiVXgNAAP6Lgl3kdOMCkqnkmC8xAdlQZ+v6lzgu+4+ZHZB+oiPFZCAzByqZUtD3x9 boFm6idVcU+FjLpHUcnEVUqot5edxacqKqhG0M1+fBtKt6YfLS/wIdXE8A1PJgfTwZQW ftsH+cgY8UmYXl3W+huGYJcb01FecakjvRnkjsqowBPP1MXzqeBwNw+NaebmGoy0IjLu Pj3A== 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=JTA1M590lw7Q0JjWFNiAKbrliJTHC2pqc6E18lG6UmpLiE5g3KezYqVlZlkBJG/FsS t1xXDqZlikleMFwFG3ikEuheg39osxtW6mxm8Pt7KnFanFTHy42XbT2GL4T0/XV6wsSM fTkS7V0bDt7MetLlS62YdE8h0woq37U2HcRwdMHbe7baLHrCFH0TkIa30XIQcd6T8wm+ sdl3qDJeznYyI1ep9KDCgttfCK9wPt5HijzrIseeqWZahAX2Iybt+ph8OsCk5b3RvJ6O P8zL9xRWoD9IGycu10BLgl5umjSo/gMgmoJmXVS02P+VzjtLM3xhtKvx6I0rdLbDIbyJ 1+eA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si1538725otk.212.2020.03.19.08.01.06; Thu, 19 Mar 2020 08:01:29 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbgCSPAj (ORCPT + 99 others); Thu, 19 Mar 2020 11:00:39 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:15923 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbgCSPAj (ORCPT ); Thu, 19 Mar 2020 11:00:39 -0400 IronPort-SDR: aq9BidRel6u2dHiaDJejrznQabVWcfiPPFH28pVCrpcPy7uOPOy6uVuBMswiEYLRHhXxalLjTD uKq1vuPQN3sm6VuR2sX8PJg2VbJbCzPyQtbXYv7KmQP/yXo8sZlENlUNimQroYPwlSztJXd3nV Rfbe41je5n0JV0hmfFxKSxpuxUP0x1UTtC529Jk8/B/jN+Rx5DUQTXsNMY3N72TVAw3WZodCOt 3mB8N3DFnUx9FOhbzuAcQ+HjVWP30N/2hWKsPO+lnPcLeo4bFBm4znv1o7XjzA5g9x3UQxTQrT JT8= X-IronPort-AV: E=Sophos;i="5.70,572,1574150400"; d="scan'208";a="48850130" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 19 Mar 2020 07:00:38 -0800 IronPort-SDR: V666wCBxE7uhKD5NWWFiTqoOOsLRkXJrRveIYym1WNZCWKtzP0x97v1QPSH2t0oGS5T+aZk5W/ hyCgiu6UFOeySoCZSgy6NjeR6HOaxNhZjY9MLrfQNQimU+jrOLcXvGzvwB47Q6fT3RsRNN2Iyn s0S0cT1vWhzbwRkqF71ZiJcLm0LYzcj9ESTap6APZIR6TQhDZ4u9BxMhdXL0ZN/t5ybq/7owq2 AeSYNod7d9SwBrcU0ac2w72rCCR04an8iekEeX2npB1KAdvwOgjNanEm/WiHk1yLr1t9gJZdWB J98= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v8 04/52] Input: atmel_mxt_ts - split large i2c transfers into blocks Date: Thu, 19 Mar 2020 07:59:28 -0700 Message-ID: <20200319150016.61398-5-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319150016.61398-1-jiada_wang@mentor.com> References: <20200319150016.61398-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