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:
parent
53231c8bfe
commit
2682879df5
1 changed files with 16 additions and 5 deletions
|
@ -131,6 +131,7 @@ int sx9500_setup_interrupt(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct sx9500_data *data = dev->data;
|
struct sx9500_data *data = dev->data;
|
||||||
const struct device *gpio;
|
const struct device *gpio;
|
||||||
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||||
k_sem_init(&data->sem, 0, K_SEM_MAX_LIMIT);
|
k_sem_init(&data->sem, 0, K_SEM_MAX_LIMIT);
|
||||||
|
@ -147,16 +148,26 @@ int sx9500_setup_interrupt(const struct device *dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio_pin_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
|
ret = gpio_pin_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
|
||||||
GPIO_INPUT | DT_INST_GPIO_FLAGS(0, int_gpios));
|
GPIO_INPUT | DT_INST_GPIO_FLAGS(0, int_gpios));
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
gpio_init_callback(&data->gpio_cb,
|
gpio_init_callback(&data->gpio_cb,
|
||||||
sx9500_gpio_cb,
|
sx9500_gpio_cb,
|
||||||
BIT(DT_INST_GPIO_PIN(0, int_gpios)));
|
BIT(DT_INST_GPIO_PIN(0, int_gpios)));
|
||||||
|
|
||||||
gpio_add_callback(gpio, &data->gpio_cb);
|
ret = gpio_add_callback(gpio, &data->gpio_cb);
|
||||||
gpio_pin_interrupt_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gpio_pin_interrupt_configure(gpio, DT_INST_GPIO_PIN(0, int_gpios),
|
||||||
GPIO_INT_EDGE_TO_ACTIVE);
|
GPIO_INT_EDGE_TO_ACTIVE);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||||
k_thread_create(&sx9500_thread, sx9500_thread_stack,
|
k_thread_create(&sx9500_thread, sx9500_thread_stack,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue