All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Li Zhong <floridsleeves@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH v1] touchscreen/88pm860x-ts: check the pm860x_set_bits return value
Date: Wed, 21 Sep 2022 15:47:25 -0700	[thread overview]
Message-ID: <YyuUfZ7sDlwuvZsk@google.com> (raw)
In-Reply-To: <20220921203706.1635298-1-floridsleeves@gmail.com>

Hi,

On Wed, Sep 21, 2022 at 01:37:06PM -0700, Li Zhong wrote:
> pm860x_touch_close() got the return value of pm860x_set_bits() but
> didn't check it. However, pm860x_set_bits() could fail when writing the
> reg map fails.

Under what conditions would the write fail?

> Since pm860x_touch_close() cannot return an error value,
> we retry the bit setting in the error handling.

What guarantees that the repeated write will not fail again? What is the
failure mode if write does not succeed?


> 
> Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> ---
>  drivers/input/touchscreen/88pm860x-ts.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
> index 81a3ea4b9a3d..043520d1ff26 100644
> --- a/drivers/input/touchscreen/88pm860x-ts.c
> +++ b/drivers/input/touchscreen/88pm860x-ts.c
> @@ -106,10 +106,13 @@ static void pm860x_touch_close(struct input_dev *dev)
>  {
>  	struct pm860x_touch *touch = input_get_drvdata(dev);
>  	int data;
> +	int ret;
>  
>  	data = MEAS_PD_EN | MEAS_TSIX_EN | MEAS_TSIY_EN
>  		| MEAS_TSIZ1_EN | MEAS_TSIZ2_EN;
> -	pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
> +	ret = pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
> +	if (ret < 0)
> +		pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
>  }
>  
>  #ifdef CONFIG_OF
> -- 
> 2.25.1
> 

Thanks.

-- 
Dmitry

      reply	other threads:[~2022-09-21 22:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 20:37 [PATCH v1] touchscreen/88pm860x-ts: check the pm860x_set_bits return value Li Zhong
2022-09-21 22:47 ` Dmitry Torokhov [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=YyuUfZ7sDlwuvZsk@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=floridsleeves@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /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 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.