sensor: Fix Unchecked return value in bma280 driver
This patch fixes two "Unchecked return value" conditions into the bma280 driver. The issue was reported by Coverity (CID 151953). Change-Id: I2e595b67619411594cec527f358f6c3d3d034550 Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
parent
575adb6060
commit
ceca10828a
1 changed files with 18 additions and 10 deletions
|
@ -82,29 +82,37 @@ static void bma280_thread_cb(void *arg)
|
||||||
struct device *dev = arg;
|
struct device *dev = arg;
|
||||||
struct bma280_data *drv_data = dev->driver_data;
|
struct bma280_data *drv_data = dev->driver_data;
|
||||||
uint8_t status = 0;
|
uint8_t status = 0;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
/* check for data ready */
|
/* check for data ready */
|
||||||
i2c_reg_read_byte(drv_data->i2c, BMA280_I2C_ADDRESS,
|
err = i2c_reg_read_byte(drv_data->i2c, BMA280_I2C_ADDRESS,
|
||||||
BMA280_REG_INT_STATUS_1, &status);
|
BMA280_REG_INT_STATUS_1, &status);
|
||||||
if (status & BMA280_BIT_DATA_INT_STATUS &&
|
if (status & BMA280_BIT_DATA_INT_STATUS &&
|
||||||
drv_data->data_ready_handler != NULL) {
|
drv_data->data_ready_handler != NULL &&
|
||||||
|
err == 0) {
|
||||||
drv_data->data_ready_handler(dev,
|
drv_data->data_ready_handler(dev,
|
||||||
&drv_data->data_ready_trigger);
|
&drv_data->data_ready_trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for any motion */
|
/* check for any motion */
|
||||||
i2c_reg_read_byte(drv_data->i2c, BMA280_I2C_ADDRESS,
|
err = i2c_reg_read_byte(drv_data->i2c, BMA280_I2C_ADDRESS,
|
||||||
BMA280_REG_INT_STATUS_0, &status);
|
BMA280_REG_INT_STATUS_0, &status);
|
||||||
if (status & BMA280_BIT_SLOPE_INT_STATUS &&
|
if (status & BMA280_BIT_SLOPE_INT_STATUS &&
|
||||||
drv_data->any_motion_handler != NULL) {
|
drv_data->any_motion_handler != NULL &&
|
||||||
|
err == 0) {
|
||||||
drv_data->any_motion_handler(dev,
|
drv_data->any_motion_handler(dev,
|
||||||
&drv_data->data_ready_trigger);
|
&drv_data->data_ready_trigger);
|
||||||
|
|
||||||
/* clear latched interrupt */
|
/* clear latched interrupt */
|
||||||
i2c_reg_update_byte(drv_data->i2c, BMA280_I2C_ADDRESS,
|
err = i2c_reg_update_byte(drv_data->i2c, BMA280_I2C_ADDRESS,
|
||||||
BMA280_REG_INT_RST_LATCH,
|
BMA280_REG_INT_RST_LATCH,
|
||||||
BMA280_BIT_INT_LATCH_RESET,
|
BMA280_BIT_INT_LATCH_RESET,
|
||||||
BMA280_BIT_INT_LATCH_RESET);
|
BMA280_BIT_INT_LATCH_RESET);
|
||||||
|
|
||||||
|
if (err < 0) {
|
||||||
|
SYS_LOG_DBG("Could not update clear the interrupt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio_pin_enable_callback(drv_data->gpio, CONFIG_BMA280_GPIO_PIN_NUM);
|
gpio_pin_enable_callback(drv_data->gpio, CONFIG_BMA280_GPIO_PIN_NUM);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue