Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316071
b: refs/heads/master
c: 5e87a36
h: refs/heads/master
i:
  316069: 5be1675
  316067: 4c573bf
  316063: 76f65ef
v: v3
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jun 18, 2012
1 parent b5a1b30 commit 6a22dfd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d365c6cfd337a2bccdc65eacce271a311ea1072c
refs/heads/master: 5e87a36ae375297b71cc21ac7e32846832bcfb34
14 changes: 14 additions & 0 deletions trunk/drivers/hid/uhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ static int uhid_dev_destroy(struct uhid_device *uhid)
return 0;
}

static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
{
if (!uhid->running)
return -EINVAL;

hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data,
min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0);

return 0;
}

static int uhid_char_open(struct inode *inode, struct file *file)
{
struct uhid_device *uhid;
Expand Down Expand Up @@ -321,6 +332,9 @@ static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
case UHID_DESTROY:
ret = uhid_dev_destroy(uhid);
break;
case UHID_INPUT:
ret = uhid_dev_input(uhid, &uhid->input_buf);
break;
default:
ret = -EOPNOTSUPP;
}
Expand Down
9 changes: 9 additions & 0 deletions trunk/include/linux/uhid.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
enum uhid_event_type {
UHID_CREATE,
UHID_DESTROY,
UHID_INPUT,
};

struct uhid_create_req {
Expand All @@ -41,11 +42,19 @@ struct uhid_create_req {
__u32 country;
} __attribute__((__packed__));

#define UHID_DATA_MAX 4096

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

struct uhid_event {
__u32 type;

union {
struct uhid_create_req create;
struct uhid_input_req input;
} u;
} __attribute__((__packed__));

Expand Down

0 comments on commit 6a22dfd

Please sign in to comment.