linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: "Lin, Meng-Bo" <linmengbo0689@protonmail.com>,
	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: Re: [PATCH] Input: stmfts - retry commands after timeout
Date: Mon, 28 Nov 2022 14:51:09 +0100	[thread overview]
Message-ID: <87wn7frxv6.fsf@baylibre.com> (raw)
In-Reply-To: <20221117142753.2477-1-linmengbo0689@protonmail.com>

On Thu, Nov 17, 2022 at 14:28, "Lin, Meng-Bo" <linmengbo0689@protonmail.com> wrote:

> 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>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2022-11-28 13:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 14:28 [PATCH] Input: stmfts - retry commands after timeout Lin, Meng-Bo
2022-11-28 13:51 ` Mattijs Korpershoek [this message]

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=87wn7frxv6.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.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=linmengbo0689@protonmail.com \
    --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).