diff --git a/drivers/sensor/lsm6dso/lsm6dso.c b/drivers/sensor/lsm6dso/lsm6dso.c index 6938579d1e9..7b6b0357c39 100644 --- a/drivers/sensor/lsm6dso/lsm6dso.c +++ b/drivers/sensor/lsm6dso/lsm6dso.c @@ -297,17 +297,12 @@ static int lsm6dso_sample_fetch_accel(const struct device *dev) const struct lsm6dso_config *cfg = dev->config; stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; struct lsm6dso_data *data = dev->data; - int16_t buf[3]; - if (lsm6dso_acceleration_raw_get(ctx, buf) < 0) { + if (lsm6dso_acceleration_raw_get(ctx, data->acc) < 0) { LOG_DBG("Failed to read sample"); return -EIO; } - data->acc[0] = sys_le16_to_cpu(buf[0]); - data->acc[1] = sys_le16_to_cpu(buf[1]); - data->acc[2] = sys_le16_to_cpu(buf[2]); - return 0; } @@ -316,17 +311,12 @@ static int lsm6dso_sample_fetch_gyro(const struct device *dev) const struct lsm6dso_config *cfg = dev->config; stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; struct lsm6dso_data *data = dev->data; - int16_t buf[3]; - if (lsm6dso_angular_rate_raw_get(ctx, buf) < 0) { + if (lsm6dso_angular_rate_raw_get(ctx, data->gyro) < 0) { LOG_DBG("Failed to read sample"); return -EIO; } - data->gyro[0] = sys_le16_to_cpu(buf[0]); - data->gyro[1] = sys_le16_to_cpu(buf[1]); - data->gyro[2] = sys_le16_to_cpu(buf[2]); - return 0; } @@ -336,15 +326,12 @@ static int lsm6dso_sample_fetch_temp(const struct device *dev) const struct lsm6dso_config *cfg = dev->config; stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; struct lsm6dso_data *data = dev->data; - int16_t buf; - if (lsm6dso_temperature_raw_get(ctx, &buf) < 0) { + if (lsm6dso_temperature_raw_get(ctx, &data->temp_sample) < 0) { LOG_DBG("Failed to read sample"); return -EIO; } - data->temp_sample = sys_le16_to_cpu(buf); - return 0; } #endif diff --git a/drivers/sensor/lsm6dso/lsm6dso.h b/drivers/sensor/lsm6dso/lsm6dso.h index 1f69f54389a..336ebcdd475 100644 --- a/drivers/sensor/lsm6dso/lsm6dso.h +++ b/drivers/sensor/lsm6dso/lsm6dso.h @@ -79,7 +79,7 @@ struct lsm6dso_data { int16_t gyro[3]; uint32_t gyro_gain; #if defined(CONFIG_LSM6DSO_ENABLE_TEMP) - int temp_sample; + int16_t temp_sample; #endif #if defined(CONFIG_LSM6DSO_SENSORHUB) uint8_t ext_data[2][6];