diff options
author | Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> | 2021-02-08 15:27:14 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-25 20:17:48 +0000 |
commit | ba264bb932fcfa46378e68c4276d1db01c577ebf (patch) | |
tree | ae5399ea9187577a192709f29250baf81bcd8efa /driver | |
parent | 96d6fa8423508cb30de9af4066b9a1831712def3 (diff) | |
download | chrome-ec-ba264bb932fcfa46378e68c4276d1db01c577ebf.tar.gz |
driver: icm426xx: update odr before turning sensor on
Prevent to have the first event in 1 ODR and the second in another.
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>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/accelgyro_icm426xx.c | 20 |
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: |