diff mbox

[WIP,1/6] fixup gpio_buttons: use the same debounce_interval member found in gpio_key to obtain a threshold count based on polling interval

Message ID 08372c879762c2b1c2accd013318ffb6765f806c.1290631852.git.bengardiner@nanometrics.ca (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Gardiner Nov. 24, 2010, 9:01 p.m. UTC
None
diff mbox

Patch

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 {