Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=006df3024431a50262d4a2898d25924f84fb697a
Commit:     006df3024431a50262d4a2898d25924f84fb697a
Parent:     2a8281d72da5dd8da025e6822dadd23a35383895
Author:     Anti Sullin <[EMAIL PROTECTED]>
AuthorDate: Wed Sep 26 00:01:03 2007 -0400
Committer:  Dmitry Torokhov <[EMAIL PROTECTED]>
CommitDate: Wed Sep 26 00:01:03 2007 -0400

    Input: gpio_keys - verify that supplied GPIO numbers are valid
    
    As David Brownell pointed out, gpio_keys driver does not check
    return code of gpio_to_irq().
    
    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 <[EMAIL PROTECTED]>
    Signed-off-by: Dmitry Torokhov <[EMAIL PROTECTED]>
---
 drivers/input/keyboard/gpio_keys.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c 
b/drivers/input/keyboard/gpio_keys.c
index 7392122..b3069bc 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -78,12 +78,24 @@ static int __devinit gpio_keys_probe(struct platform_device 
*pdev)
                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) {
+                       error = irq;
+                       printk(KERN_ERR
+                               "gpio-keys: "
+                               "Unable to get irq number for GPIO %d,"
+                               "error %d\n",
+                               button->gpio, error);
+                       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",
+                       printk(KERN_ERR
+                               "gpio-keys: Unable to claim irq %d; error %d\n",
                                irq, error);
                        goto fail;
                }
@@ -93,16 +105,19 @@ static int __devinit gpio_keys_probe(struct 
platform_device *pdev)
 
        error = input_register_device(input);
        if (error) {
-               printk(KERN_ERR "Unable to register gpio-keys input device\n");
+               printk(KERN_ERR
+                       "gpio-keys: Unable to register input device, "
+                       "error: %d\n", error);
                goto fail;
        }
 
        return 0;
 
  fail:
-       for (i = i - 1; i >= 0; i--)
+       while (--i >= 0)
                free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev);
 
+       platform_set_drvdata(pdev, NULL);
        input_free_device(input);
 
        return error;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to