kernel: gpio-button-hotplug: Add missing ONESHOT flag to threaded IRQ request
[openwrt/svn-archive/archive.git] / package / kernel / gpio-button-hotplug / src / gpio-button-hotplug.c
index 780736c89bb66c1904a718514f10ec7ad6b47813..0ebe6c55767e642a77d0e5e78d7e36741d1b8476 100644 (file)
@@ -96,12 +96,13 @@ static struct bh_map button_map[] = {
        BH_MAP(KEY_RESTART,     "reset"),
        BH_MAP(KEY_RFKILL,      "rfkill"),
        BH_MAP(KEY_WPS_BUTTON,  "wps"),
+       BH_MAP(KEY_WIMAX,       "wwan"),
 };
 
 /* -------------------------------------------------------------------------*/
 
-static int bh_event_add_var(struct bh_event *event, int argv,
-               const char *format, ...)
+static __printf(3, 4)
+int bh_event_add_var(struct bh_event *event, int argv, const char *format, ...)
 {
        static char buf[128];
        char *s;
@@ -116,8 +117,7 @@ static int bh_event_add_var(struct bh_event *event, int argv,
        va_end(args);
 
        if (len >= sizeof(buf)) {
-               BH_ERR("buffer size too small\n");
-               WARN_ON(1);
+               WARN(1, "buffer size too small");
                return -ENOMEM;
        }
 
@@ -223,7 +223,6 @@ static int button_hotplug_create_event(const char *name, unsigned int type,
 
 /* -------------------------------------------------------------------------*/
 
-#ifdef CONFIG_HOTPLUG
 static int button_get_index(unsigned int code)
 {
        int i;
@@ -255,12 +254,6 @@ static void button_hotplug_event(struct gpio_keys_button_data *data,
                        (seen - priv->seen) / HZ, value);
        priv->seen = seen;
 }
-#else
-static void button_hotplug_event(struct gpio_keys_button_data *data,
-                          unsigned int type, int value)
-{
-}
-#endif /* CONFIG_HOTPLUG */
 
 struct gpio_keys_button_dev {
        int polled;
@@ -390,7 +383,18 @@ gpio_keys_get_devtree_pdata(struct device *dev)
                button = &pdata->buttons[i++];
 
                button->gpio = of_get_gpio_flags(pp, 0, &flags);
-               button->active_low = flags & OF_GPIO_ACTIVE_LOW;
+               if (button->gpio < 0) {
+                       error = button->gpio;
+                       if (error != -ENOENT) {
+                               if (error != -EPROBE_DEFER)
+                                       dev_err(dev,
+                                               "Failed to get gpio flags, error: %d\n",
+                                               error);
+                               return ERR_PTR(error);
+                       }
+               } else {
+                       button->active_low = flags & OF_GPIO_ACTIVE_LOW;
+               }
 
                if (of_property_read_u32(pp, "linux,code", &button->code)) {
                        dev_err(dev, "Button without keycode: 0x%x\n",
@@ -551,20 +555,17 @@ static int gpio_keys_probe(struct platform_device *pdev)
                struct gpio_keys_button *button = &pdata->buttons[i];
                struct gpio_keys_button_data *bdata = &bdev->data[i];
 
-               if (bdata->can_sleep) {
-                       dev_err(&pdev->dev, "skipping gpio:%d, it can sleep\n", button->gpio);
-                       continue;
-               }
                if (!button->irq)
                        button->irq = gpio_to_irq(button->gpio);
                if (button->irq < 0) {
                        dev_err(&pdev->dev, "failed to get irq for gpio:%d\n", button->gpio);
                        continue;
                }
-               ret = devm_request_irq(&pdev->dev, button->irq, button_handle_irq,
-                                       IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-                                       dev_name(&pdev->dev), bdata);
-               if (ret)
+
+               ret = devm_request_threaded_irq(&pdev->dev, button->irq, NULL, button_handle_irq,
+                                               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+                                               dev_name(&pdev->dev), bdata);
+               if (ret < 0)
                        dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n", button->irq, button->gpio);
                else
                        dev_dbg(&pdev->dev, "gpio:%d has irq:%d\n", button->gpio, button->irq);