Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316069
b: refs/heads/master
c: 6664ef7
h: refs/heads/master
i:
  316067: 4c573bf
v: v3
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jun 18, 2012
1 parent b3e6cdf commit 5be1675
Show file tree
Hide file tree
Showing 2 changed files with 31 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: d937ae5fae17e63aaa97f029be221a6516b25475
refs/heads/master: 6664ef72a47459f883d3409ca9b2fa200015704b
31 changes: 30 additions & 1 deletion trunk/drivers/hid/uhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
struct uhid_device {
struct mutex devlock;
struct hid_device *hid;
struct uhid_event input_buf;

wait_queue_head_t waitq;
spinlock_t qlock;
Expand Down Expand Up @@ -156,7 +157,35 @@ static ssize_t uhid_char_read(struct file *file, char __user *buffer,
static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
return 0;
struct uhid_device *uhid = file->private_data;
int ret;
size_t len;

/* we need at least the "type" member of uhid_event */
if (count < sizeof(__u32))
return -EINVAL;

ret = mutex_lock_interruptible(&uhid->devlock);
if (ret)
return ret;

memset(&uhid->input_buf, 0, sizeof(uhid->input_buf));
len = min(count, sizeof(uhid->input_buf));
if (copy_from_user(&uhid->input_buf, buffer, len)) {
ret = -EFAULT;
goto unlock;
}

switch (uhid->input_buf.type) {
default:
ret = -EOPNOTSUPP;
}

unlock:
mutex_unlock(&uhid->devlock);

/* return "count" not "len" to not confuse the caller */
return ret ? ret : count;
}

static unsigned int uhid_char_poll(struct file *file, poll_table *wait)
Expand Down

0 comments on commit 5be1675

Please sign in to comment.