Linux-IIO Archive on lore.kernel.org
 help / Atom feed
* [PATCH] iio: chemical: sps30: fix a loop timeout test
@ 2019-02-09  9:03 Dan Carpenter
  2019-02-09 16:41 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-02-09  9:03 UTC (permalink / raw)
  To: Jonathan Cameron, Tomasz Duszynski
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, kernel-janitors

The "while (tries--) {" loop is a postop so it exits with "tries" set
to -1.

Fixes: 232e0f6ddeae ("iio: chemical: add support for Sensirion SPS30 sensor")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/iio/chemical/sps30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c
index e03a28a67146..375df5060ed5 100644
--- a/drivers/iio/chemical/sps30.c
+++ b/drivers/iio/chemical/sps30.c
@@ -210,7 +210,7 @@ static int sps30_do_meas(struct sps30_state *state, s32 *data, int size)
 		msleep_interruptible(300);
 	}
 
-	if (!tries)
+	if (tries == -1)
 		return -ETIMEDOUT;
 
 	ret = sps30_do_cmd(state, SPS30_READ_DATA, tmp, sizeof(int) * size);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: chemical: sps30: fix a loop timeout test
  2019-02-09  9:03 [PATCH] iio: chemical: sps30: fix a loop timeout test Dan Carpenter
@ 2019-02-09 16:41 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-02-09 16:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tomasz Duszynski, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-iio, kernel-janitors

On Sat, 9 Feb 2019 12:03:52 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The "while (tries--) {" loop is a postop so it exits with "tries" set
> to -1.
> 
> Fixes: 232e0f6ddeae ("iio: chemical: add support for Sensirion SPS30 sensor")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks.

Applied to the togreg branch of iio.git.  Should make it in before
the merge window so no need for stable etc.

thanks,

Jonathan
> ---
>  drivers/iio/chemical/sps30.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c
> index e03a28a67146..375df5060ed5 100644
> --- a/drivers/iio/chemical/sps30.c
> +++ b/drivers/iio/chemical/sps30.c
> @@ -210,7 +210,7 @@ static int sps30_do_meas(struct sps30_state *state, s32 *data, int size)
>  		msleep_interruptible(300);
>  	}
>  
> -	if (!tries)
> +	if (tries == -1)
>  		return -ETIMEDOUT;
>  
>  	ret = sps30_do_cmd(state, SPS30_READ_DATA, tmp, sizeof(int) * size);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09  9:03 [PATCH] iio: chemical: sps30: fix a loop timeout test Dan Carpenter
2019-02-09 16:41 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox