diff mbox

[2/2] Input: soc_button_array - Debounce the buttons

Message ID 20170109175707.12854-2-hdegoede@redhat.com (mailing list archive)
State Accepted
Headers show

Commit Message

Hans de Goede Jan. 9, 2017, 5:57 p.m. UTC
The soc_button_array driver was initializing (kzalloc) the
debounce_interval value to 0, leading to no debouncing at all,
while the buttons are simple mechanical switches.

This commit sets debounce_interval to 50ms to avoid spurious button
press reports both on press and release of the button. Note 50ms may
seem like a lot but soc_button_array is typically used with cheap
tablets, with not so great buttons. I tried 10ms on my tablet and it
is not enough, where as 50ms works well.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/misc/soc_button_array.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Dmitry Torokhov Jan. 21, 2017, 7:14 p.m. UTC | #1
On Mon, Jan 09, 2017 at 06:57:07PM +0100, Hans de Goede wrote:
> The soc_button_array driver was initializing (kzalloc) the
> debounce_interval value to 0, leading to no debouncing at all,
> while the buttons are simple mechanical switches.
> 
> This commit sets debounce_interval to 50ms to avoid spurious button
> press reports both on press and release of the button. Note 50ms may
> seem like a lot but soc_button_array is typically used with cheap
> tablets, with not so great buttons. I tried 10ms on my tablet and it
> is not enough, where as 50ms works well.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

> ---
>  drivers/input/misc/soc_button_array.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
> index d2e5186..e53b0a1 100644
> --- a/drivers/input/misc/soc_button_array.c
> +++ b/drivers/input/misc/soc_button_array.c
> @@ -101,6 +101,8 @@ soc_button_device_create(struct platform_device *pdev,
>  		gpio_keys[n_buttons].active_low = 1;
>  		gpio_keys[n_buttons].desc = info->name;
>  		gpio_keys[n_buttons].wakeup = info->wakeup;
> +		/* These devices often use cheap buttons, use 50 ms debounce */
> +		gpio_keys[n_buttons].debounce_interval = 50;
>  		n_buttons++;
>  	}
>  
> -- 
> 2.9.3
>
diff mbox

Patch

diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index d2e5186..e53b0a1 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -101,6 +101,8 @@  soc_button_device_create(struct platform_device *pdev,
 		gpio_keys[n_buttons].active_low = 1;
 		gpio_keys[n_buttons].desc = info->name;
 		gpio_keys[n_buttons].wakeup = info->wakeup;
+		/* These devices often use cheap buttons, use 50 ms debounce */
+		gpio_keys[n_buttons].debounce_interval = 50;
 		n_buttons++;
 	}