David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 1 | /* |
| 2 | * User-space I/O driver support for HID subsystem |
| 3 | * Copyright (c) 2012 David Herrmann |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/atomic.h> |
Dmitry Torokhov | befde02 | 2013-02-18 11:26:11 +0100 | [diff] [blame] | 14 | #include <linux/compat.h> |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 15 | #include <linux/device.h> |
| 16 | #include <linux/fs.h> |
| 17 | #include <linux/hid.h> |
| 18 | #include <linux/input.h> |
| 19 | #include <linux/miscdevice.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/mutex.h> |
| 22 | #include <linux/poll.h> |
| 23 | #include <linux/sched.h> |
| 24 | #include <linux/spinlock.h> |
| 25 | #include <linux/uhid.h> |
| 26 | #include <linux/wait.h> |
| 27 | |
| 28 | #define UHID_NAME "uhid" |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 29 | #define UHID_BUFSIZE 32 |
| 30 | |
Dmitry Torokhov | 9835098 | 2017-05-30 14:46:26 -0700 | [diff] [blame] | 31 | static DEFINE_MUTEX(uhid_open_mutex); |
| 32 | |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 33 | struct uhid_device { |
David Herrmann | d937ae5 | 2012-06-10 15:16:16 +0200 | [diff] [blame] | 34 | struct mutex devlock; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 35 | bool running; |
| 36 | |
| 37 | __u8 *rd_data; |
| 38 | uint rd_size; |
| 39 | |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 40 | struct hid_device *hid; |
David Herrmann | 6664ef7 | 2012-06-10 15:16:17 +0200 | [diff] [blame] | 41 | struct uhid_event input_buf; |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 42 | |
| 43 | wait_queue_head_t waitq; |
| 44 | spinlock_t qlock; |
| 45 | __u8 head; |
| 46 | __u8 tail; |
| 47 | struct uhid_event *outq[UHID_BUFSIZE]; |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 48 | |
David Herrmann | 8cad5b0 | 2014-07-29 17:14:19 +0200 | [diff] [blame] | 49 | /* blocking GET_REPORT support; state changes protected by qlock */ |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 50 | struct mutex report_lock; |
| 51 | wait_queue_head_t report_wait; |
David Herrmann | 5942b84 | 2014-07-29 17:14:20 +0200 | [diff] [blame] | 52 | bool report_running; |
David Herrmann | 8cad5b0 | 2014-07-29 17:14:19 +0200 | [diff] [blame] | 53 | u32 report_id; |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 54 | u32 report_type; |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 55 | struct uhid_event report_buf; |
Roderick Colenbrander | 67f8ecc | 2016-05-18 13:11:09 -0700 | [diff] [blame] | 56 | struct work_struct worker; |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 57 | }; |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 58 | |
| 59 | static struct miscdevice uhid_misc; |
| 60 | |
Roderick Colenbrander | 67f8ecc | 2016-05-18 13:11:09 -0700 | [diff] [blame] | 61 | static void uhid_device_add_worker(struct work_struct *work) |
| 62 | { |
| 63 | struct uhid_device *uhid = container_of(work, struct uhid_device, worker); |
| 64 | int ret; |
| 65 | |
| 66 | ret = hid_add_device(uhid->hid); |
| 67 | if (ret) { |
| 68 | hid_err(uhid->hid, "Cannot register HID device: error %d\n", ret); |
| 69 | |
| 70 | hid_destroy_device(uhid->hid); |
| 71 | uhid->hid = NULL; |
| 72 | uhid->running = false; |
| 73 | } |
| 74 | } |
| 75 | |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 76 | static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev) |
| 77 | { |
| 78 | __u8 newhead; |
| 79 | |
| 80 | newhead = (uhid->head + 1) % UHID_BUFSIZE; |
| 81 | |
| 82 | if (newhead != uhid->tail) { |
| 83 | uhid->outq[uhid->head] = ev; |
| 84 | uhid->head = newhead; |
| 85 | wake_up_interruptible(&uhid->waitq); |
| 86 | } else { |
| 87 | hid_warn(uhid->hid, "Output queue is full\n"); |
| 88 | kfree(ev); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | static int uhid_queue_event(struct uhid_device *uhid, __u32 event) |
| 93 | { |
| 94 | unsigned long flags; |
| 95 | struct uhid_event *ev; |
| 96 | |
| 97 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
| 98 | if (!ev) |
| 99 | return -ENOMEM; |
| 100 | |
| 101 | ev->type = event; |
| 102 | |
| 103 | spin_lock_irqsave(&uhid->qlock, flags); |
| 104 | uhid_queue(uhid, ev); |
| 105 | spin_unlock_irqrestore(&uhid->qlock, flags); |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 110 | static int uhid_hid_start(struct hid_device *hid) |
| 111 | { |
David Herrmann | ec4b7de | 2012-06-10 15:16:21 +0200 | [diff] [blame] | 112 | struct uhid_device *uhid = hid->driver_data; |
David Herrmann | c2b2f16 | 2014-07-29 17:14:25 +0200 | [diff] [blame] | 113 | struct uhid_event *ev; |
| 114 | unsigned long flags; |
David Herrmann | ec4b7de | 2012-06-10 15:16:21 +0200 | [diff] [blame] | 115 | |
David Herrmann | c2b2f16 | 2014-07-29 17:14:25 +0200 | [diff] [blame] | 116 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
| 117 | if (!ev) |
| 118 | return -ENOMEM; |
| 119 | |
| 120 | ev->type = UHID_START; |
| 121 | |
| 122 | if (hid->report_enum[HID_FEATURE_REPORT].numbered) |
| 123 | ev->u.start.dev_flags |= UHID_DEV_NUMBERED_FEATURE_REPORTS; |
| 124 | if (hid->report_enum[HID_OUTPUT_REPORT].numbered) |
| 125 | ev->u.start.dev_flags |= UHID_DEV_NUMBERED_OUTPUT_REPORTS; |
| 126 | if (hid->report_enum[HID_INPUT_REPORT].numbered) |
| 127 | ev->u.start.dev_flags |= UHID_DEV_NUMBERED_INPUT_REPORTS; |
| 128 | |
| 129 | spin_lock_irqsave(&uhid->qlock, flags); |
| 130 | uhid_queue(uhid, ev); |
| 131 | spin_unlock_irqrestore(&uhid->qlock, flags); |
| 132 | |
| 133 | return 0; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | static void uhid_hid_stop(struct hid_device *hid) |
| 137 | { |
David Herrmann | ec4b7de | 2012-06-10 15:16:21 +0200 | [diff] [blame] | 138 | struct uhid_device *uhid = hid->driver_data; |
| 139 | |
| 140 | hid->claimed = 0; |
| 141 | uhid_queue_event(uhid, UHID_STOP); |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static int uhid_hid_open(struct hid_device *hid) |
| 145 | { |
David Herrmann | e719147 | 2012-06-10 15:16:22 +0200 | [diff] [blame] | 146 | struct uhid_device *uhid = hid->driver_data; |
Dmitry Torokhov | 9835098 | 2017-05-30 14:46:26 -0700 | [diff] [blame] | 147 | int retval = 0; |
David Herrmann | e719147 | 2012-06-10 15:16:22 +0200 | [diff] [blame] | 148 | |
Dmitry Torokhov | 9835098 | 2017-05-30 14:46:26 -0700 | [diff] [blame] | 149 | mutex_lock(&uhid_open_mutex); |
| 150 | if (!hid->open++) { |
| 151 | retval = uhid_queue_event(uhid, UHID_OPEN); |
| 152 | if (retval) |
| 153 | hid->open--; |
| 154 | } |
| 155 | mutex_unlock(&uhid_open_mutex); |
| 156 | return retval; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | static void uhid_hid_close(struct hid_device *hid) |
| 160 | { |
David Herrmann | e719147 | 2012-06-10 15:16:22 +0200 | [diff] [blame] | 161 | struct uhid_device *uhid = hid->driver_data; |
| 162 | |
Dmitry Torokhov | 9835098 | 2017-05-30 14:46:26 -0700 | [diff] [blame] | 163 | mutex_lock(&uhid_open_mutex); |
| 164 | if (!--hid->open) |
| 165 | uhid_queue_event(uhid, UHID_CLOSE); |
| 166 | mutex_unlock(&uhid_open_mutex); |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 167 | } |
| 168 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 169 | static int uhid_hid_parse(struct hid_device *hid) |
| 170 | { |
David Herrmann | 037c061 | 2012-06-10 15:16:20 +0200 | [diff] [blame] | 171 | struct uhid_device *uhid = hid->driver_data; |
| 172 | |
| 173 | return hid_parse_report(hid, uhid->rd_data, uhid->rd_size); |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 174 | } |
| 175 | |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 176 | /* must be called with report_lock held */ |
| 177 | static int __uhid_report_queue_and_wait(struct uhid_device *uhid, |
| 178 | struct uhid_event *ev, |
| 179 | __u32 *report_id) |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 180 | { |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 181 | unsigned long flags; |
| 182 | int ret; |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 183 | |
| 184 | spin_lock_irqsave(&uhid->qlock, flags); |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 185 | *report_id = ++uhid->report_id; |
Benjamin Tissoires | 8493ecc | 2014-10-01 11:59:47 -0400 | [diff] [blame] | 186 | uhid->report_type = ev->type + 1; |
David Herrmann | 5942b84 | 2014-07-29 17:14:20 +0200 | [diff] [blame] | 187 | uhid->report_running = true; |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 188 | uhid_queue(uhid, ev); |
| 189 | spin_unlock_irqrestore(&uhid->qlock, flags); |
| 190 | |
| 191 | ret = wait_event_interruptible_timeout(uhid->report_wait, |
David Herrmann | 5942b84 | 2014-07-29 17:14:20 +0200 | [diff] [blame] | 192 | !uhid->report_running || !uhid->running, |
| 193 | 5 * HZ); |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 194 | if (!ret || !uhid->running || uhid->report_running) |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 195 | ret = -EIO; |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 196 | else if (ret < 0) |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 197 | ret = -ERESTARTSYS; |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 198 | else |
| 199 | ret = 0; |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 200 | |
David Herrmann | 5942b84 | 2014-07-29 17:14:20 +0200 | [diff] [blame] | 201 | uhid->report_running = false; |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 202 | |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 203 | return ret; |
| 204 | } |
| 205 | |
| 206 | static void uhid_report_wake_up(struct uhid_device *uhid, u32 id, |
| 207 | const struct uhid_event *ev) |
| 208 | { |
| 209 | unsigned long flags; |
| 210 | |
| 211 | spin_lock_irqsave(&uhid->qlock, flags); |
| 212 | |
| 213 | /* id for old report; drop it silently */ |
| 214 | if (uhid->report_type != ev->type || uhid->report_id != id) |
| 215 | goto unlock; |
| 216 | if (!uhid->report_running) |
| 217 | goto unlock; |
| 218 | |
| 219 | memcpy(&uhid->report_buf, ev, sizeof(*ev)); |
| 220 | uhid->report_running = false; |
| 221 | wake_up_interruptible(&uhid->report_wait); |
| 222 | |
| 223 | unlock: |
| 224 | spin_unlock_irqrestore(&uhid->qlock, flags); |
| 225 | } |
| 226 | |
| 227 | static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum, |
| 228 | u8 *buf, size_t count, u8 rtype) |
| 229 | { |
| 230 | struct uhid_device *uhid = hid->driver_data; |
| 231 | struct uhid_get_report_reply_req *req; |
| 232 | struct uhid_event *ev; |
| 233 | int ret; |
| 234 | |
| 235 | if (!uhid->running) |
| 236 | return -EIO; |
| 237 | |
| 238 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
| 239 | if (!ev) |
| 240 | return -ENOMEM; |
| 241 | |
| 242 | ev->type = UHID_GET_REPORT; |
| 243 | ev->u.get_report.rnum = rnum; |
| 244 | ev->u.get_report.rtype = rtype; |
| 245 | |
| 246 | ret = mutex_lock_interruptible(&uhid->report_lock); |
| 247 | if (ret) { |
| 248 | kfree(ev); |
| 249 | return ret; |
| 250 | } |
| 251 | |
| 252 | /* this _always_ takes ownership of @ev */ |
| 253 | ret = __uhid_report_queue_and_wait(uhid, ev, &ev->u.get_report.id); |
| 254 | if (ret) |
| 255 | goto unlock; |
| 256 | |
| 257 | req = &uhid->report_buf.u.get_report_reply; |
| 258 | if (req->err) { |
| 259 | ret = -EIO; |
| 260 | } else { |
| 261 | ret = min3(count, (size_t)req->size, (size_t)UHID_DATA_MAX); |
| 262 | memcpy(buf, req->data, ret); |
| 263 | } |
| 264 | |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 265 | unlock: |
| 266 | mutex_unlock(&uhid->report_lock); |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 267 | return ret; |
| 268 | } |
| 269 | |
| 270 | static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum, |
| 271 | const u8 *buf, size_t count, u8 rtype) |
| 272 | { |
| 273 | struct uhid_device *uhid = hid->driver_data; |
| 274 | struct uhid_event *ev; |
| 275 | int ret; |
| 276 | |
| 277 | if (!uhid->running || count > UHID_DATA_MAX) |
| 278 | return -EIO; |
| 279 | |
| 280 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
| 281 | if (!ev) |
| 282 | return -ENOMEM; |
| 283 | |
| 284 | ev->type = UHID_SET_REPORT; |
| 285 | ev->u.set_report.rnum = rnum; |
| 286 | ev->u.set_report.rtype = rtype; |
| 287 | ev->u.set_report.size = count; |
| 288 | memcpy(ev->u.set_report.data, buf, count); |
| 289 | |
| 290 | ret = mutex_lock_interruptible(&uhid->report_lock); |
| 291 | if (ret) { |
| 292 | kfree(ev); |
| 293 | return ret; |
| 294 | } |
| 295 | |
| 296 | /* this _always_ takes ownership of @ev */ |
| 297 | ret = __uhid_report_queue_and_wait(uhid, ev, &ev->u.set_report.id); |
| 298 | if (ret) |
| 299 | goto unlock; |
| 300 | |
| 301 | if (uhid->report_buf.u.set_report_reply.err) |
| 302 | ret = -EIO; |
| 303 | else |
| 304 | ret = count; |
| 305 | |
| 306 | unlock: |
| 307 | mutex_unlock(&uhid->report_lock); |
| 308 | return ret; |
Jiri Kosina | 289a716 | 2014-02-17 14:49:34 +0100 | [diff] [blame] | 309 | } |
| 310 | |
David Herrmann | 7c4003b | 2014-07-29 17:14:23 +0200 | [diff] [blame] | 311 | static int uhid_hid_raw_request(struct hid_device *hid, unsigned char reportnum, |
| 312 | __u8 *buf, size_t len, unsigned char rtype, |
| 313 | int reqtype) |
| 314 | { |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 315 | u8 u_rtype; |
| 316 | |
| 317 | switch (rtype) { |
| 318 | case HID_FEATURE_REPORT: |
| 319 | u_rtype = UHID_FEATURE_REPORT; |
| 320 | break; |
| 321 | case HID_OUTPUT_REPORT: |
| 322 | u_rtype = UHID_OUTPUT_REPORT; |
| 323 | break; |
| 324 | case HID_INPUT_REPORT: |
| 325 | u_rtype = UHID_INPUT_REPORT; |
| 326 | break; |
| 327 | default: |
| 328 | return -EINVAL; |
| 329 | } |
| 330 | |
David Herrmann | 7c4003b | 2014-07-29 17:14:23 +0200 | [diff] [blame] | 331 | switch (reqtype) { |
| 332 | case HID_REQ_GET_REPORT: |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 333 | return uhid_hid_get_report(hid, reportnum, buf, len, u_rtype); |
David Herrmann | 7c4003b | 2014-07-29 17:14:23 +0200 | [diff] [blame] | 334 | case HID_REQ_SET_REPORT: |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 335 | return uhid_hid_set_report(hid, reportnum, buf, len, u_rtype); |
David Herrmann | 7c4003b | 2014-07-29 17:14:23 +0200 | [diff] [blame] | 336 | default: |
| 337 | return -EIO; |
| 338 | } |
| 339 | } |
| 340 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 341 | static int uhid_hid_output_raw(struct hid_device *hid, __u8 *buf, size_t count, |
| 342 | unsigned char report_type) |
| 343 | { |
David Herrmann | 3b3baa8 | 2012-06-10 15:16:24 +0200 | [diff] [blame] | 344 | struct uhid_device *uhid = hid->driver_data; |
| 345 | __u8 rtype; |
| 346 | unsigned long flags; |
| 347 | struct uhid_event *ev; |
| 348 | |
| 349 | switch (report_type) { |
| 350 | case HID_FEATURE_REPORT: |
| 351 | rtype = UHID_FEATURE_REPORT; |
| 352 | break; |
| 353 | case HID_OUTPUT_REPORT: |
| 354 | rtype = UHID_OUTPUT_REPORT; |
| 355 | break; |
| 356 | default: |
| 357 | return -EINVAL; |
| 358 | } |
| 359 | |
| 360 | if (count < 1 || count > UHID_DATA_MAX) |
| 361 | return -EINVAL; |
| 362 | |
| 363 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
| 364 | if (!ev) |
| 365 | return -ENOMEM; |
| 366 | |
| 367 | ev->type = UHID_OUTPUT; |
| 368 | ev->u.output.size = count; |
| 369 | ev->u.output.rtype = rtype; |
| 370 | memcpy(ev->u.output.data, buf, count); |
| 371 | |
| 372 | spin_lock_irqsave(&uhid->qlock, flags); |
| 373 | uhid_queue(uhid, ev); |
| 374 | spin_unlock_irqrestore(&uhid->qlock, flags); |
| 375 | |
| 376 | return count; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 377 | } |
| 378 | |
Frank Praznik | 596cfdd | 2014-01-22 13:49:43 -0500 | [diff] [blame] | 379 | static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf, |
| 380 | size_t count) |
| 381 | { |
Benjamin Tissoires | 41abfb3 | 2014-02-10 12:58:46 -0500 | [diff] [blame] | 382 | return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT); |
Frank Praznik | 596cfdd | 2014-01-22 13:49:43 -0500 | [diff] [blame] | 383 | } |
| 384 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 385 | static struct hid_ll_driver uhid_hid_driver = { |
| 386 | .start = uhid_hid_start, |
| 387 | .stop = uhid_hid_stop, |
| 388 | .open = uhid_hid_open, |
| 389 | .close = uhid_hid_close, |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 390 | .parse = uhid_hid_parse, |
David Herrmann | 7c4003b | 2014-07-29 17:14:23 +0200 | [diff] [blame] | 391 | .raw_request = uhid_hid_raw_request, |
Frank Praznik | 596cfdd | 2014-01-22 13:49:43 -0500 | [diff] [blame] | 392 | .output_report = uhid_hid_output_report, |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 393 | }; |
| 394 | |
Dmitry Torokhov | befde02 | 2013-02-18 11:26:11 +0100 | [diff] [blame] | 395 | #ifdef CONFIG_COMPAT |
| 396 | |
| 397 | /* Apparently we haven't stepped on these rakes enough times yet. */ |
| 398 | struct uhid_create_req_compat { |
| 399 | __u8 name[128]; |
| 400 | __u8 phys[64]; |
| 401 | __u8 uniq[64]; |
| 402 | |
| 403 | compat_uptr_t rd_data; |
| 404 | __u16 rd_size; |
| 405 | |
| 406 | __u16 bus; |
| 407 | __u32 vendor; |
| 408 | __u32 product; |
| 409 | __u32 version; |
| 410 | __u32 country; |
| 411 | } __attribute__((__packed__)); |
| 412 | |
| 413 | static int uhid_event_from_user(const char __user *buffer, size_t len, |
| 414 | struct uhid_event *event) |
| 415 | { |
Andy Lutomirski | 7365abb | 2016-03-22 14:25:24 -0700 | [diff] [blame] | 416 | if (in_compat_syscall()) { |
Dmitry Torokhov | befde02 | 2013-02-18 11:26:11 +0100 | [diff] [blame] | 417 | u32 type; |
| 418 | |
| 419 | if (get_user(type, buffer)) |
| 420 | return -EFAULT; |
| 421 | |
| 422 | if (type == UHID_CREATE) { |
| 423 | /* |
| 424 | * This is our messed up request with compat pointer. |
| 425 | * It is largish (more than 256 bytes) so we better |
| 426 | * allocate it from the heap. |
| 427 | */ |
| 428 | struct uhid_create_req_compat *compat; |
| 429 | |
David Herrmann | 80897aa | 2013-11-26 13:58:18 +0100 | [diff] [blame] | 430 | compat = kzalloc(sizeof(*compat), GFP_KERNEL); |
Dmitry Torokhov | befde02 | 2013-02-18 11:26:11 +0100 | [diff] [blame] | 431 | if (!compat) |
| 432 | return -ENOMEM; |
| 433 | |
| 434 | buffer += sizeof(type); |
| 435 | len -= sizeof(type); |
| 436 | if (copy_from_user(compat, buffer, |
| 437 | min(len, sizeof(*compat)))) { |
| 438 | kfree(compat); |
| 439 | return -EFAULT; |
| 440 | } |
| 441 | |
| 442 | /* Shuffle the data over to proper structure */ |
| 443 | event->type = type; |
| 444 | |
| 445 | memcpy(event->u.create.name, compat->name, |
| 446 | sizeof(compat->name)); |
| 447 | memcpy(event->u.create.phys, compat->phys, |
| 448 | sizeof(compat->phys)); |
| 449 | memcpy(event->u.create.uniq, compat->uniq, |
| 450 | sizeof(compat->uniq)); |
| 451 | |
| 452 | event->u.create.rd_data = compat_ptr(compat->rd_data); |
| 453 | event->u.create.rd_size = compat->rd_size; |
| 454 | |
| 455 | event->u.create.bus = compat->bus; |
| 456 | event->u.create.vendor = compat->vendor; |
| 457 | event->u.create.product = compat->product; |
| 458 | event->u.create.version = compat->version; |
| 459 | event->u.create.country = compat->country; |
| 460 | |
| 461 | kfree(compat); |
| 462 | return 0; |
| 463 | } |
| 464 | /* All others can be copied directly */ |
| 465 | } |
| 466 | |
| 467 | if (copy_from_user(event, buffer, min(len, sizeof(*event)))) |
| 468 | return -EFAULT; |
| 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | #else |
| 473 | static int uhid_event_from_user(const char __user *buffer, size_t len, |
| 474 | struct uhid_event *event) |
| 475 | { |
| 476 | if (copy_from_user(event, buffer, min(len, sizeof(*event)))) |
| 477 | return -EFAULT; |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | #endif |
| 482 | |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 483 | static int uhid_dev_create2(struct uhid_device *uhid, |
| 484 | const struct uhid_event *ev) |
| 485 | { |
| 486 | struct hid_device *hid; |
David Herrmann | 25be7fe | 2014-07-29 17:14:18 +0200 | [diff] [blame] | 487 | size_t rd_size, len; |
David Herrmann | 41c4a46 | 2014-07-29 17:14:17 +0200 | [diff] [blame] | 488 | void *rd_data; |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 489 | int ret; |
| 490 | |
| 491 | if (uhid->running) |
| 492 | return -EALREADY; |
| 493 | |
David Herrmann | 41c4a46 | 2014-07-29 17:14:17 +0200 | [diff] [blame] | 494 | rd_size = ev->u.create2.rd_size; |
| 495 | if (rd_size <= 0 || rd_size > HID_MAX_DESCRIPTOR_SIZE) |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 496 | return -EINVAL; |
| 497 | |
David Herrmann | 41c4a46 | 2014-07-29 17:14:17 +0200 | [diff] [blame] | 498 | rd_data = kmemdup(ev->u.create2.rd_data, rd_size, GFP_KERNEL); |
| 499 | if (!rd_data) |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 500 | return -ENOMEM; |
| 501 | |
David Herrmann | 41c4a46 | 2014-07-29 17:14:17 +0200 | [diff] [blame] | 502 | uhid->rd_size = rd_size; |
| 503 | uhid->rd_data = rd_data; |
| 504 | |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 505 | hid = hid_allocate_device(); |
| 506 | if (IS_ERR(hid)) { |
| 507 | ret = PTR_ERR(hid); |
| 508 | goto err_free; |
| 509 | } |
| 510 | |
David Herrmann | 25be7fe | 2014-07-29 17:14:18 +0200 | [diff] [blame] | 511 | len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1; |
| 512 | strncpy(hid->name, ev->u.create2.name, len); |
| 513 | len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)) - 1; |
| 514 | strncpy(hid->phys, ev->u.create2.phys, len); |
| 515 | len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)) - 1; |
| 516 | strncpy(hid->uniq, ev->u.create2.uniq, len); |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 517 | |
| 518 | hid->ll_driver = &uhid_hid_driver; |
| 519 | hid->bus = ev->u.create2.bus; |
| 520 | hid->vendor = ev->u.create2.vendor; |
| 521 | hid->product = ev->u.create2.product; |
| 522 | hid->version = ev->u.create2.version; |
| 523 | hid->country = ev->u.create2.country; |
| 524 | hid->driver_data = uhid; |
| 525 | hid->dev.parent = uhid_misc.this_device; |
| 526 | |
| 527 | uhid->hid = hid; |
| 528 | uhid->running = true; |
| 529 | |
Roderick Colenbrander | 67f8ecc | 2016-05-18 13:11:09 -0700 | [diff] [blame] | 530 | /* Adding of a HID device is done through a worker, to allow HID drivers |
| 531 | * which use feature requests during .probe to work, without they would |
| 532 | * be blocked on devlock, which is held by uhid_char_write. |
| 533 | */ |
| 534 | schedule_work(&uhid->worker); |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 535 | |
| 536 | return 0; |
| 537 | |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 538 | err_free: |
| 539 | kfree(uhid->rd_data); |
David Herrmann | 41c4a46 | 2014-07-29 17:14:17 +0200 | [diff] [blame] | 540 | uhid->rd_data = NULL; |
| 541 | uhid->rd_size = 0; |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 542 | return ret; |
| 543 | } |
| 544 | |
David Herrmann | 56c4775 | 2014-07-29 17:14:16 +0200 | [diff] [blame] | 545 | static int uhid_dev_create(struct uhid_device *uhid, |
| 546 | struct uhid_event *ev) |
| 547 | { |
| 548 | struct uhid_create_req orig; |
| 549 | |
| 550 | orig = ev->u.create; |
| 551 | |
| 552 | if (orig.rd_size <= 0 || orig.rd_size > HID_MAX_DESCRIPTOR_SIZE) |
| 553 | return -EINVAL; |
| 554 | if (copy_from_user(&ev->u.create2.rd_data, orig.rd_data, orig.rd_size)) |
| 555 | return -EFAULT; |
| 556 | |
| 557 | memcpy(ev->u.create2.name, orig.name, sizeof(orig.name)); |
| 558 | memcpy(ev->u.create2.phys, orig.phys, sizeof(orig.phys)); |
| 559 | memcpy(ev->u.create2.uniq, orig.uniq, sizeof(orig.uniq)); |
| 560 | ev->u.create2.rd_size = orig.rd_size; |
| 561 | ev->u.create2.bus = orig.bus; |
| 562 | ev->u.create2.vendor = orig.vendor; |
| 563 | ev->u.create2.product = orig.product; |
| 564 | ev->u.create2.version = orig.version; |
| 565 | ev->u.create2.country = orig.country; |
| 566 | |
| 567 | return uhid_dev_create2(uhid, ev); |
| 568 | } |
| 569 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 570 | static int uhid_dev_destroy(struct uhid_device *uhid) |
| 571 | { |
| 572 | if (!uhid->running) |
| 573 | return -EINVAL; |
| 574 | |
| 575 | uhid->running = false; |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 576 | wake_up_interruptible(&uhid->report_wait); |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 577 | |
Roderick Colenbrander | 67f8ecc | 2016-05-18 13:11:09 -0700 | [diff] [blame] | 578 | cancel_work_sync(&uhid->worker); |
| 579 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 580 | hid_destroy_device(uhid->hid); |
| 581 | kfree(uhid->rd_data); |
| 582 | |
| 583 | return 0; |
| 584 | } |
| 585 | |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 586 | static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev) |
| 587 | { |
| 588 | if (!uhid->running) |
| 589 | return -EINVAL; |
| 590 | |
| 591 | hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data, |
| 592 | min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0); |
| 593 | |
| 594 | return 0; |
| 595 | } |
| 596 | |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 597 | static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev) |
| 598 | { |
| 599 | if (!uhid->running) |
| 600 | return -EINVAL; |
| 601 | |
| 602 | hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input2.data, |
| 603 | min_t(size_t, ev->u.input2.size, UHID_DATA_MAX), 0); |
| 604 | |
| 605 | return 0; |
| 606 | } |
| 607 | |
David Herrmann | fa71f32 | 2014-07-29 17:14:21 +0200 | [diff] [blame] | 608 | static int uhid_dev_get_report_reply(struct uhid_device *uhid, |
| 609 | struct uhid_event *ev) |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 610 | { |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 611 | if (!uhid->running) |
| 612 | return -EINVAL; |
| 613 | |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 614 | uhid_report_wake_up(uhid, ev->u.get_report_reply.id, ev); |
| 615 | return 0; |
| 616 | } |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 617 | |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 618 | static int uhid_dev_set_report_reply(struct uhid_device *uhid, |
| 619 | struct uhid_event *ev) |
| 620 | { |
| 621 | if (!uhid->running) |
| 622 | return -EINVAL; |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 623 | |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 624 | uhid_report_wake_up(uhid, ev->u.set_report_reply.id, ev); |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 625 | return 0; |
| 626 | } |
| 627 | |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 628 | static int uhid_char_open(struct inode *inode, struct file *file) |
| 629 | { |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 630 | struct uhid_device *uhid; |
| 631 | |
| 632 | uhid = kzalloc(sizeof(*uhid), GFP_KERNEL); |
| 633 | if (!uhid) |
| 634 | return -ENOMEM; |
| 635 | |
David Herrmann | d937ae5 | 2012-06-10 15:16:16 +0200 | [diff] [blame] | 636 | mutex_init(&uhid->devlock); |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 637 | mutex_init(&uhid->report_lock); |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 638 | spin_lock_init(&uhid->qlock); |
| 639 | init_waitqueue_head(&uhid->waitq); |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 640 | init_waitqueue_head(&uhid->report_wait); |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 641 | uhid->running = false; |
Roderick Colenbrander | 67f8ecc | 2016-05-18 13:11:09 -0700 | [diff] [blame] | 642 | INIT_WORK(&uhid->worker, uhid_device_add_worker); |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 643 | |
| 644 | file->private_data = uhid; |
| 645 | nonseekable_open(inode, file); |
| 646 | |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | static int uhid_char_release(struct inode *inode, struct file *file) |
| 651 | { |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 652 | struct uhid_device *uhid = file->private_data; |
| 653 | unsigned int i; |
| 654 | |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 655 | uhid_dev_destroy(uhid); |
| 656 | |
David Herrmann | ace3d86 | 2012-06-10 15:16:14 +0200 | [diff] [blame] | 657 | for (i = 0; i < UHID_BUFSIZE; ++i) |
| 658 | kfree(uhid->outq[i]); |
| 659 | |
| 660 | kfree(uhid); |
| 661 | |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 662 | return 0; |
| 663 | } |
| 664 | |
| 665 | static ssize_t uhid_char_read(struct file *file, char __user *buffer, |
| 666 | size_t count, loff_t *ppos) |
| 667 | { |
David Herrmann | d937ae5 | 2012-06-10 15:16:16 +0200 | [diff] [blame] | 668 | struct uhid_device *uhid = file->private_data; |
| 669 | int ret; |
| 670 | unsigned long flags; |
| 671 | size_t len; |
| 672 | |
| 673 | /* they need at least the "type" member of uhid_event */ |
| 674 | if (count < sizeof(__u32)) |
| 675 | return -EINVAL; |
| 676 | |
| 677 | try_again: |
| 678 | if (file->f_flags & O_NONBLOCK) { |
| 679 | if (uhid->head == uhid->tail) |
| 680 | return -EAGAIN; |
| 681 | } else { |
| 682 | ret = wait_event_interruptible(uhid->waitq, |
| 683 | uhid->head != uhid->tail); |
| 684 | if (ret) |
| 685 | return ret; |
| 686 | } |
| 687 | |
| 688 | ret = mutex_lock_interruptible(&uhid->devlock); |
| 689 | if (ret) |
| 690 | return ret; |
| 691 | |
| 692 | if (uhid->head == uhid->tail) { |
| 693 | mutex_unlock(&uhid->devlock); |
| 694 | goto try_again; |
| 695 | } else { |
| 696 | len = min(count, sizeof(**uhid->outq)); |
Vinicius Costa Gomes | adefb69 | 2012-07-14 18:59:25 -0300 | [diff] [blame] | 697 | if (copy_to_user(buffer, uhid->outq[uhid->tail], len)) { |
David Herrmann | d937ae5 | 2012-06-10 15:16:16 +0200 | [diff] [blame] | 698 | ret = -EFAULT; |
| 699 | } else { |
| 700 | kfree(uhid->outq[uhid->tail]); |
| 701 | uhid->outq[uhid->tail] = NULL; |
| 702 | |
| 703 | spin_lock_irqsave(&uhid->qlock, flags); |
| 704 | uhid->tail = (uhid->tail + 1) % UHID_BUFSIZE; |
| 705 | spin_unlock_irqrestore(&uhid->qlock, flags); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | mutex_unlock(&uhid->devlock); |
| 710 | return ret ? ret : len; |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | static ssize_t uhid_char_write(struct file *file, const char __user *buffer, |
| 714 | size_t count, loff_t *ppos) |
| 715 | { |
David Herrmann | 6664ef7 | 2012-06-10 15:16:17 +0200 | [diff] [blame] | 716 | struct uhid_device *uhid = file->private_data; |
| 717 | int ret; |
| 718 | size_t len; |
| 719 | |
| 720 | /* we need at least the "type" member of uhid_event */ |
| 721 | if (count < sizeof(__u32)) |
| 722 | return -EINVAL; |
| 723 | |
| 724 | ret = mutex_lock_interruptible(&uhid->devlock); |
| 725 | if (ret) |
| 726 | return ret; |
| 727 | |
| 728 | memset(&uhid->input_buf, 0, sizeof(uhid->input_buf)); |
| 729 | len = min(count, sizeof(uhid->input_buf)); |
Dmitry Torokhov | befde02 | 2013-02-18 11:26:11 +0100 | [diff] [blame] | 730 | |
| 731 | ret = uhid_event_from_user(buffer, len, &uhid->input_buf); |
| 732 | if (ret) |
David Herrmann | 6664ef7 | 2012-06-10 15:16:17 +0200 | [diff] [blame] | 733 | goto unlock; |
David Herrmann | 6664ef7 | 2012-06-10 15:16:17 +0200 | [diff] [blame] | 734 | |
| 735 | switch (uhid->input_buf.type) { |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 736 | case UHID_CREATE: |
| 737 | ret = uhid_dev_create(uhid, &uhid->input_buf); |
| 738 | break; |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 739 | case UHID_CREATE2: |
| 740 | ret = uhid_dev_create2(uhid, &uhid->input_buf); |
| 741 | break; |
David Herrmann | d365c6c | 2012-06-10 15:16:18 +0200 | [diff] [blame] | 742 | case UHID_DESTROY: |
| 743 | ret = uhid_dev_destroy(uhid); |
| 744 | break; |
David Herrmann | 5e87a36 | 2012-06-10 15:16:19 +0200 | [diff] [blame] | 745 | case UHID_INPUT: |
| 746 | ret = uhid_dev_input(uhid, &uhid->input_buf); |
| 747 | break; |
Petri Gynther | 4522643 | 2014-03-24 13:50:01 -0700 | [diff] [blame] | 748 | case UHID_INPUT2: |
| 749 | ret = uhid_dev_input2(uhid, &uhid->input_buf); |
| 750 | break; |
David Herrmann | fa71f32 | 2014-07-29 17:14:21 +0200 | [diff] [blame] | 751 | case UHID_GET_REPORT_REPLY: |
| 752 | ret = uhid_dev_get_report_reply(uhid, &uhid->input_buf); |
David Herrmann | fcfcf0d | 2012-06-10 15:16:25 +0200 | [diff] [blame] | 753 | break; |
David Herrmann | 11c2215 | 2014-07-29 17:14:24 +0200 | [diff] [blame] | 754 | case UHID_SET_REPORT_REPLY: |
| 755 | ret = uhid_dev_set_report_reply(uhid, &uhid->input_buf); |
| 756 | break; |
David Herrmann | 6664ef7 | 2012-06-10 15:16:17 +0200 | [diff] [blame] | 757 | default: |
| 758 | ret = -EOPNOTSUPP; |
| 759 | } |
| 760 | |
| 761 | unlock: |
| 762 | mutex_unlock(&uhid->devlock); |
| 763 | |
| 764 | /* return "count" not "len" to not confuse the caller */ |
| 765 | return ret ? ret : count; |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | static unsigned int uhid_char_poll(struct file *file, poll_table *wait) |
| 769 | { |
David Herrmann | 1f9dec1 | 2012-06-10 15:16:15 +0200 | [diff] [blame] | 770 | struct uhid_device *uhid = file->private_data; |
| 771 | |
| 772 | poll_wait(file, &uhid->waitq, wait); |
| 773 | |
| 774 | if (uhid->head != uhid->tail) |
| 775 | return POLLIN | POLLRDNORM; |
| 776 | |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | static const struct file_operations uhid_fops = { |
| 781 | .owner = THIS_MODULE, |
| 782 | .open = uhid_char_open, |
| 783 | .release = uhid_char_release, |
| 784 | .read = uhid_char_read, |
| 785 | .write = uhid_char_write, |
| 786 | .poll = uhid_char_poll, |
| 787 | .llseek = no_llseek, |
| 788 | }; |
| 789 | |
| 790 | static struct miscdevice uhid_misc = { |
| 791 | .fops = &uhid_fops, |
David Herrmann | 19872d2 | 2013-09-09 18:33:54 +0200 | [diff] [blame] | 792 | .minor = UHID_MINOR, |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 793 | .name = UHID_NAME, |
| 794 | }; |
PrasannaKumar Muralidharan | ca75d60 | 2016-08-25 22:30:49 +0530 | [diff] [blame] | 795 | module_misc_device(uhid_misc); |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 796 | |
David Herrmann | 1ccd7a2 | 2012-06-10 15:16:13 +0200 | [diff] [blame] | 797 | MODULE_LICENSE("GPL"); |
| 798 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); |
| 799 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); |
David Herrmann | 19872d2 | 2013-09-09 18:33:54 +0200 | [diff] [blame] | 800 | MODULE_ALIAS_MISCDEV(UHID_MINOR); |
Marcel Holtmann | 60cbd53 | 2013-09-01 11:02:46 -0700 | [diff] [blame] | 801 | MODULE_ALIAS("devname:" UHID_NAME); |