aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/uhid.c14
-rw-r--r--include/linux/uhid.h9
2 files changed, 23 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
213static 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
213static int uhid_char_open(struct inode *inode, struct file *file) 224static 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 }
diff --git a/include/linux/uhid.h b/include/linux/uhid.h
index 8a493e604a77..6eb42bea86a2 100644
--- a/include/linux/uhid.h
+++ b/include/linux/uhid.h
@@ -25,6 +25,7 @@
25enum uhid_event_type { 25enum uhid_event_type {
26 UHID_CREATE, 26 UHID_CREATE,
27 UHID_DESTROY, 27 UHID_DESTROY,
28 UHID_INPUT,
28}; 29};
29 30
30struct uhid_create_req { 31struct uhid_create_req {
@@ -41,11 +42,19 @@ struct uhid_create_req {
41 __u32 country; 42 __u32 country;
42} __attribute__((__packed__)); 43} __attribute__((__packed__));
43 44
45#define UHID_DATA_MAX 4096
46
47struct uhid_input_req {
48 __u8 data[UHID_DATA_MAX];
49 __u16 size;
50} __attribute__((__packed__));
51
44struct uhid_event { 52struct uhid_event {
45 __u32 type; 53 __u32 type;
46 54
47 union { 55 union {
48 struct uhid_create_req create; 56 struct uhid_create_req create;
57 struct uhid_input_req input;
49 } u; 58 } u;
50} __attribute__((__packed__)); 59} __attribute__((__packed__));
51 60