public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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: twl4030 power button: don't lose presses on resume
Date: Wed, 25 Apr 2012 12:21:39 +1000	[thread overview]
Message-ID: <20120425122139.512c6890@notabene.brown> (raw)

[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]


If we press and release the power button before the press interrupt is
handled - as can happen on resume - we lose the press event so the
release event is ignored and we don't know what happened to cause the
wakeup.

So make sure that each interrupt handled does generate an event.
Because twl4030 queues interrupt events we will see two interrupts
for a press-release even if we handle the first one later.  This means
that such a sequence will be reported as two button presses.  This
is unfortunate but is better than no button presses.
Possibly we could set the PENDDIS_MASK to disable queuing of
interrupts, but that might adversely affect other interrupt sources.

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index 38e4b50..7ea0ea8 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -42,7 +42,19 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
 	err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
 				STS_HW_CONDITIONS);
 	if (!err)  {
-		input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
+		int val = !!(value & PWR_PWRON_IRQ);
+
+		/* We got an interrupt, so we must see a change.
+		 * Because the TWL4030 queues pending interrupts to a depth
+		 * of 2, we end up seeing two key presses as there can
+		 * be two interrupts processed while the key appears to
+		 * be up.  This could be fixed by setting PNEDDIS_MASK
+		 * in PWR_SIH_CTRL in twl4030-irq.c.
+		 */
+		input_report_key(pwr, KEY_POWER, !val);
+		input_sync(pwr);
+
+		input_report_key(pwr, KEY_POWER, val);
 		input_sync(pwr);
 	} else {
 		dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading"

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

             reply	other threads:[~2012-04-25  2:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-25  2:21 NeilBrown [this message]
2012-04-25  5:09 ` [PATCH] Input: twl4030 power button: don't lose presses on resume Dmitry Torokhov
2012-04-25  5:26   ` NeilBrown
2012-04-25 16:56     ` anish kumar
2012-04-25 20:58       ` NeilBrown
2012-04-26  3:06         ` anish singh
2012-04-26  7:14     ` NeilBrown

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=20120425122139.512c6890@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