int last_state;
int count;
int threshold;
- int can_sleep;
};
struct gpio_keys_polled_dev {
{
int state;
- if (bdata->can_sleep)
- state = !!gpiod_get_value_cansleep(bdata->gpiod);
- else
- state = !!gpiod_get_value(bdata->gpiod);
-
- gpio_keys_button_event(dev, button, state);
+ state = gpiod_get_value_cansleep(bdata->gpiod);
+ if (state < 0) {
+ dev_err(dev->input->dev.parent,
+ "failed to get gpio state: %d\n", state);
+ } else {
+ gpio_keys_button_event(dev, button, state);
- if (state != bdata->last_state) {
- bdata->count = 0;
- bdata->last_state = state;
+ if (state != bdata->last_state) {
+ bdata->count = 0;
+ bdata->last_state = state;
+ }
}
}
}
}
- bdata->can_sleep = gpiod_cansleep(bdata->gpiod);
bdata->last_state = -1;
bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
pdata->poll_interval);