my reasoning was that if the debounce interval was set then the platform _wants_ to supress spurious events so it was better to roundup and swallow real events than round down and not supress. I'm fine also with using the poll_interval and debuonce_interval directly as you suggested. Signed-off-by: Ben Gardiner <bengardiner@xxxxxxxxxxxxxx> --- drivers/input/misc/gpio_buttons.c | 7 +++++-- include/linux/gpio_buttons.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/gpio_buttons.c b/drivers/input/misc/gpio_buttons.c index 51288a3..f42906c 100644 --- a/drivers/input/misc/gpio_buttons.c +++ b/drivers/input/misc/gpio_buttons.c @@ -68,13 +68,16 @@ static void gpio_buttons_poll(struct input_polled_dev *dev) struct gpio_buttons_dev *bdev = dev->private; struct gpio_buttons_platform_data *pdata = bdev->pdata; struct input_dev *input = dev->input; - int i; + int i, threshold; for (i = 0; i < bdev->pdata->nbuttons; i++) { struct gpio_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &bdev->data[i]; - if (bdata->count < button->threshold) + threshold = round_up(button->debounce_interval, + pdata->poll_interval) / + pdata->poll_interval; + if (bdata->count < threshold) bdata->count++; else gpio_buttons_check_state(input, button, bdata); diff --git a/include/linux/gpio_buttons.h b/include/linux/gpio_buttons.h index f85b993..c016f07 100644 --- a/include/linux/gpio_buttons.h +++ b/include/linux/gpio_buttons.h @@ -21,7 +21,7 @@ struct gpio_button { char *desc; /* button description */ int type; /* input event type (EV_KEY, EV_SW) */ int code; /* input event code (KEY_*, SW_*) */ - int threshold; /* count threshold */ + int debounce_interval; /* debounce ticks interval in msecs */ }; struct gpio_buttons_platform_data { -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html