From patchwork Tue Jun 7 07:43:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 12871481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DE45C433EF for ; Tue, 7 Jun 2022 07:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236233AbiFGHnS (ORCPT ); Tue, 7 Jun 2022 03:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbiFGHnR (ORCPT ); Tue, 7 Jun 2022 03:43:17 -0400 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 166342E093; Tue, 7 Jun 2022 00:43:17 -0700 (PDT) Date: Tue, 07 Jun 2022 07:43:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1654587793; x=1654846993; bh=D9FtRQsL64UZzeNlDSZGhV3sxAUQRz/jzb9A2KCTcNc=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:Feedback-ID:From:To: Cc:Date:Subject:Reply-To:Feedback-ID:Message-ID; b=i6mTSUcTRPosAWilhmCAwd5mvCKSmf+X6domJ9XNYgWu3XZzkkHWiVAPQ03pqcISA tvSLTTF7a5+Gzy6Tus1NrtlT1gSep4rDK0fETn2N0fjRn6lTsWtnDabdtEGZRZKN6g 0S2tL+Cisllizz5L7QOdUeg4rnan6P/LgWgQuLb6H5Tlnx82IONYb+5d5XXKkZNZ2o Hi82zZiQC3r6/3hsEFJ/3C5s1bKKgMmKKGbBcMGjEZ6ZeblGYJL+0hikwtSRCbTVTZ zqQhMPWsNgvfbK+UBnqDrghDbTOJ/SX9UJvlSeVBs/KjBiAT9HnkgYnhEjzWietluv M5C1LbFSYs61w== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: dmitry.torokhov@gmail.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, rydberg@bitmath.org, zhengyongjun3@huawei.com, linux-input@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, ~postmarketos/upstreaming@lists.sr.ht, andi@etezian.org, stephan@gerhold.net, nikita@trvn.ru Reply-To: "Lin, Meng-Bo" Subject: [RESEND PATCH] input: stmfts: Add #define STMFTS_RETRY_COUNT 3 Message-ID: <20220607074249.21763-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@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 -ETIMEDOUT to failed attempt due to no event received for the 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 c175d44c52f3..730035f5c62c 100644 --- a/drivers/input/touchscreen/stmfts.c +++ b/drivers/input/touchscreen/stmfts.c @@ -68,6 +68,7 @@ #define STMFTS_DATA_MAX_SIZE (STMFTS_EVENT_SIZE * STMFTS_STACK_DEPTH) #define STMFTS_MAX_FINGERS 10 #define STMFTS_DEV_NAME "stmfts" +#define STMFTS_RETRY_COUNT 3 enum stmfts_regulators { STMFTS_REGULATOR_VDD, @@ -317,19 +318,20 @@ static irqreturn_t stmfts_irq_handler(int irq, void *dev) static int stmfts_command(struct stmfts_data *sdata, const u8 cmd) { - int err; + int err, retry; reinit_completion(&sdata->cmd_done); - err = i2c_smbus_write_byte(sdata->client, cmd); - if (err) - return err; - - if (!wait_for_completion_timeout(&sdata->cmd_done, - msecs_to_jiffies(1000))) - return -ETIMEDOUT; + for (retry = 0; retry < STMFTS_RETRY_COUNT; retry++) { + err = i2c_smbus_write_byte(sdata->client, cmd); + if (err) + return err; - return 0; + if (wait_for_completion_timeout(&sdata->cmd_done, + msecs_to_jiffies(1000))) + return 0; + } + return -ETIMEDOUT; } static int stmfts_input_open(struct input_dev *dev)