lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250625215813.3477840-4-superm1@kernel.org>
Date: Wed, 25 Jun 2025 16:58:12 -0500
From: Mario Limonciello <superm1@...nel.org>
To: Hans de Goede <hansg@...nel.org>,
	Mika Westerberg <westeri@...nel.org>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Linus Walleij <linus.walleij@...aro.org>,
	Bartosz Golaszewski <brgl@...ev.pl>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: linux-gpio@...r.kernel.org (open list:GPIO ACPI SUPPORT),
	linux-acpi@...r.kernel.org (open list:GPIO ACPI SUPPORT),
	linux-kernel@...r.kernel.org (open list),
	linux-input@...r.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...),
	Mario Limonciello <mario.limonciello@....com>
Subject: [PATCH v3 3/4] Input: Don't program hw debounce for soc_button_array devices

From: Mario Limonciello <mario.limonciello@....com>

Programming a hardware debounce of 50ms causes problems where a button
doesn't work properly anymore on some systems.  This debounce is intended
for compatibility with systems with a mechanical switch so soc_button_array
devices should only be using a sofware debounce.

Add support for indicating that a driver is only requesting gpio_keys
to use software debounce support and mark that in soc_button_array
accordingly.

Suggested-by: Hans de Goede <hansg@...nel.org>
Fixes: 5c4fa2a6da7fb ("Input: soc_button_array - debounce the buttons")
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
 drivers/input/keyboard/gpio_keys.c    | 7 +++++--
 drivers/input/misc/soc_button_array.c | 1 +
 include/linux/gpio_keys.h             | 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index f9db86da0818b..773aa5294d269 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -552,8 +552,11 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 		bool active_low = gpiod_is_active_low(bdata->gpiod);
 
 		if (button->debounce_interval) {
-			error = gpiod_set_debounce(bdata->gpiod,
-					button->debounce_interval * 1000);
+			if (ddata->pdata->no_hw_debounce)
+				error = -EINVAL;
+			else
+				error = gpiod_set_debounce(bdata->gpiod,
+							   button->debounce_interval * 1000);
 			/* use timer if gpiolib doesn't provide debounce */
 			if (error < 0)
 				bdata->software_debounce =
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index b8cad415c62ca..dac940455bea8 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -232,6 +232,7 @@ soc_button_device_create(struct platform_device *pdev,
 	gpio_keys_pdata->buttons = gpio_keys;
 	gpio_keys_pdata->nbuttons = n_buttons;
 	gpio_keys_pdata->rep = autorepeat;
+	gpio_keys_pdata->no_hw_debounce = TRUE;
 
 	pd = platform_device_register_resndata(&pdev->dev, "gpio-keys",
 					       PLATFORM_DEVID_AUTO, NULL, 0,
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index 80fa930b04c67..c99f74467fda6 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -48,6 +48,7 @@ struct gpio_keys_button {
  * @enable:		platform hook for enabling the device
  * @disable:		platform hook for disabling the device
  * @name:		input device name
+ * @no_hw_debounce:	avoid programming hardware debounce
  */
 struct gpio_keys_platform_data {
 	const struct gpio_keys_button *buttons;
@@ -57,6 +58,7 @@ struct gpio_keys_platform_data {
 	int (*enable)(struct device *dev);
 	void (*disable)(struct device *dev);
 	const char *name;
+	bool no_hw_debounce;
 };
 
 #endif
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ