From 2ce6482fbb48d7d3290bc5c7d5dd4ea632aee1a6 Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Mon, 1 Oct 2018 13:54:25 -0600 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/1257502 Reviewed-by: Furquan Shaikh Reviewed-by: Jett Rink --- driver/accelgyro_lsm6dsm.c | 13 +++++-------- 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 */ -- cgit v1.2.1