gpio-button-hotplug: add support for sliding switches
authorJohn Crispin <john@openwrt.org>
Mon, 11 Nov 2013 12:19:06 +0000 (12:19 +0000)
committerJohn Crispin <john@openwrt.org>
Mon, 11 Nov 2013 12:19:06 +0000 (12:19 +0000)
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 38725

package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c

index 927f37dccf2f12cd251647d3879a2a811ee86432..19621d96d43adf3aac82d709a951173aa908022d 100644 (file)
@@ -141,17 +141,7 @@ static int button_hotplug_fill_event(struct bh_event *event)
        if (ret)
                return ret;
 
-       switch (event->type) {
-               case EV_SW:
-                       s = "switch";
-                       break;
-               case EV_KEY:
-               default:
-                       s = "button";
-                       break;
-       }
-
-       ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", s);
+       ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
        if (ret)
                return ret;
 
@@ -163,6 +153,12 @@ static int button_hotplug_fill_event(struct bh_event *event)
        if (ret)
                return ret;
 
+       if (event->type == EV_SW) {
+               ret = bh_event_add_var(event, 0, "TYPE=%s", "switch");
+               if (ret)
+                       return ret;
+       }
+
        ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
        if (ret)
                return ret;
@@ -299,7 +295,7 @@ static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
                        return;
                }
 
-               if (bdata->last_state != -1)
+               if ((bdata->last_state != -1) || (type == EV_SW))
                        button_hotplug_event(bdata, type, button->code, state);
 
                bdata->last_state = state;