From 0773847d80c8821da2b277c6e007b6948eb350aa Mon Sep 17 00:00:00 2001 From: Tomasz Michalec Date: Wed, 14 Jul 2021 00:44:44 +0200 Subject: driver: bmi160: bmi260: Minor driver fixes Fix three issues with BMI160 and BMI260 drivers: - get/set acclerometer/gyroscope offset will return error on failed read of offset register - BMI160 calibration function returns error when setting range fail - Invalid temperature is properly recognized by driver BUG=none BRANCH=none TEST=run zmake drivers test Signed-off-by: Tomasz Michalec Change-Id: I545c0a931227ef7efc000ec97c1f6297a48e6d1a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3027039 Reviewed-by: Simon Glass Reviewed-by: Jeremy Bettis Reviewed-by: Keith Short --- driver/accelgyro_bmi160.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'driver/accelgyro_bmi160.c') diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index daa47965d8..66dffc0db5 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -211,13 +211,19 @@ static int set_offset(const struct motion_sensor_t *s, switch (s->type) { case MOTIONSENSE_TYPE_ACCEL: - bmi_set_accel_offset(s, v); + ret = bmi_set_accel_offset(s, v); + if (ret != EC_SUCCESS) + return ret; + ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_OFFSET_EN_GYR98, val98 | BMI160_OFFSET_ACC_EN); break; case MOTIONSENSE_TYPE_GYRO: - bmi_set_gyro_offset(s, v, &val98); + ret = bmi_set_gyro_offset(s, v, &val98); + if (ret != EC_SUCCESS) + return ret; + ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_OFFSET_EN_GYR98, val98 | BMI160_OFFSET_GYRO_EN); @@ -246,7 +252,9 @@ static int perform_calib(struct motion_sensor_t *s, int enable) * Temporary set frequency to 100Hz to get enough data in a short * period of time. */ - set_data_rate(s, 100000, 0); + ret = set_data_rate(s, 100000, 0); + if (ret != EC_SUCCESS) + goto end_perform_calib; switch (s->type) { case MOTIONSENSE_TYPE_ACCEL: -- cgit v1.2.1