From bad10174f5e453d69c1c6a4d7921d420da104576 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 6 Jun 2018 11:16:38 +0200 Subject: [PATCH] drivers/lsm6dsl: adapt the i2c api return codes --- drivers/lsm6dsl/lsm6dsl.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/lsm6dsl/lsm6dsl.c b/drivers/lsm6dsl/lsm6dsl.c index adb4f05dad..b81cbbde92 100644 --- a/drivers/lsm6dsl/lsm6dsl.c +++ b/drivers/lsm6dsl/lsm6dsl.c @@ -62,7 +62,7 @@ int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params) xtimer_usleep(LSM6DSL_BOOT_WAIT); - if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_WHO_AM_I, &tmp, 0) != 1) { + if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_WHO_AM_I, &tmp, 0) < 0) { i2c_release(BUS); DEBUG("[ERROR] lsm6dsl_init: i2c_read_reg LSM6DSL_REG_WHO_AM_I!\n"); return -LSM6DSL_ERROR_BUS; @@ -92,7 +92,7 @@ int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params) i2c_release(BUS); - if (res < 4) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_init: config\n"); return -LSM6DSL_ERROR_CNF; } @@ -122,7 +122,7 @@ int lsm6dsl_read_acc(const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data) data->z |= tmp << 8; i2c_release(BUS); - if (res < 6) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_read_acc\n"); return -LSM6DSL_ERROR_BUS; } @@ -158,7 +158,7 @@ int lsm6dsl_read_gyro(const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data) data->z |= tmp << 8; i2c_release(BUS); - if (res < 6) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_read_gyro\n"); return -LSM6DSL_ERROR_BUS; } @@ -177,12 +177,12 @@ int lsm6dsl_read_temp(const lsm6dsl_t *dev, int16_t *data) uint16_t traw; /* read raw temperature */ i2c_acquire(BUS); - if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_OUT_TEMP_L, &tmp, 0) != 1) { + if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_OUT_TEMP_L, &tmp, 0) < 0) { i2c_release(BUS); return -LSM6DSL_ERROR_BUS; } traw = tmp; - if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_OUT_TEMP_H, &tmp, 0) != 1) { + if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_OUT_TEMP_H, &tmp, 0) < 0) { i2c_release(BUS); return -LSM6DSL_ERROR_BUS; } @@ -202,7 +202,7 @@ int lsm6dsl_acc_power_down(const lsm6dsl_t *dev) i2c_acquire(BUS); res = i2c_read_reg(BUS, ADDR, LSM6DSL_REG_CTRL1_XL, &tmp, 0); - if (res != 1) { + if (res < 0) { i2c_release(BUS); DEBUG("[ERROR] lsm6dsl_acc_power_down\n"); return -LSM6DSL_ERROR_BUS; @@ -213,7 +213,7 @@ int lsm6dsl_acc_power_down(const lsm6dsl_t *dev) i2c_release(BUS); - if (res != 1) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_acc_power_down\n"); return -LSM6DSL_ERROR_BUS; } @@ -228,7 +228,7 @@ int lsm6dsl_gyro_power_down(const lsm6dsl_t *dev) i2c_acquire(BUS); res = i2c_read_reg(BUS, ADDR, LSM6DSL_REG_CTRL2_G, &tmp, 0); - if (res != 1) { + if (res < 0) { i2c_release(BUS); DEBUG("[ERROR] lsm6dsl_gyro_power_down\n"); return -LSM6DSL_ERROR_BUS; @@ -239,7 +239,7 @@ int lsm6dsl_gyro_power_down(const lsm6dsl_t *dev) i2c_release(BUS); - if (res != 1) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_gyro_power_down\n"); return -LSM6DSL_ERROR_BUS; } @@ -254,7 +254,7 @@ int lsm6dsl_acc_power_up(const lsm6dsl_t *dev) i2c_acquire(BUS); res = i2c_read_reg(BUS, ADDR, LSM6DSL_REG_CTRL1_XL, &tmp, 0); - if (res != 1) { + if (res < 0) { i2c_release(BUS); DEBUG("[ERROR] lsm6dsl_acc_power_up\n"); return -LSM6DSL_ERROR_BUS; @@ -266,7 +266,7 @@ int lsm6dsl_acc_power_up(const lsm6dsl_t *dev) i2c_release(BUS); - if (res != 1) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_acc_power_up\n"); return -LSM6DSL_ERROR_BUS; } @@ -281,7 +281,7 @@ int lsm6dsl_gyro_power_up(const lsm6dsl_t *dev) i2c_acquire(BUS); res = i2c_read_reg(BUS, ADDR, LSM6DSL_REG_CTRL2_G, &tmp, 0); - if (res != 1) { + if (res < 0) { i2c_release(BUS); DEBUG("[ERROR] lsm6dsl_gyro_power_up\n"); return -LSM6DSL_ERROR_BUS; @@ -293,7 +293,7 @@ int lsm6dsl_gyro_power_up(const lsm6dsl_t *dev) i2c_release(BUS); - if (res != 1) { + if (res < 0) { DEBUG("[ERROR] lsm6dsl_gyro_power_up\n"); return -LSM6DSL_ERROR_BUS; }