Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316076
b: refs/heads/master
c: 3b3baa8
h: refs/heads/master
v: v3
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jun 18, 2012
1 parent b6bab5c commit 88edf46
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f80e13601c51a836b2aac583b8a3b4327c0c27ce
refs/heads/master: 3b3baa82e4306b5160692643fab2fa322ceb94f9
34 changes: 33 additions & 1 deletion trunk/drivers/hid/uhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,39 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
static int uhid_hid_output_raw(struct hid_device *hid, __u8 *buf, size_t count,
unsigned char report_type)
{
return 0;
struct uhid_device *uhid = hid->driver_data;
__u8 rtype;
unsigned long flags;
struct uhid_event *ev;

switch (report_type) {
case HID_FEATURE_REPORT:
rtype = UHID_FEATURE_REPORT;
break;
case HID_OUTPUT_REPORT:
rtype = UHID_OUTPUT_REPORT;
break;
default:
return -EINVAL;
}

if (count < 1 || count > UHID_DATA_MAX)
return -EINVAL;

ev = kzalloc(sizeof(*ev), GFP_KERNEL);
if (!ev)
return -ENOMEM;

ev->type = UHID_OUTPUT;
ev->u.output.size = count;
ev->u.output.rtype = rtype;
memcpy(ev->u.output.data, buf, count);

spin_lock_irqsave(&uhid->qlock, flags);
uhid_queue(uhid, ev);
spin_unlock_irqrestore(&uhid->qlock, flags);

return count;
}

static struct hid_ll_driver uhid_hid_driver = {
Expand Down
14 changes: 14 additions & 0 deletions trunk/include/linux/uhid.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum uhid_event_type {
UHID_STOP,
UHID_OPEN,
UHID_CLOSE,
UHID_OUTPUT,
UHID_OUTPUT_EV,
UHID_INPUT,
};
Expand All @@ -49,11 +50,23 @@ struct uhid_create_req {

#define UHID_DATA_MAX 4096

enum uhid_report_type {
UHID_FEATURE_REPORT,
UHID_OUTPUT_REPORT,
UHID_INPUT_REPORT,
};

struct uhid_input_req {
__u8 data[UHID_DATA_MAX];
__u16 size;
} __attribute__((__packed__));

struct uhid_output_req {
__u8 data[UHID_DATA_MAX];
__u16 size;
__u8 rtype;
} __attribute__((__packed__));

struct uhid_output_ev_req {
__u16 type;
__u16 code;
Expand All @@ -66,6 +79,7 @@ struct uhid_event {
union {
struct uhid_create_req create;
struct uhid_input_req input;
struct uhid_output_req output;
struct uhid_output_ev_req output_ev;
} u;
} __attribute__((__packed__));
Expand Down

0 comments on commit 88edf46

Please sign in to comment.