Skip to contentSkip to conversation

iio: chemical: sps30: fix a loop timeout test

PATCH Applied Dan Carpenter 2 participants 2 messages Feb 9, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: chemical: sps30: fix a loop timeout test

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")
---
 drivers/iio/chemical/sps30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sps30.c +1 -1
index e03a28a67146..375df5060ed5 100644
@@ -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);
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 5 lines · On Sat, 9 Feb 2019 12:03:52 +0300 Dan Carpenter <[email protected]>…

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

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

Quoted 17 lines
---
 drivers/iio/chemical/sps30.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sps30.c +1 -1
index e03a28a67146..375df5060ed5 100644
@@ -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);