linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@caiaq.de>
To: linux-input@vger.kernel.org
Cc: Daniel Mack <daniel@caiaq.de>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jani Nikula <ext-jani.1.nikula@nokia.com>,
	Mike Rapoport <mike@compulab.co.il>
Subject: [PATCH] input_ gpio_keys: scan gpio state at probe time
Date: Wed, 25 Nov 2009 11:53:36 +0100	[thread overview]
Message-ID: <1259146416-6713-1-git-send-email-daniel@caiaq.de> (raw)

gpio_keys.c registers interrupts at both edges of all given gpio lines
and updates the input device when they change. However, the driver fails
to check the current line state at probe time.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jani Nikula <ext-jani.1.nikula@nokia.com>
Cc: Mike Rapoport <mike@compulab.co.il>
---
 drivers/input/keyboard/gpio_keys.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 77d1309..cb5f862 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -171,6 +171,18 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 		goto fail2;
 	}
 
+	/* get current state of buttons */
+	for (i = 0; i < pdata->nbuttons; i++) {
+		struct gpio_keys_button *button = &pdata->buttons[i];
+		int state = !!gpio_get_value(button->gpio) ^ button->active_low;
+
+		if (state) {
+			unsigned int type = button->type ?: EV_KEY;
+			input_event(input, type, button->code, !!state);
+			input_sync(input);
+		}
+	}
+
 	device_init_wakeup(&pdev->dev, wakeup);
 
 	return 0;
-- 
1.6.5.2


             reply	other threads:[~2009-11-25 10:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 10:53 Daniel Mack [this message]
2009-11-26  3:46 ` [PATCH] input_ gpio_keys: scan gpio state at probe time Dmitry Torokhov
2009-12-14  3:10   ` Daniel Mack
2009-12-14  4:31     ` Dmitry Torokhov
2009-12-17  1:05       ` Daniel Mack
2009-12-17  1:16         ` Dmitry Torokhov

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=1259146416-6713-1-git-send-email-daniel@caiaq.de \
    --to=daniel@caiaq.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ext-jani.1.nikula@nokia.com \
    --cc=linux-input@vger.kernel.org \
    --cc=mike@compulab.co.il \
    /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).