drivers: sensor: adt7420: check gpio add callback return code
gpio_add_callback was not being error-checked. Some other minor cleanups (rc var to the top, remove redundant log). This patch fixes coverity issue 236649. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
2682879df5
commit
6cfab29e19
|
@ -130,6 +130,7 @@ int adt7420_init_interrupt(const struct device *dev)
|
|||
{
|
||||
struct adt7420_data *drv_data = dev->data;
|
||||
const struct adt7420_dev_config *cfg = dev->config;
|
||||
int rc;
|
||||
|
||||
drv_data->gpio = device_get_binding(cfg->int_name);
|
||||
if (drv_data->gpio == NULL) {
|
||||
|
@ -142,14 +143,14 @@ int adt7420_init_interrupt(const struct device *dev)
|
|||
adt7420_gpio_callback,
|
||||
BIT(cfg->int_pin));
|
||||
|
||||
int rc = gpio_pin_configure(drv_data->gpio, cfg->int_pin,
|
||||
GPIO_INPUT | cfg->int_flags);
|
||||
if (rc == 0) {
|
||||
gpio_add_callback(drv_data->gpio, &drv_data->gpio_cb);
|
||||
rc = gpio_pin_configure(drv_data->gpio, cfg->int_pin,
|
||||
GPIO_INPUT | cfg->int_flags);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
LOG_DBG("Failed to set gpio callback!");
|
||||
rc = gpio_add_callback(drv_data->gpio, &drv_data->gpio_cb);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue