* [RESEND PATCH] input: stmfts: Add #define STMFTS_RETRY_COUNT 3
@ 2022-06-07 7:43 ` Lin, Meng-Bo
0 siblings, 0 replies; 2+ messages in thread
From: Lin, Meng-Bo @ 2022-06-07 7:43 UTC (permalink / raw)
To: linux-kernel
Cc: dmitry.torokhov, mcoquelin.stm32, alexandre.torgue, rydberg,
zhengyongjun3, linux-input, linux-stm32, linux-arm-kernel,
~postmarketos/upstreaming, andi, stephan, nikita
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 <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 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)
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [RESEND PATCH] input: stmfts: Add #define STMFTS_RETRY_COUNT 3
@ 2022-06-07 7:43 ` Lin, Meng-Bo
0 siblings, 0 replies; 2+ messages in thread
From: Lin, Meng-Bo @ 2022-06-07 7:43 UTC (permalink / raw)
To: linux-kernel
Cc: dmitry.torokhov, mcoquelin.stm32, alexandre.torgue, rydberg,
zhengyongjun3, linux-input, linux-stm32, linux-arm-kernel,
~postmarketos/upstreaming, andi, stephan, nikita
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 <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 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)
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-07 7:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07 7:43 [RESEND PATCH] input: stmfts: Add #define STMFTS_RETRY_COUNT 3 Lin, Meng-Bo
2022-06-07 7:43 ` Lin, Meng-Bo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.