Input: gpio_keys - fix warning regarding uninitialized 'irq' variable
[sfrench/cifs-2.6.git] / drivers / input / keyboard / gpio_keys.c
index 8c98e97f8e41144a08c53e4c5ee1eefca9ebfb0f..b8b4876ac8d3151211984264e599f73b46e5c63c 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
+#include <linux/of_irq.h>
 #include <linux/spinlock.h>
 
 struct gpio_button_data {
@@ -617,23 +618,26 @@ gpio_keys_get_devtree_pdata(struct device *dev)
 
        i = 0;
        for_each_child_of_node(node, pp) {
-               int gpio;
+               int gpio = -1;
                enum of_gpio_flags flags;
 
                if (!of_find_property(pp, "gpios", NULL)) {
-                       pdata->nbuttons--;
-                       dev_warn(dev, "Found button without gpios\n");
-                       continue;
-               }
-
-               gpio = of_get_gpio_flags(pp, 0, &flags);
-               if (gpio < 0) {
-                       error = gpio;
-                       if (error != -EPROBE_DEFER)
-                               dev_err(dev,
-                                       "Failed to get gpio flags, error: %d\n",
-                                       error);
-                       return ERR_PTR(error);
+                       button->irq = irq_of_parse_and_map(pp, 0);
+                       if (button->irq == 0) {
+                               pdata->nbuttons--;
+                               dev_warn(dev, "Found button without gpios or irqs\n");
+                               continue;
+                       }
+               } else {
+                       gpio = of_get_gpio_flags(pp, 0, &flags);
+                       if (gpio < 0) {
+                               error = gpio;
+                               if (error != -EPROBE_DEFER)
+                                       dev_err(dev,
+                                               "Failed to get gpio flags, error: %d\n",
+                                               error);
+                               return ERR_PTR(error);
+                       }
                }
 
                button = &pdata->buttons[i++];