diff options
author | Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> | 2021-02-08 15:27:14 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-27 05:29:26 +0000 |
commit | 281402b2ae9bb5c3537e66e470cbe5849eee13e9 (patch) | |
tree | b995359ab5dcc03c0a95d46fd79dc27b19d3c633 | |
parent | c5481deaaec93eee79de7ac7af2e2f2353cacdbf (diff) | |
download | chrome-ec-281402b2ae9bb5c3537e66e470cbe5849eee13e9.tar.gz |
driver: icm426xx: update odr before turning sensor on
Prevent to have the first event in 1 ODR and the second in another.
Conflicts:
driver/accelgyro_icm426xx.c: IS_ENABLED is not in this branch.
BUG=chromium:1175757
BRANCH=hatch,nami,kukui,dedede,grunt,zork,octopus,volteer
TEST=turn sensor on/off and change odr using cros-ec iio devices
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Change-Id: I501bf14e70fd7180c7e68385ef4afb5934d7d37a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2679699
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
(cherry picked from commit ba264bb932fcfa46378e68c4276d1db01c577ebf)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3128754
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r-- | driver/accelgyro_icm426xx.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/driver/accelgyro_icm426xx.c b/driver/accelgyro_icm426xx.c index 68e2be5811..409916d42f 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,15 +430,20 @@ 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); + if (data->odr == 0) { + /* enable sensor */ + ret = icm426xx_enable_sensor(s, 1); + if (ret) + return ret; #ifdef CONFIG_ACCEL_FIFO - /* enable data in FIFO */ - icm426xx_config_fifo(s, 1); + /* enable data in FIFO */ + icm426xx_config_fifo(s, 1); #endif /* CONFIG_ACCEL_FIFO */ + } + data->odr = normalized_rate; return EC_SUCCESS; out_unlock: |