diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2017-11-13 12:33:24 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-11-17 20:18:30 -0800 |
commit | f587852570770564e8a94b2c3f7ad7d97883c49a (patch) | |
tree | a7d78650875c700c3449268ed05330a11bea5eb6 /driver/accel_lis2dh.c | |
parent | ab2ce0a0ef38a701a9cc6622ccb41ba55d6b4984 (diff) | |
download | chrome-ec-f587852570770564e8a94b2c3f7ad7d97883c49a.tar.gz |
motion_sense: Put set_range in common code
At the end of the sensor initialization, all _init sensor routines set
the range to the default value from board.c file.
Put all the code in a single place, move it from sensor_common.c to
motion_sense.c.
BUG=none
BRANCH=none
TEST=compile
Change-Id: If89cf27c6438e0f215c193d68a480e027110174c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/767610
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/accel_lis2dh.c')
-rw-r--r-- | driver/accel_lis2dh.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c index eadc66cf71..18a0ade444 100644 --- a/driver/accel_lis2dh.c +++ b/driver/accel_lis2dh.c @@ -16,6 +16,7 @@ #include "task.h" #include "util.h" #include "driver/accel_lis2dh.h" +#include "driver/stm_mems_common.h" #ifdef CONFIG_ACCEL_FIFO /** @@ -324,7 +325,7 @@ static int init(const struct motion_sensor_t *s) ret = raw_read8(s->port, s->addr, LIS2DH_WHO_AM_I_REG, &tmp); if (ret != EC_SUCCESS) - return EC_ERROR_UNKNOWN; + return ret; if (tmp != LIS2DH_WHO_AM_I) return EC_ERROR_ACCESS_DENIED; @@ -367,26 +368,22 @@ static int init(const struct motion_sensor_t *s) mutex_unlock(s->mutex); - /* Config initial Acc Range */ - ret = set_range(s, s->default_range, 0); - if (ret != EC_SUCCESS) - return ret; - /* Set default resolution */ data->resol = LIS2DH_RESOLUTION; #ifdef CONFIG_ACCEL_INTERRUPTS ret = config_interrupt(s); + if (ret != EC_SUCCESS) + return ret; #endif - sensor_init_done(s, get_range(s)); - return ret; + return sensor_init_done(s); err_unlock: CPRINTF("[%T %s: MS Init type:0x%X Error]\n", s->name, s->type); mutex_unlock(s->mutex); - return EC_ERROR_UNKNOWN; + return ret; } const struct accelgyro_drv lis2dh_drv = { |