aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2012-06-10 15:16:19 +0200
committerHumberto Borba <humberos@gmail.com>2013-01-12 21:04:47 -0200
commitfa55868d01e4058d2a8b864c7139a75300f664c0 (patch)
tree44e0cd9462be8b023c2cd41e57eed4a05b340ca5 /drivers/hid
parentee038486f733ed69cf7e4c08c43c1afd54395e66 (diff)
downloadkernel_samsung_smdk4412-fa55868d01e4058d2a8b864c7139a75300f664c0.zip
kernel_samsung_smdk4412-fa55868d01e4058d2a8b864c7139a75300f664c0.tar.gz
kernel_samsung_smdk4412-fa55868d01e4058d2a8b864c7139a75300f664c0.tar.bz2
HID: uhid: allow feeding input data into uhid devices
This adds a new event type UHID_INPUT which allows user-space to feed raw HID reports into the HID subsystem. We copy the data into kernel memory and directly feed it into the HID core. There is no error handling of the events couldn't be parsed so user-space should consider all events successfull unless read() returns an error. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/uhid.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 61ee7cc..3d1ebda 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -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;
@@ -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;
}