[PATCH v5 3/5] iio:temperature:mlx90632: Convert polling while loop to do-while

Crt Mori
2020-08-13T07:53:36Z

Reduce number of lines and improve readability to convert polling while
loops to do-while. The iopoll.h interface was not used, because we
require more than 20ms timeout, because time for sensor to perform a
measurement is around 10ms and it needs to perform measurements for each
channel (which currently is 3).

Signed-off-by: Crt Mori <cmo@melexis.com>
---
drivers/iio/temperature/mlx90632.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
index ce75f5a3486b..d87c792b7e72 100644
--- a/drivers/iio/temperature/mlx90632.c
+++ b/drivers/iio/temperature/mlx90632.c
@@ -188,15 +188,13 @@ static int mlx90632_perform_measurement(struct mlx90632_data *data)
if (ret < 0)
return ret;

- while (tries-- > 0) {
+ do {
ret = regmap_read(data->regmap, MLX90632_REG_STATUS,
&reg_status);
if (ret < 0)
return ret;
- if (reg_status & MLX90632_STAT_DATA_RDY)
- break;
usleep_range(10000, 11000);
- }
+ } while (!(reg_status & MLX90632_STAT_DATA_RDY) && tries--);

if (tries < 0) {
dev_err(&data->client->dev, "data not ready");
--
2.25.1