summaryrefslogtreecommitdiff
path: root/package/kernel/gpio-button-hotplug
diff options
context:
space:
mode:
authorluka <luka@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-07-02 10:45:31 +0000
committerluka <luka@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-07-02 10:45:31 +0000
commit87f464a94b3c2e0cd7a557bbf30c8158f79a56cb (patch)
tree440e0e61a4f1f42d429e875a92aa93d627a9fe5d /package/kernel/gpio-button-hotplug
parentb03ea591ccb19ca2ab7f661c8197c9657cd74cc8 (diff)
gpio-button-hotplug: add support for EV_SW
Signed-off-by: Luka Perkov <luka@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@37130 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/kernel/gpio-button-hotplug')
-rw-r--r--package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
index 412c045fe4..0b3140c0bf 100644
--- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
+++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
@@ -49,6 +49,7 @@ struct bh_priv {
struct bh_event {
const char *name;
+ unsigned int type;
char *action;
unsigned long seen;
@@ -91,9 +92,7 @@ static struct bh_map button_map[] = {
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 */
};
/* -------------------------------------------------------------------------*/
@@ -140,7 +139,20 @@ static int button_hotplug_fill_event(struct bh_event *event)
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;
@@ -190,8 +202,8 @@ static void button_hotplug_work(struct work_struct *work)
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;
@@ -203,6 +215,7 @@ static int button_hotplug_create_event(const char *name, unsigned long seen,
return -ENOMEM;
event->name = name;
+ event->type = type;
event->seen = seen;
event->action = pressed ? "pressed" : "released";
@@ -225,6 +238,7 @@ static int button_get_index(unsigned int code)
return -1;
}
+
static void button_hotplug_event(struct gpio_keys_button_data *data,
unsigned int type, unsigned int code, int value)
{
@@ -234,14 +248,14 @@ static void button_hotplug_event(struct gpio_keys_button_data *data,
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;
}