drivers: sensor: sx9500: check gpio calls return code

Some GPIO related calls were not being checked for error.

This patch fixes coverity issue 236648.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-08-26 08:38:16 +02:00 committed by Anas Nashif
parent 53231c8bfe
commit 2682879df5

View file

@ -131,6 +131,7 @@ int sx9500_setup_interrupt(const struct device *dev)
{
struct sx9500_data *data = dev->data;
const struct device *gpio;
int ret;
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
k_sem_init(&data->sem, 0, K_SEM_MAX_LIMIT);
@ -147,16 +148,26 @@ int sx9500_setup_interrupt(const struct device *dev)
return -EINVAL;
}
gpio_pin_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
GPIO_INPUT | DT_INST_GPIO_FLAGS(0, int_gpios));
ret = gpio_pin_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
GPIO_INPUT | DT_INST_GPIO_FLAGS(0, int_gpios));
if (ret < 0) {
return ret;
}
gpio_init_callback(&data->gpio_cb,
sx9500_gpio_cb,
BIT(DT_INST_GPIO_PIN(0, int_gpios)));
gpio_add_callback(gpio, &data->gpio_cb);
gpio_pin_interrupt_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
GPIO_INT_EDGE_TO_ACTIVE);
ret = gpio_add_callback(gpio, &data->gpio_cb);
if (ret < 0) {
return ret;
}
ret = gpio_pin_interrupt_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
GPIO_INT_EDGE_TO_ACTIVE);
if (ret < 0) {
return ret;
}
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
k_thread_create(&sx9500_thread, sx9500_thread_stack,