Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2130455rwb; Thu, 17 Nov 2022 07:00:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kCaKw/Wp5Td6JS0CAO+Itc2OmMCt+jj6iq57+ScrXoKZCpw0qggCU78IJQAYZhDOfvL+/ X-Received: by 2002:a17:906:2e83:b0:78d:b3f0:b5c0 with SMTP id o3-20020a1709062e8300b0078db3f0b5c0mr2529134eji.141.1668697214244; Thu, 17 Nov 2022 07:00:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668697214; cv=none; d=google.com; s=arc-20160816; b=N7eTqNegVSLvPtAWRxW9G+OtS/OPS15K7SS+dkEQk5JQXnLt9smFGevA1eOuCe2uzs 0zgTcoSfs7mIqtzGplx77B9DWEA4HtumTdz9R5a7BJYZovtCkXko18INWQ63g7bx+/0s 5y/QS6Nyc8l8QgnK4KDdOpFZoRiwcrg/gS0eseVCD3pzO/aE38lLasttsEmkxaV1vgNz p/AmpmLDbMd3L6lI8W9qIci8NT+PMRRWZLhoF9STNFAyvbIdfPNiHHj8I2f/zArC63y6 lq8+ncm1lpte09KHYn+cWKnRQxPNFbi0SLsE6iKICdcxdP40U6zOk9fAVL0Wr/Hl/Ik8 /Ptw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:message-id:subject:cc:from:to:dkim-signature:date; bh=h8QUQMuBeId16fwT8sIh6ZqutzDewiMZtFIp21P7mOY=; b=z0Si6ZLn14E8uhDY6A3vd867iwvQnz4QToctj82R1L0fPqxn73fVxeNxE6pQgr8xZ7 +wHsJa658DGZctp3pkMmIWOJarHrjIbEt+fB0GZkzZSVd7oQbvMVbHqjOzId2ypuMEOh f50VYd82nDOLRnBf98kKGahTeoWKEGLg3fWVsx4zjJprUQZibRwIJZH6DiuWx7IGKsRd jd2XbGJVlxjuLjpsy214MUIixn0D58WqdRyL79lYk/Q4YLp6Gqbn5zXIxFKKlDALNwCJ hufk1paKMnAFpHLhylsNRaVtrkT+j6nL4LYdGYG2Ta7BGSnDvYDcnhf1bxwsGBB9TkCB dvcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=cLYLHTMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a1709062ecc00b0078c47b4478esi578412eji.106.2022.11.17.06.59.51; Thu, 17 Nov 2022 07:00:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=cLYLHTMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239483AbiKQO2v (ORCPT + 92 others); Thu, 17 Nov 2022 09:28:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240352AbiKQO2o (ORCPT ); Thu, 17 Nov 2022 09:28:44 -0500 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 293951261B for ; Thu, 17 Nov 2022 06:28:42 -0800 (PST) Date: Thu, 17 Nov 2022 14:28:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1668695315; x=1668954515; bh=h8QUQMuBeId16fwT8sIh6ZqutzDewiMZtFIp21P7mOY=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=cLYLHTMvI4pQQtyVvzPKzaE42SZoN0qoVPQeQLANiJ77ipklFCAlKAu9C2fUV9eQn B+dBlatkXMTkQhcJxLeUiX5os+iXkuE6Dny9XEf+idfQzdHupDpmBG/f6/MHmuA7Lr XEd9hN5wfk4hjQEfPv1xyMlEAh3lnNglucGJ2Xdk43Vwhsz2JpZFKojtMoU4tDd1lf YP3z2yogAUeXhmE3lTxsdYliSWbIy5uNXp1g7nrsotbj8VmDvtOGHEq5ekFX3m6LdO i1eJuzY10Jz64eFubqo79KYtQfTU/717jpWZI7ABXH9twBqmoSps8Uow3PsOpbOHes aCVnYVrwm/oQw== To: linux-input@vger.kernel.org From: "Lin, Meng-Bo" Cc: Dmitry Torokhov , Maxime Coquelin , Alexandre Torgue , Corey Minyard , Srinivas Pandruvada , Benjamin Mugnier , Greg Kroah-Hartman , Zheng Yongjun , =?utf-8?Q?Uwe_Kleine-K=C3=B6nig?= , Stephan Gerhold , Nikita Travkin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH] Input: stmfts - retry commands after timeout Message-ID: <20221117142753.2477-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add #define STMFTS_RETRY_COUNT 3 to retry stmfts_command() 3 times. Without it, STMFTS_SYSTEM_RESET or STMFTS_SLEEP_OUT may return -110 to failed attempt due to no event received for completion. Signed-off-by: Lin, Meng-Bo --- drivers/input/touchscreen/stmfts.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen= /stmfts.c index d5bd170808fb..22de34966373 100644 --- a/drivers/input/touchscreen/stmfts.c +++ b/drivers/input/touchscreen/stmfts.c @@ -68,6 +68,7 @@ #define STMFTS_DATA_MAX_SIZE=09(STMFTS_EVENT_SIZE * STMFTS_STACK_DEPTH) #define STMFTS_MAX_FINGERS=0910 #define STMFTS_DEV_NAME=09=09"stmfts" +#define STMFTS_RETRY_COUNT=093 =20 enum stmfts_regulators { =09STMFTS_REGULATOR_VDD, @@ -317,19 +318,20 @@ static irqreturn_t stmfts_irq_handler(int irq, void *= dev) =20 static int stmfts_command(struct stmfts_data *sdata, const u8 cmd) { -=09int err; +=09int err, retry; =20 =09reinit_completion(&sdata->cmd_done); =20 -=09err =3D i2c_smbus_write_byte(sdata->client, cmd); -=09if (err) -=09=09return err; - -=09if (!wait_for_completion_timeout(&sdata->cmd_done, -=09=09=09=09=09 msecs_to_jiffies(1000))) -=09=09return -ETIMEDOUT; +=09for (retry =3D 0; retry < STMFTS_RETRY_COUNT; retry++) { +=09=09err =3D i2c_smbus_write_byte(sdata->client, cmd); +=09=09if (err) +=09=09=09return err; =20 -=09return 0; +=09=09if (wait_for_completion_timeout(&sdata->cmd_done, +=09=09=09=09=09=09msecs_to_jiffies(1000))) +=09=09=09return 0; +=09} +=09return -ETIMEDOUT; } =20 static int stmfts_input_open(struct input_dev *dev) --=20 2.30.2