gpio-button-hotplug: improve gpio button debouncing, verify state changes over multiple polls. fixes spurious failsafe triggers (#13784)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37090
This commit is contained in:
Felix Fietkau 2013-06-29 19:01:49 +00:00
parent 124ef95f5f
commit 0f6e9c9fcc

View File

@ -274,10 +274,16 @@ static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
if (state != bdata->last_state) { if (state != bdata->last_state) {
unsigned int type = button->type ?: EV_KEY; unsigned int type = button->type ?: EV_KEY;
if (bdata->count < bdata->threshold) {
bdata->count++;
return;
}
button_hotplug_event(bdata, type, button->code, state); button_hotplug_event(bdata, type, button->code, state);
bdata->count = 0;
bdata->last_state = state; bdata->last_state = state;
} }
bdata->count = 0;
} }
static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev) static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev)
@ -299,11 +305,7 @@ static void gpio_keys_polled_poll(struct work_struct *work)
for (i = 0; i < bdev->pdata->nbuttons; i++) { for (i = 0; i < bdev->pdata->nbuttons; i++) {
struct gpio_keys_button_data *bdata = &bdev->data[i]; struct gpio_keys_button_data *bdata = &bdev->data[i];
gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
if (bdata->count < bdata->threshold)
bdata->count++;
else
gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
} }
gpio_keys_polled_queue_work(bdev); gpio_keys_polled_queue_work(bdev);
} }