linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RFC] gpio-keys: let platform code specify the trigger type
@ 2008-07-03  7:28 Uwe Kleine-König
  2008-07-10  8:58 ` [PATCH RESENT] " Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2008-07-03  7:28 UTC (permalink / raw)
  To: linux-input
  Cc: Kay Sievers, David Brownell, Dmitry Torokhov,
	Herbert Valerio Riedel

The intend for this change is that not all platform's irqs support
triggering on both edges.  Examples are ns9xxx[1] and txx9[2], and I
expect that there are more.

Provided that the platform data is initialized with zeros there is no
change in behavior if the new struct member 'trigger' isn't set in
platform code.

open points:
 - if only one trigger direction is used it should match active_low such
   that the button press generates the irq.
 - poll for button release instead of generate the release event
   directly after the press?
 - is it correct to input_sync() between press and release event?
 - sanitize button->trigger &= IRQF_TRIGGER_EDGE in gpio_keys_probe
   before passing it to request_irq?
 - a comment describing the trigger member of struct gpio_keys_button

I'd like to have polling support in this driver.  This could use
button->trigger == 0, so it might be sensible to add a
WARN_ON(!button->trigger) for now and wait some time before implementing
it.

[There is no MAINTAINER entry for gpio-keys, so I Cc: the last
contributors.] 

[1] The code to show that isn't in vanilla yet.  Basic machine support
    is in arch/arm/mach-ns9xxx.
[2] see txx9_irq_set_type in arch/mips/kernel/irq_txx9.c

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Herbert Valerio Riedel <hvr@gnu.org>

---
 drivers/input/keyboard/gpio_keys.c |   15 +++++++++++++--
 include/linux/gpio_keys.h          |    1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index bbd00c3..43a4c0c 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -26,6 +26,10 @@
 
 #include <asm/gpio.h>
 
+#ifndef IRQF_TRIGGER_EDGE
+#define IRQF_TRIGGER_EDGE (IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING)
+#endif
+
 static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
 {
 	int i;
@@ -43,6 +47,11 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
 
 			input_event(input, type, button->code, !!state);
 			input_sync(input);
+
+			if (~button->trigger & IRQF_TRIGGER_EDGE) {
+				input_event(input, type, button->code, !state);
+				input_sync(input);
+			}
 			return IRQ_HANDLED;
 		}
 	}
@@ -105,9 +114,11 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 			goto fail;
 		}
 
+		if (!button->trigger)
+			button->trigger = IRQF_TRIGGER_EDGE;
+
 		error = request_irq(irq, gpio_keys_isr,
-				    IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
-					IRQF_TRIGGER_FALLING,
+				    IRQF_SAMPLE_RANDOM | button->trigger,
 				    button->desc ? button->desc : "gpio_keys",
 				    pdev);
 		if (error) {
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index c6d3a9d..afe9d5d 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -9,6 +9,7 @@ struct gpio_keys_button {
 	char *desc;
 	int type;		/* input event type (EV_KEY, EV_SW) */
 	int wakeup;		/* configure the button as a wake-up source */
+	unsigned long trigger;
 };
 
 struct gpio_keys_platform_data {
-- 
1.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-14  5:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03  7:28 [PATCH] [RFC] gpio-keys: let platform code specify the trigger type Uwe Kleine-König
2008-07-10  8:58 ` [PATCH RESENT] " Uwe Kleine-König
2008-07-10 13:54   ` Dmitry Torokhov
2008-07-14  5:33     ` Uwe Kleine-König

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).