diff mbox

[RFC,v2,2/4] HID: uhid: Handle LED input events

Message ID 1354388841-23854-3-git-send-email-andre.guedes@openbossa.org (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Andre Guedes Dec. 1, 2012, 7:07 p.m. UTC
This patch adds support for handling LED input events in uhid driver.
Others input events are sent to userspace as UHID_OUTPUT_EV events.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 drivers/hid/uhid.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 714cd8c..a5cf905 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -122,21 +122,31 @@  static int uhid_hid_input(struct input_dev *input, unsigned int type,
 	struct uhid_device *uhid = hid->driver_data;
 	unsigned long flags;
 	struct uhid_event *ev;
+	int ret;
 
-	ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
-	if (!ev)
-		return -ENOMEM;
+	switch (type) {
+	case EV_LED:
+		ret = hidinput_led_output_report(hid, code, value);
+		break;
 
-	ev->type = UHID_OUTPUT_EV;
-	ev->u.output_ev.type = type;
-	ev->u.output_ev.code = code;
-	ev->u.output_ev.value = value;
+	default:
+		ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
+		if (!ev)
+			return -ENOMEM;
 
-	spin_lock_irqsave(&uhid->qlock, flags);
-	uhid_queue(uhid, ev);
-	spin_unlock_irqrestore(&uhid->qlock, flags);
+		ev->type = UHID_OUTPUT_EV;
+		ev->u.output_ev.type = type;
+		ev->u.output_ev.code = code;
+		ev->u.output_ev.value = value;
 
-	return 0;
+		spin_lock_irqsave(&uhid->qlock, flags);
+		uhid_queue(uhid, ev);
+		spin_unlock_irqrestore(&uhid->qlock, flags);
+
+		ret = 0;
+	}
+
+	return ret;
 }
 
 static int uhid_hid_parse(struct hid_device *hid)