drivers: input: add few missing gpio_add_callback return check

Add few missing check on gpio_add_callback and gpio_add_callback_dt
calls, fixes a coverity warning.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2023-07-18 11:28:40 +00:00 committed by Fabio Baltieri
parent 3d94c830a3
commit d95c12848d
3 changed files with 17 additions and 3 deletions

View file

@ -204,7 +204,11 @@ static int gpio_qdec_init(const struct device *dev)
return ret; return ret;
} }
gpio_add_callback_dt(gpio, &data->gpio_cb); ret = gpio_add_callback_dt(gpio, &data->gpio_cb);
if (ret < 0) {
LOG_ERR("Could not set gpio callback");
return ret;
}
} }
data->prev_step = gpio_qdec_get_step(dev); data->prev_step = gpio_qdec_get_step(dev);

View file

@ -343,7 +343,11 @@ static int gt911_init(const struct device *dev)
} }
#ifdef CONFIG_INPUT_GT911_INTERRUPT #ifdef CONFIG_INPUT_GT911_INTERRUPT
gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb); r = gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
if (r < 0) {
LOG_ERR("Could not set gpio callback");
return ret;
}
#else #else
k_timer_start(&data->timer, K_MSEC(CONFIG_INPUT_GT911_PERIOD_MS), k_timer_start(&data->timer, K_MSEC(CONFIG_INPUT_GT911_PERIOD_MS),
K_MSEC(CONFIG_INPUT_GT911_PERIOD_MS)); K_MSEC(CONFIG_INPUT_GT911_PERIOD_MS));

View file

@ -125,6 +125,7 @@ static void xpt2046_work_handler(struct k_work *kw)
{ {
struct xpt2046_data *data = CONTAINER_OF(kw, struct xpt2046_data, work); struct xpt2046_data *data = CONTAINER_OF(kw, struct xpt2046_data, work);
struct xpt2046_config *config = (struct xpt2046_config *)data->dev->config; struct xpt2046_config *config = (struct xpt2046_config *)data->dev->config;
int ret;
const struct spi_buf txb = {.buf = tbuf, .len = sizeof(tbuf)}; const struct spi_buf txb = {.buf = tbuf, .len = sizeof(tbuf)};
const struct spi_buf rxb = {.buf = data->rbuf, .len = sizeof(data->rbuf)}; const struct spi_buf rxb = {.buf = data->rbuf, .len = sizeof(data->rbuf)};
@ -180,7 +181,12 @@ static void xpt2046_work_handler(struct k_work *kw)
/* Ensure that we send released event */ /* Ensure that we send released event */
k_work_reschedule(&data->dwork, K_MSEC(100)); k_work_reschedule(&data->dwork, K_MSEC(100));
} }
gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
ret = gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
if (ret < 0) {
LOG_ERR("Could not set gpio callback");
return;
}
} }
static int xpt2046_init(const struct device *dev) static int xpt2046_init(const struct device *dev)