summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-09-18 21:55:12 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-21 02:41:28 +0000
commiteca8b44a324c5a89285dbfb6e4258b7036662d72 (patch)
tree8185bebeb19d65a0d7cbd9cbc6033a13b122effe
parentdc414da0a9d1114144e1b3e6d3ab6df88ec0a7ea (diff)
downloadchrome-ec-eca8b44a324c5a89285dbfb6e4258b7036662d72.tar.gz
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 <peress@chromium.org> Change-Id: Iebeafe9c57c71713a1df5230e60ac067209ec5b2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170538 Commit-Queue: Yuval Peress <peress@google.com> Tested-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--driver/accel_lis2dw12.c4
1 files changed, 1 insertions, 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,