diff options
author | David Herrmann <dh.herrmann@googlemail.com> | 2012-06-10 09:16:19 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-06-18 07:42:01 -0400 |
commit | 5e87a36ae375297b71cc21ac7e32846832bcfb34 (patch) | |
tree | 4f5d355092d58e4690f99ced40bc4efceab0ab40 /drivers/hid | |
parent | d365c6cfd337a2bccdc65eacce271a311ea1072c (diff) |
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.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 61ee7cc32ccf..3d1ebda122e5 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c | |||
@@ -210,6 +210,17 @@ static int uhid_dev_destroy(struct uhid_device *uhid) | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev) | ||
214 | { | ||
215 | if (!uhid->running) | ||
216 | return -EINVAL; | ||
217 | |||
218 | hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data, | ||
219 | min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0); | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
213 | static int uhid_char_open(struct inode *inode, struct file *file) | 224 | static int uhid_char_open(struct inode *inode, struct file *file) |
214 | { | 225 | { |
215 | struct uhid_device *uhid; | 226 | struct uhid_device *uhid; |
@@ -321,6 +332,9 @@ static ssize_t uhid_char_write(struct file *file, const char __user *buffer, | |||
321 | case UHID_DESTROY: | 332 | case UHID_DESTROY: |
322 | ret = uhid_dev_destroy(uhid); | 333 | ret = uhid_dev_destroy(uhid); |
323 | break; | 334 | break; |
335 | case UHID_INPUT: | ||
336 | ret = uhid_dev_input(uhid, &uhid->input_buf); | ||
337 | break; | ||
324 | default: | 338 | default: |
325 | ret = -EOPNOTSUPP; | 339 | ret = -EOPNOTSUPP; |
326 | } | 340 | } |