struct bh_event {
const char *name;
+ unsigned int type;
char *action;
unsigned long seen;
BH_MAP(BTN_9, "BTN_9"),
BH_MAP(KEY_RESTART, "reset"),
BH_MAP(KEY_RFKILL, "rfkill"),
-#ifdef KEY_WPS_BUTTON
BH_MAP(KEY_WPS_BUTTON, "wps"),
-#endif /* KEY_WPS_BUTTON */
};
/* -------------------------------------------------------------------------*/
if (ret)
return ret;
- ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
+ char *s;
+ switch (event->type) {
+ case EV_KEY:
+ s = "button";
+ break;
+ case EV_SW:
+ s = "switch";
+ break;
+ default:
+ s = "button";
+ break;
+ }
+
+ ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", s);
if (ret)
return ret;
kfree(event);
}
-static int button_hotplug_create_event(const char *name, unsigned long seen,
- int pressed)
+static int button_hotplug_create_event(const char *name, unsigned int type,
+ unsigned long seen, int pressed)
{
struct bh_event *event;
return -ENOMEM;
event->name = name;
+ event->type = type;
event->seen = seen;
event->action = pressed ? "pressed" : "released";
return -1;
}
+
static void button_hotplug_event(struct gpio_keys_button_data *data,
unsigned int type, unsigned int code, int value)
{
BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
- if (type != EV_KEY)
+ if ((type != EV_KEY) && (type != EV_SW))
return;
btn = button_get_index(code);
if (btn < 0)
return;
- button_hotplug_create_event(button_map[btn].name,
+ button_hotplug_create_event(button_map[btn].name, type,
(seen - priv->seen) / HZ, value);
priv->seen = seen;
}