From: "Lin, Meng-Bo" <linmengbo0689@protonmail.com>
To: linux-input@vger.kernel.org
Cc: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Corey Minyard" <cminyard@mvista.com>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Zheng Yongjun" <zhengyongjun3@huawei.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Stephan Gerhold" <stephan@gerhold.net>,
"Nikita Travkin" <nikita@trvn.ru>,
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
Date: Thu, 17 Nov 2022 14:28:20 +0000 [thread overview]
Message-ID: <20221117142753.2477-1-linmengbo0689@protonmail.com> (raw)
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 <linmengbo0689@protonmail.com>
---
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 (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)
--
2.30.2
next reply other threads:[~2022-11-17 14:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 14:28 Lin, Meng-Bo [this message]
2022-11-28 13:51 ` [PATCH] Input: stmfts - retry commands after timeout Mattijs Korpershoek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221117142753.2477-1-linmengbo0689@protonmail.com \
--to=linmengbo0689@protonmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=benjamin.mugnier@foss.st.com \
--cc=cminyard@mvista.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=nikita@trvn.ru \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=stephan@gerhold.net \
--cc=u.kleine-koenig@pengutronix.de \
--cc=zhengyongjun3@huawei.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).