[PATCH RESENT] [RFC] gpio-keys: let platform code specify the trigger type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
Cc: Kay Sievers <kay.sievers@xxxxxxxx>
Cc: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx>
Cc: Dmitry Torokhov <dtor@xxxxxxx>
Cc: Herbert Valerio Riedel <hvr@xxxxxxx>

---
Hello,

I already sent this mail a week ago, so far without any feedback.  So I just
start a new try.

Best regards
Uwe

 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux