From eca8b44a324c5a89285dbfb6e4258b7036662d72 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Sat, 18 Sep 2021 21:55:12 -0600 Subject: driver: lis2dw12: fix init timeout loop condition The loop condition for the soft reset was incorrect, on a failure to read the soft reset register, the loop would hit the `continue` command which would then test (status & LIS2DW12_SOFT_RESET_MASK) != 0 and leave us at the mercy of the status value left on the stack. BRANCH=none BUG=b:200046770 TEST=zmake configure --test zephyr/projects/drivers Signed-off-by: Yuval Peress Change-Id: Iebeafe9c57c71713a1df5230e60ac067209ec5b2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170538 Commit-Queue: Yuval Peress Tested-by: Yuval Peress Reviewed-by: Jeremy Bettis Reviewed-by: Jack Rosenthal --- driver/accel_lis2dw12.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/driver/accel_lis2dw12.c b/driver/accel_lis2dw12.c index 9d7bfa4c0c..1872e572f2 100644 --- a/driver/accel_lis2dw12.c +++ b/driver/accel_lis2dw12.c @@ -541,9 +541,7 @@ static int init(struct motion_sensor_t *s) timeout += 1; ret = st_raw_read8(s->port, s->i2c_spi_addr_flags, LIS2DW12_SOFT_RESET_ADDR, &status); - if (ret != EC_SUCCESS) - continue; - } while ((status & LIS2DW12_SOFT_RESET_MASK) != 0); + } while (ret != EC_SUCCESS || (status & LIS2DW12_SOFT_RESET_MASK) != 0); /* Enable BDU. */ ret = st_write_data_with_mask(s, LIS2DW12_BDU_ADDR, LIS2DW12_BDU_MASK, -- cgit v1.2.1