Linux Input/HID development
 help / color / mirror / Atom feed
From: Guennadi Liakhovetski <lg@denx.de>
To: dtor@mail.ru
Cc: linux-input@vger.kernel.org
Subject: [PATCH] gpio-keys: support buttons with only one interrupt trigger type
Date: Wed, 26 Nov 2008 18:11:37 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.0811261804480.4749@axis700.grange> (raw)

Some systems (e.g., i.MX31) do not support interrupts on both falling and 
rising GPIO edge. Modify the gpio-keys input driver to support such 
buttons, in which case, of course, no auto repeat can be provided.

Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
---
 drivers/input/keyboard/gpio_keys.c |   18 ++++++++++++++++--
 include/linux/gpio_keys.h          |    1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ad67d76..d9b4434 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -44,6 +44,14 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
 	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
 
 	input_event(input, type, button->code, !!state);
+	/*
+	 * If the button only supports press events, simulate release
+	 * immediately
+	 */
+	if (button->irq_trigger != (IRQF_TRIGGER_RISING |
+				    IRQF_TRIGGER_FALLING))
+		input_event(input, type, button->code, !state);
+
 	input_sync(input);
 }
 
@@ -141,9 +149,15 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 			goto fail2;
 		}
 
+		button->irq_trigger &= IRQF_TRIGGER_RISING |
+			IRQF_TRIGGER_FALLING;
+
+		if (!button->irq_trigger)
+			button->irq_trigger = IRQF_TRIGGER_RISING |
+				IRQF_TRIGGER_FALLING;
+
 		error = request_irq(irq, gpio_keys_isr,
-				    IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
-					IRQF_TRIGGER_FALLING,
+				    IRQF_SAMPLE_RANDOM | button->irq_trigger,
 				    button->desc ? button->desc : "gpio_keys",
 				    bdata);
 		if (error) {
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index 1289fa7..d0bd8e2 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -10,6 +10,7 @@ struct gpio_keys_button {
 	int type;		/* input event type (EV_KEY, EV_SW) */
 	int wakeup;		/* configure the button as a wake-up source */
 	int debounce_interval;	/* debounce ticks interval in msecs */
+	unsigned long irq_trigger; /* IRQF_TRIGGER_{RISING,FALLING} */
 };
 
 struct gpio_keys_platform_data {

                 reply	other threads:[~2008-11-26 17:11 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=Pine.LNX.4.64.0811261804480.4749@axis700.grange \
    --to=lg@denx.de \
    --cc=dtor@mail.ru \
    --cc=linux-input@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