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
1 changed files with 7 additions and 6 deletions
|
@ -130,6 +130,7 @@ int adt7420_init_interrupt(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct adt7420_data *drv_data = dev->data;
|
struct adt7420_data *drv_data = dev->data;
|
||||||
const struct adt7420_dev_config *cfg = dev->config;
|
const struct adt7420_dev_config *cfg = dev->config;
|
||||||
|
int rc;
|
||||||
|
|
||||||
drv_data->gpio = device_get_binding(cfg->int_name);
|
drv_data->gpio = device_get_binding(cfg->int_name);
|
||||||
if (drv_data->gpio == NULL) {
|
if (drv_data->gpio == NULL) {
|
||||||
|
@ -142,14 +143,14 @@ int adt7420_init_interrupt(const struct device *dev)
|
||||||
adt7420_gpio_callback,
|
adt7420_gpio_callback,
|
||||||
BIT(cfg->int_pin));
|
BIT(cfg->int_pin));
|
||||||
|
|
||||||
int rc = gpio_pin_configure(drv_data->gpio, cfg->int_pin,
|
rc = gpio_pin_configure(drv_data->gpio, cfg->int_pin,
|
||||||
GPIO_INPUT | cfg->int_flags);
|
GPIO_INPUT | cfg->int_flags);
|
||||||
if (rc == 0) {
|
if (rc < 0) {
|
||||||
gpio_add_callback(drv_data->gpio, &drv_data->gpio_cb);
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != 0) {
|
rc = gpio_add_callback(drv_data->gpio, &drv_data->gpio_cb);
|
||||||
LOG_DBG("Failed to set gpio callback!");
|
if (rc < 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue