[OpenWrt-Devel] [PATCH 2/2] gpio-button-hotplug: fix wrong initial seen value

Petr Štetiar ynezz at true.cz
Mon Jun 3 18:23:29 EDT 2019


Currently the generated event contains wrong seen value, when the button
is pressed for the first time:

 rmmod gpio_button_hotplug; modprobe gpio_button_hotplug
 [ pressing the wps key immediately after modprobe ]
 gpio-keys: create event, name=wps, seen=1088, pressed=1

So this patch adds a check for this corner case and makes seen=0 if the
button is pressed for the first time.

Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c | 3 +++
 1 file changed, 3 insertions(+)

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 d81898f932a1..f429f8c0271f 100644
--- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
+++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
@@ -253,6 +253,9 @@ static void button_hotplug_event(struct gpio_keys_button_data *data,
 	if (btn < 0)
 		return;
 
+	if (priv->seen == 0)
+		priv->seen = seen;
+
 	button_hotplug_create_event(button_map[btn].name, type,
 			(seen - priv->seen) / HZ, value);
 	priv->seen = seen;
-- 
1.9.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list