Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp591509pxk; Thu, 3 Sep 2020 07:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYbSYsPhTQs7jg30rgkrJChMFma/D5FENWzLAvX3DDZPDpBpw0Lg7ffpPBlPPhj9nXIXrZ X-Received: by 2002:aa7:dcd2:: with SMTP id w18mr3522129edu.288.1599144368395; Thu, 03 Sep 2020 07:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599144368; cv=none; d=google.com; s=arc-20160816; b=G0ezxQO0gCYvNQzTdz7USHbZDZplomQO3hSOzkvUABAASY/Ox8nNYR+0v24KQvyTau GbgjglV0KKWNrIZplcOxZJPNoDx6ZO77F5LXOxTIJkuN5IJvK3C6uu7pLE8enCIPSIaG EH4bKFcYCR4v4KQOU2pmDxC5vXf0UKDjzwc+vcbn9Ohn4oE/uq2sjpWEy106rhFF74i0 09LkspD/HYTPL4zALPBxQkOohD910HEFqLRSF1PR07yRwTR4TY5a4cI67DMqTMUuh+yg X1jXITvmYx38kQQekNX3oEkZoGXgFXttbVBvAhYDt6q5pYXpcuC/pW3yvZQZrvLFPzs5 8ALw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=pVk21ds77qyhldbyY39YUHM0Dex6zET30jWOLRIgWMY=; b=BvLdA3qv22ayfHygMxBYzJM4BdsuJXiWFcq3Mk9grrfBAMB5KmpkzTS38LCg837F3K jnjFU4LkXnh+0xblWEjzLb6xPSiHwHrJgiSgU9IMM33KHiwsFXMcEy0AUqbPqvHPlrWq nGmhXAKh/HHCnJwl5hwMyOxT8oG8r+RzAqtjLomk7e3ItMVho3XogrcpYGr0ZX1U16uH im2VRdF1B2cuCmEbJGvcDNSf8JvSGkVR7uwZ8S7k/EFsTA/AQ3fZpLttIoU2ei2uEv9I 5LsxMlrX0iOC+bSOWrKbHEzkx9klSWyUPSVME55WdOcoLcBMDztZlQt7OAq8RZzsz7Qw Fvdw== 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 l14si2012534ejz.622.2020.09.03.07.45.44; Thu, 03 Sep 2020 07:46:08 -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 S1729372AbgICOo7 (ORCPT + 99 others); Thu, 3 Sep 2020 10:44:59 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:28704 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728918AbgICOoh (ORCPT ); Thu, 3 Sep 2020 10:44:37 -0400 IronPort-SDR: nkWVAQKqUCXjXdJVF0KOn7X/P8AH4A4+9wI69zWZU3zIGWV2djriaGGB0WigwaZqbiCLCE7dFL XP+9lmAashYfp4IYGIWQM0YFqSb8T5YfbDx/HxOkAc7p91myExBIjyf67GfCpM/Nwe9g0jI9s4 d9EOGdlvTuy0EhALv78khIxewiGgYsgt7HB5ep7XnErOEVNbBRNWLsHPgaJF0ZE3w9iuf89WSd SuRxstOlvEPNeLdn7J0LEtGXWPV6OgGP96xeGQud1OlwLP9A3q+fGA2vj4qhyh8VIFPBckKpwi 1U0= X-IronPort-AV: E=Sophos;i="5.76,387,1592899200"; d="scan'208";a="54728480" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 03 Sep 2020 06:44:30 -0800 IronPort-SDR: Mgmi2Sj3+nlxK/9a28nix/exYFJLpu41rF0jAUMoQX66CtMvBMjTmsnuGDZIH9HRErM/sP7K7+ VNrT6TbfxCSjcs1cAPcnfdJIdiJgb7dYpNvV7RUKcW15t+QmT17xWc6bog6HJK2tvx8V3fAnpD i0JiUYuqpIp9gdxK4puu4tq9wMkN+tD1rW7qR7imz/74ynJGTDlG2Bg3YJ0LXVHHrnHKtVS2rL nGDp3E4LRGP12zUXOG/9ySxhvGBn6etQMM2KZrb1s1+xI9o43Khe/06Dpzll8tZ+pn9v3rGBsg pV4= Subject: Re: [PATCH 1/1] Input: atmel_mxt_ts - implement I2C retries To: Dmitry Osipenko , , CC: , , , References: <20200821082254.16661-1-jiada_wang@mentor.com> <64c77ff9-6d20-abcf-f549-7d5c85fba28d@gmail.com> From: "Wang, Jiada" Message-ID: <2c8ed5c8-f95b-dce4-f964-ac16f12c3f20@mentor.com> Date: Thu, 3 Sep 2020 23:44:21 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <64c77ff9-6d20-abcf-f549-7d5c85fba28d@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SVR-ORW-MBX-07.mgc.mentorg.com (147.34.90.207) To svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry On 2020/08/28 17:19, Dmitry Osipenko wrote: > 21.08.2020 11:22, Jiada Wang пишет: >> From: Nick Dyer >> >> Some maXTouch chips (eg mXT1386) will not respond on the first I2C request >> when they are in a sleep state. It must be retried after a delay for the >> chip to wake up. >> >> Signed-off-by: Nick Dyer >> Acked-by: Yufeng Shen >> (cherry picked from ndyer/linux/for-upstream commit 63fd7a2cd03c3a572a5db39c52f4856819e1835d) >> [gdavis: Forward port and fix conflicts.] >> Signed-off-by: George G. Davis >> Signed-off-by: Jiada Wang >> --- >> drivers/input/touchscreen/atmel_mxt_ts.c | 45 ++++++++++++++++-------- >> 1 file changed, 30 insertions(+), 15 deletions(-) > > Hello, Jiada! > > I tested this patch on Acer A500 that has mXT1386 controller which > requires the I2C retrying and everything working good, no problems > spotted! Touchscreen doesn't work without this patch! > > Tested-by: Dmitry Osipenko > > I have one minor comment, please see it below! > >> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c >> index a2189739e30f..e93eda1f3d59 100644 >> --- a/drivers/input/touchscreen/atmel_mxt_ts.c >> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c >> @@ -196,6 +196,7 @@ enum t100_type { >> #define MXT_CRC_TIMEOUT 1000 /* msec */ >> #define MXT_FW_RESET_TIME 3000 /* msec */ >> #define MXT_FW_CHG_TIMEOUT 300 /* msec */ >> +#define MXT_WAKEUP_TIME 25 /* msec */ >> >> /* Command to unlock bootloader */ >> #define MXT_UNLOCK_CMD_MSB 0xaa >> @@ -626,6 +627,7 @@ static int __mxt_read_reg(struct i2c_client *client, >> struct i2c_msg xfer[2]; >> u8 buf[2]; >> int ret; >> + bool retry = false; >> >> buf[0] = reg & 0xff; >> buf[1] = (reg >> 8) & 0xff; >> @@ -642,17 +644,22 @@ static int __mxt_read_reg(struct i2c_client *client, >> xfer[1].len = len; >> xfer[1].buf = val; >> >> - ret = i2c_transfer(client->adapter, xfer, 2); >> - if (ret == 2) { >> - ret = 0; >> - } else { >> - if (ret >= 0) >> - ret = -EIO; >> - dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", >> - __func__, ret); >> +retry_read: >> + ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer)); >> + if (ret != ARRAY_SIZE(xfer)) { > > Is it really possible to get a positive ret != 2 from i2c_transfer()? > > Maybe it's better to keep the old code behaviour by returning the "ret" > value directly if it's not equal to ARRAY_SIZE(xfer)? > I think, theoretically i2c_transfer() may return positive value but != number to transfer, original behavior is, when ret >= 0, it returns -EIO, when ret < 0, it just returns ret, current behavior is, when ret != 2, it returns -EIO, after retry. I am OK to change the behavior exactly as same original one. Thanks, Jiada