From: NeilBrown <neilb@suse.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Input: gpio_keys - ensure we don't miss key-presses during resume.
Date: Wed, 25 Apr 2012 12:08:49 +1000 [thread overview]
Message-ID: <20120425120849.04cee091@notabene.brown> (raw)
[-- Attachment #1: Type: text/plain, Size: 1696 bytes --]
If the latency of resume means we don't poll the key status until
after it has been released, we can lose the keypress which woke the
device.
So on each interrupt, record that a press is pending, and in that
case, report both the up and down event, ordered such that the second
event is that one that reflects the current state.
One event will normally be swallowed by the input layer if there was
no change, but the result will be that every interrupt will produce at
least one event.
Signed-off-by: NeilBrown <neilb@suse.de>
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 62bfce4..961e5e1 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -40,6 +40,7 @@ struct gpio_button_data {
spinlock_t lock;
bool disabled;
bool key_pressed;
+ bool pending;
};
struct gpio_keys_drvdata {
@@ -335,6 +336,14 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
if (state)
input_event(input, type, button->code, button->value);
} else {
+ if (type == EV_KEY && bdata->pending) {
+ /* Before reporting the observed state, report the
+ * alternate to be sure that a change is seen.
+ */
+ bdata->pending = 0;
+ input_event(input, type, button->code, !state);
+ input_sync(input);
+ }
input_event(input, type, button->code, !!state);
}
input_sync(input);
@@ -361,6 +370,7 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
BUG_ON(irq != bdata->irq);
+ bdata->pending = true;
if (bdata->timer_debounce)
mod_timer(&bdata->timer,
jiffies + msecs_to_jiffies(bdata->timer_debounce));
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
reply other threads:[~2012-04-25 2:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120425120849.04cee091@notabene.brown \
--to=neilb@suse.de \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).