diff options
author | Karthikeyan Ramasubramanian <kramasub@chromium.org> | 2018-10-01 13:54:25 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-19 15:07:39 -0700 |
commit | 2ce6482fbb48d7d3290bc5c7d5dd4ea632aee1a6 (patch) | |
tree | c5d01262a87c2d66dcf71e1f9020e8c8ceae6d18 | |
parent | dce4ff12eca8176b0abab7873048147d26156548 (diff) | |
download | chrome-ec-2ce6482fbb48d7d3290bc5c7d5dd4ea632aee1a6.tar.gz |
driver/accelgryo_lsm6dsm: Export accelgyro_config_fifo helper function
Rename config_fifo function as accelgyro_config_fifo and export it to
configure the accelerometer FIFO to support magmetometer data. Also remove
a redundant else code by initializing the local variables appropriately.
BRANCH=none
BUG=b:115587004
TEST=none
Change-Id: I6f35245b45941adaafd49cc0e26e1f9307c480c2
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1257502
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | driver/accelgyro_lsm6dsm.c | 13 | ||||
-rw-r--r-- | driver/accelgyro_lsm6dsm.h | 4 |
2 files changed, 9 insertions, 8 deletions
diff --git a/driver/accelgyro_lsm6dsm.c b/driver/accelgyro_lsm6dsm.c index c4afa2a5e6..7a445dc0c7 100644 --- a/driver/accelgyro_lsm6dsm.c +++ b/driver/accelgyro_lsm6dsm.c @@ -277,9 +277,9 @@ static int load_fifo(struct motion_sensor_t *s, const struct fstatus *fsts) } /** - * config_fifo - update mode and ODR for FIFO decimator + * accelgyro_config_fifo - update mode and ODR for FIFO decimator */ -static int config_fifo(const struct motion_sensor_t *accel) +int accelgyro_config_fifo(const struct motion_sensor_t *accel) { int err; @@ -425,7 +425,7 @@ static int get_range(const struct motion_sensor_t *s) */ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) { - int ret, normalized_rate; + int ret, normalized_rate = 0; /* * Since 'stprivate_data a_data;' is the first member of lsm6dsm_data, * the address of lsm6dsm_data is the same as a_data's. Using this @@ -435,7 +435,7 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) * struct stprivate_data *data = &lsm_data->a_data; */ struct stprivate_data *data = s->drv_data; - uint8_t ctrl_reg, reg_val; + uint8_t ctrl_reg, reg_val = 0; ctrl_reg = LSM6DSM_ODR_REG(s->type); if (rate > 0) { @@ -450,9 +450,6 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) normalized_rate > MIN(LSM6DSM_ODR_MAX_VAL, CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ)) return EC_RES_INVALID_PARAM; - } else { - reg_val = 0; - normalized_rate = 0; } mutex_lock(s->mutex); @@ -460,7 +457,7 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) if (ret == EC_SUCCESS) { data->base.odr = normalized_rate; #ifdef CONFIG_ACCEL_FIFO - config_fifo(LSM6DSM_MAIN_SENSOR(s)); + accelgyro_config_fifo(LSM6DSM_MAIN_SENSOR(s)); #endif } diff --git a/driver/accelgyro_lsm6dsm.h b/driver/accelgyro_lsm6dsm.h index cc4b2eafc6..a85b460c33 100644 --- a/driver/accelgyro_lsm6dsm.h +++ b/driver/accelgyro_lsm6dsm.h @@ -242,4 +242,8 @@ struct lsm6dsm_data { #define LSM6DSM_MAIN_SENSOR(_s) ((_s) - (_s)->type) +#ifdef CONFIG_ACCEL_FIFO +int accelgyro_config_fifo(const struct motion_sensor_t *accel); +#endif /* CONFIG_ACCEL_FIFO */ + #endif /* __CROS_EC_ACCELGYRO_LSM6DSM_H */ |