public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio_keys: add gpio_to_irq return code check
@ 2007-09-18 15:43 Anti Sullin
  2007-09-18 15:59 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Anti Sullin @ 2007-09-18 15:43 UTC (permalink / raw)
  To: LKML; +Cc: dtor, akpm, david-b

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.

Signed-off-by: Anti Sullin <anti.sullin@artecdesign.ee> 

---

diff -pur clean/linux-2.6.23-rc5-at91/drivers/input/keyboard/gpio_keys.c linux-2.6.23-rc5-at91/drivers/input/keyboard/gpio_keys.c
--- clean/linux-2.6.23-rc5-at91/drivers/input/keyboard/gpio_keys.c	2007-09-01 09:08:24.000000000 +0300
+++ linux-2.6.23-rc5-at91/drivers/input/keyboard/gpio_keys.c	2007-09-18 16:59:23.000000000 +0300
@@ -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);



-- 
Anti Sullin
Embedded Software Engineer
Artec Design LLC
Türi 10C, 11313, Tallinn, Estonia


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

* Re: [PATCH 1/2] gpio_keys: add gpio_to_irq return code check
  2007-09-18 15:43 [PATCH 1/2] gpio_keys: add gpio_to_irq return code check Anti Sullin
@ 2007-09-18 15:59 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2007-09-18 15:59 UTC (permalink / raw)
  To: Anti Sullin; +Cc: LKML, akpm, david-b

Hi Anti,

On 9/18/07, Anti Sullin <anti.sullin@artecdesign.ee> wrote:
> 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.
>
...
> -               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?

> +                       goto fail;
> +

-- 
Dmitry

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

end of thread, other threads:[~2007-09-18 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-18 15:43 [PATCH 1/2] gpio_keys: add gpio_to_irq return code check Anti Sullin
2007-09-18 15:59 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox