diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-06-29 19:01:49 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-06-29 19:01:49 +0000 |
commit | ca73ec3ee39a98e75df5db2ed543814e77a8ceb9 (patch) | |
tree | 2c82023b8cdba62ee18e3259106d6bf3ee404296 | |
parent | 6f085ea93a8d949d55bbcb422fe22b3581eb13a9 (diff) | |
download | upstream-ca73ec3ee39a98e75df5db2ed543814e77a8ceb9.tar.gz upstream-ca73ec3ee39a98e75df5db2ed543814e77a8ceb9.tar.bz2 upstream-ca73ec3ee39a98e75df5db2ed543814e77a8ceb9.zip |
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>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@37090 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c index 9d91b57b56..412c045fe4 100644 --- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c +++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c @@ -274,10 +274,16 @@ static void gpio_keys_polled_check_state(struct gpio_keys_button *button, if (state != bdata->last_state) { unsigned int type = button->type ?: EV_KEY; + if (bdata->count < bdata->threshold) { + bdata->count++; + return; + } + button_hotplug_event(bdata, type, button->code, state); - bdata->count = 0; bdata->last_state = state; } + + bdata->count = 0; } 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++) { struct gpio_keys_button_data *bdata = &bdev->data[i]; - - if (bdata->count < bdata->threshold) - bdata->count++; - else - gpio_keys_polled_check_state(&pdata->buttons[i], bdata); + gpio_keys_polled_check_state(&pdata->buttons[i], bdata); } gpio_keys_polled_queue_work(bdev); } |