gpio_keys: add gpio_to_irq return code check
Subsystems (2)
PATCH 1/2 gpio_keys: add gpio_to_irq return code check
As David Brownell pointed out when reviewing my suspend patch to gpio_keys, the original gpio_keys driver does not check gpio_to_irq return code.
This patch adds the gpio_to_irq return code check to gpio_keys and moves the IRQ edge type setting to request_irq flags to avoid changing the irq type before we have confirmed we can use it.
---
drivers/input/keyboard/gpio_keys.c renamed from linux-2.6.23-rc5-at91/drivers/input/keyboard/gpio_keys.c +0 -0
@@ -77,10 +77,12 @@ static int __devinit gpio_keys_probe(str
int irq = gpio_to_irq(button->gpio); unsigned int type = button->type ?: EV_KEY;
- set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
- error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM,
- button->desc ? button->desc : "gpio_keys",
- pdev);
+ if (irq < 0)
+ goto fail;
+
+ error = request_irq(irq, gpio_keys_isr, + IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+ button->desc ? button->desc : "gpio_keys", pdev);
if (error) {
printk(KERN_ERR "gpio-keys: unable to claim irq %d; error %d\n",
irq, error);Signature · 4 lines
Anti Sullin Embedded Software Engineer Artec Design LLC Türi 10C, 11313, Tallinn, Estonia
Dmitry Torokhov
maintainerHi Anti,
Quoted 4 lines · Anti Sullin
As David Brownell pointed out when reviewing my suspend patch to
gpio_keys, the originalgpio_keysdriver does not checkgpio_to_irqreturn code.
...
Review
Quoted 5 lines
(quoted diff) +1
-4- set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); - error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM, - button->desc ? button->desc : "gpio_keys", - pdev); + if (irq < 0)
What would be the value of error variable (that we use as a return value) here?
Quoted 2 lines
(quoted diff) +2
-0+ goto fail; +
Signature · 1 line
Dmitry