diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2020-10-20 23:45:19 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-06 01:43:28 +0000 |
commit | 2d900dc16b610703296803e438a8728036c06ea4 (patch) | |
tree | 69e1376917da6922f80616d49f5fc1250d87caac /driver/accelgyro_bmi_common.c | |
parent | bf3190f8ed0eb50473f1c00a2ccd172c12367500 (diff) | |
download | chrome-ec-2d900dc16b610703296803e438a8728036c06ea4.tar.gz |
driver: bmi260: Use IS_ENABLED()
Add IS_ENABLED() instead of #ifdef when possible in bmi260 and
bmi_common.
BUG=chromium:1140877
BRANCH=none
TEST=buildall
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Change-Id: If8e36ed2a527e8a4ac9582a7b30fe7f7ff589a30
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2489461
Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
Diffstat (limited to 'driver/accelgyro_bmi_common.c')
-rw-r--r-- | driver/accelgyro_bmi_common.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/driver/accelgyro_bmi_common.c b/driver/accelgyro_bmi_common.c index ce2e836234..75447d54f8 100644 --- a/driver/accelgyro_bmi_common.c +++ b/driver/accelgyro_bmi_common.c @@ -12,6 +12,8 @@ #include "accelgyro.h" #include "console.h" #include "driver/accelgyro_bmi_common.h" +#include "driver/mag_bmm150.h" +#include "driver/mag_lis2mdl.h" #include "i2c.h" #include "math_util.h" #include "motion_sense_fifo.h" @@ -141,7 +143,7 @@ int bmi_get_engineering_val(const int reg_val, } #ifdef CONFIG_SPI_ACCEL_PORT -int bmi_spi_raw_read(const int addr, const uint8_t reg, +static int bmi_spi_raw_read(const int addr, const uint8_t reg, uint8_t *data, const int len) { uint8_t cmd = 0x80 | reg; @@ -319,17 +321,13 @@ void bmi_normalize(const struct motion_sensor_t *s, intv3_t v, uint8_t *input) int i; struct accelgyro_saved_data_t *data = BMI_GET_SAVED_DATA(s); -#ifdef CONFIG_MAG_BMI_BMM150 - if (s->type == MOTIONSENSE_TYPE_MAG) + if (IS_ENABLED(CONFIG_MAG_BMI_BMM150) && + (s->type == MOTIONSENSE_TYPE_MAG)) { bmm150_normalize(s, v, input); - else -#endif -#ifdef CONFIG_MAG_BMI_LIS2MDL - if (s->type == MOTIONSENSE_TYPE_MAG) - lis2mdl_normalize(s, v, data); - else -#endif - { + } else if (IS_ENABLED(CONFIG_MAG_BMI_LIS2MDL) && + (s->type == MOTIONSENSE_TYPE_MAG)) { + lis2mdl_normalize(s, v, input); + } else { v[0] = ((int16_t)((input[1] << 8) | input[0])); v[1] = ((int16_t)((input[3] << 8) | input[2])); v[2] = ((int16_t)((input[5] << 8) | input[4])); |