]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/keyboard/gpio_keys.c
Input: add MODULE_ALIAS() to hotpluggable platform modules
[linux-2.6-omap-h63xx.git] / drivers / input / keyboard / gpio_keys.c
index 3eddf52a0bba5cabbe76a1f41cedee7c5fbf8ffc..bbd00c3fe98ca18999b19c011a8c0040f3e9fb9b 100644 (file)
@@ -43,10 +43,11 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
 
                        input_event(input, type, button->code, !!state);
                        input_sync(input);
+                       return IRQ_HANDLED;
                }
        }
 
-       return IRQ_HANDLED;
+       return IRQ_NONE;
 }
 
 static int __devinit gpio_keys_probe(struct platform_device *pdev)
@@ -75,16 +76,32 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 
        for (i = 0; i < pdata->nbuttons; i++) {
                struct gpio_keys_button *button = &pdata->buttons[i];
-               int irq = gpio_to_irq(button->gpio);
+               int irq;
                unsigned int type = button->type ?: EV_KEY;
 
+               error = gpio_request(button->gpio, button->desc ?: "gpio_keys");
+               if (error < 0) {
+                       pr_err("gpio-keys: failed to request GPIO %d,"
+                               " error %d\n", button->gpio, error);
+                       goto fail;
+               }
+
+               error = gpio_direction_input(button->gpio);
+               if (error < 0) {
+                       pr_err("gpio-keys: failed to configure input"
+                               " direction for GPIO %d, error %d\n",
+                               button->gpio, error);
+                       gpio_free(button->gpio);
+                       goto fail;
+               }
+
+               irq = gpio_to_irq(button->gpio);
                if (irq < 0) {
                        error = irq;
-                       printk(KERN_ERR
-                               "gpio-keys: "
-                               "Unable to get irq number for GPIO %d,"
-                               "error %d\n",
+                       pr_err("gpio-keys: Unable to get irq number"
+                               " for GPIO %d, error %d\n",
                                button->gpio, error);
+                       gpio_free(button->gpio);
                        goto fail;
                }
 
@@ -94,9 +111,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
                                    button->desc ? button->desc : "gpio_keys",
                                    pdev);
                if (error) {
-                       printk(KERN_ERR
-                               "gpio-keys: Unable to claim irq %d; error %d\n",
+                       pr_err("gpio-keys: Unable to claim irq %d; error %d\n",
                                irq, error);
+                       gpio_free(button->gpio);
                        goto fail;
                }
 
@@ -108,8 +125,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 
        error = input_register_device(input);
        if (error) {
-               printk(KERN_ERR
-                       "gpio-keys: Unable to register input device, "
+               pr_err("gpio-keys: Unable to register input device, "
                        "error: %d\n", error);
                goto fail;
        }
@@ -119,8 +135,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
        return 0;
 
  fail:
-       while (--i >= 0)
+       while (--i >= 0) {
                free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev);
+               gpio_free(pdata->buttons[i].gpio);
+       }
 
        platform_set_drvdata(pdev, NULL);
        input_free_device(input);
@@ -139,6 +157,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
        for (i = 0; i < pdata->nbuttons; i++) {
                int irq = gpio_to_irq(pdata->buttons[i].gpio);
                free_irq(irq, pdev);
+               gpio_free(pdata->buttons[i].gpio);
        }
 
        input_unregister_device(input);
@@ -195,6 +214,7 @@ struct platform_driver gpio_keys_device_driver = {
        .resume         = gpio_keys_resume,
        .driver         = {
                .name   = "gpio-keys",
+               .owner  = THIS_MODULE,
        }
 };
 
@@ -214,3 +234,4 @@ module_exit(gpio_keys_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Phil Blundell <pb@handhelds.org>");
 MODULE_DESCRIPTION("Keyboard driver for CPU GPIOs");
+MODULE_ALIAS("platform:gpio-keys");