All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Michael Hennerich <michael.hennerich@analog.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] input/touchscreen: Fix a missing check on regmap_bulk_read
Date: Wed, 26 Dec 2018 12:08:38 -0800	[thread overview]
Message-ID: <20181226200838.GC5999@dtor-ws> (raw)
In-Reply-To: <20181224183719.22211-1-pakki001@umn.edu>

Hi,

On Mon, Dec 24, 2018 at 12:37:19PM -0600, Aditya Pakki wrote:
> regmap_bulk_read() can return a non zero value on failure. The fix
> checks if the function call succeeded before calling mod_timer.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/input/touchscreen/ad7879.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index 6bad23ee47a1..735cb4c0d913 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -247,11 +247,12 @@ static void ad7879_timer(struct timer_list *t)
>  static irqreturn_t ad7879_irq(int irq, void *handle)
>  {
>  	struct ad7879 *ts = handle;
> +	int ret;
>  
> -	regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
> -			 ts->conversion_data, AD7879_NR_SENSE);
> +	ret = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
> +				ts->conversion_data, AD7879_NR_SENSE);

I'd probably say:

	error = regmap_bulk_read(...);
	if (error)
		dev_err_ratelimited(...);
	else if (!ad7879_report(ts))
		mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);

Were the failures observed in real life or it is some kind of class
project?

>  
> -	if (!ad7879_report(ts))
> +	if (!ret && !ad7879_report(ts))
>  		mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
>  
>  	return IRQ_HANDLED;
> -- 
> 2.17.1
> 

Thanks.

-- 
Dmitry

      reply	other threads:[~2018-12-26 20:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-24 18:37 [PATCH] input/touchscreen: Fix a missing check on regmap_bulk_read Aditya Pakki
2018-12-26 20:08 ` 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=20181226200838.GC5999@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=kjlu@umn.edu \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=pakki001@umn.edu \
    /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.