[OpenWrt-Devel] [PATCH] gpio-button-hotplug: gpio-keys: fix always missing first event

Christian Lamparter chunkeey at gmail.com
Sun Jun 9 04:06:33 EDT 2019


On Thursday, June 6, 2019 6:52:35 AM CEST Kristian Evensen wrote:
> Hi Christian,
> 
> On Wed, Jun 5, 2019 at 10:23 PM Christian Lamparter <chunkeey at gmail.com> wrote:
> > @Kristian Evensen, can you please check if the following patch would also
> > resolve the issues you have been experiencing?
> >
> > I had to attach the patch as a file since gmail's webmail interface now seems to
> > eat all the tabs. I hope this still gets through.
> 
> Patch arrived safe and sound, and I just finished my tests on the
> ZBT-WD323 (AR9344). I started out by building a fresh image from
> master (head of my tree is commit 66d1c29655a4), and with this image I
> saw the earlier reported behavior (a press of the button triggers
> factory reset). I then applied your patch on top of my tree and the
> button now works as expected. A short press triggers reboot, and
> holding the button for ~5 seconds triggers a factory reset.

@ynezz, @Kristian

The APM821xx checks out with both as well. While there are spurious
events on enabling the interrupt (one released event), 
the /etc/rc.button/ scripts are setup to handle that. So, which patch
should we take and who gets the merge them? (I've seen that ynezz has
more patches as well.)

Cheers,
Christian
---
From 0a46c8adb4d0dd288c6a646dd53757c6805e584a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz at true.cz>
Date: Sat, 8 Jun 2019 01:05:32 +0200
Subject: [PATCH] gpio-button-hotplug: gpio-keys: fix always missing first
 event
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit afc056d7dc83 ("gpio-button-hotplug: support interrupt
properties") changed the gpio-keys interrupt handling logic in a way,
that it always misses first event, which causes issues with rc.button
scripts, so this patch restores the previous behaviour.

Fixes: afc056d7dc83 ("gpio-button-hotplug: support interrupt properties")
Reported-by: Kristian Evensen <kristian.evensen at gmail.com>
Signed-off-by: Petr Štetiar <ynezz at true.cz>
Signed-off-by: Christian Lamparter <chunkeey at gmail.com> [drop state check]
---
 .../gpio-button-hotplug/src/gpio-button-hotplug.c     | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

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 11c914d4ef..6de8f56cdf 100644
--- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
+++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
@@ -348,16 +348,9 @@ static void gpio_keys_irq_work_func(struct work_struct *work)
 {
 	struct gpio_keys_button_data *bdata = container_of(work,
 		struct gpio_keys_button_data, work.work);
-	int state = gpio_button_get_value(bdata);
 
-	if (state != bdata->last_state) {
-		unsigned int type = bdata->b->type ?: EV_KEY;
-
-		if (bdata->last_state != -1 || type == EV_SW)
-			button_hotplug_event(bdata, type, state);
-
-		bdata->last_state = state;
-	}
+	button_hotplug_event(bdata, bdata->b->type ?: EV_KEY,
+			     gpio_button_get_value(bdata));
 }
 
 static irqreturn_t button_handle_irq(int irq, void *_bdata)
-- 
2.20.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