* [PATCH] gpio-keys: support buttons with only one interrupt trigger type
@ 2008-11-26 17:11 Guennadi Liakhovetski
0 siblings, 0 replies; only message in thread
From: Guennadi Liakhovetski @ 2008-11-26 17:11 UTC (permalink / raw)
To: dtor; +Cc: linux-input
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 {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-26 17:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 17:11 [PATCH] gpio-keys: support buttons with only one interrupt trigger type Guennadi Liakhovetski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox