summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/accelgyro_icm426xx.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/driver/accelgyro_icm426xx.c b/driver/accelgyro_icm426xx.c
index 77867ed722..47558beeed 100644
--- a/driver/accelgyro_icm426xx.c
+++ b/driver/accelgyro_icm426xx.c
@@ -421,11 +421,6 @@ static int icm426xx_set_data_rate(const struct motion_sensor_t *s, int rate,
ret = icm426xx_enable_sensor(s, 0);
data->odr = 0;
return ret;
- } else if (data->odr == 0) {
- /* enable sensor */
- ret = icm426xx_enable_sensor(s, 1);
- if (ret)
- return ret;
}
mutex_lock(s->mutex);
@@ -435,14 +430,19 @@ static int icm426xx_set_data_rate(const struct motion_sensor_t *s, int rate,
if (ret != EC_SUCCESS)
goto out_unlock;
- data->odr = normalized_rate;
-
mutex_unlock(s->mutex);
- /* enable data in FIFO */
- if (IS_ENABLED(CONFIG_ACCEL_FIFO))
- icm426xx_config_fifo(s, 1);
+ if (data->odr == 0) {
+ /* enable sensor */
+ ret = icm426xx_enable_sensor(s, 1);
+ if (ret)
+ return ret;
+ /* enable data in FIFO */
+ if (IS_ENABLED(CONFIG_ACCEL_FIFO))
+ icm426xx_config_fifo(s, 1);
+ }
+ data->odr = normalized_rate;
return EC_SUCCESS;
out_unlock: