]> Pileus Git - ~andy/linux/commitdiff
HID: uhid: forward open/close events to user-space
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 10 Jun 2012 13:16:22 +0000 (15:16 +0200)
committerJiri Kosina <jkosina@suse.cz>
Mon, 18 Jun 2012 11:42:02 +0000 (13:42 +0200)
HID core notifies us with *_open/*_close callbacks when there is an actual
user of our device. We forward these to user-space so they can react on
this. This allows user-space to skip I/O unless they receive an OPEN
event. When they receive a CLOSE event they can stop I/O again to save
energy.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/uhid.c
include/linux/uhid.h

index 2e7f3a02397539aa799ff00b87eb61c82f652e5e..0226ba3f5307009384e6755e10d0ca83092e2090 100644 (file)
@@ -97,11 +97,16 @@ static void uhid_hid_stop(struct hid_device *hid)
 
 static int uhid_hid_open(struct hid_device *hid)
 {
-       return 0;
+       struct uhid_device *uhid = hid->driver_data;
+
+       return uhid_queue_event(uhid, UHID_OPEN);
 }
 
 static void uhid_hid_close(struct hid_device *hid)
 {
+       struct uhid_device *uhid = hid->driver_data;
+
+       uhid_queue_event(uhid, UHID_CLOSE);
 }
 
 static int uhid_hid_input(struct input_dev *input, unsigned int type,
index f8ce6f7571d858129d750846bdac056c1c67d2ee..351650b7a0f69622f53121f5626de2fe6ee2d019 100644 (file)
@@ -27,6 +27,8 @@ enum uhid_event_type {
        UHID_DESTROY,
        UHID_START,
        UHID_STOP,
+       UHID_OPEN,
+       UHID_CLOSE,
        UHID_INPUT,
 };