uhid.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. /*
  2. * User-space I/O driver support for HID subsystem
  3. * Copyright (c) 2012 David Herrmann
  4. */
  5. /*
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. */
  11. #include <linux/atomic.h>
  12. #include <linux/device.h>
  13. #include <linux/fs.h>
  14. #include <linux/hid.h>
  15. #include <linux/input.h>
  16. #include <linux/miscdevice.h>
  17. #include <linux/module.h>
  18. #include <linux/mutex.h>
  19. #include <linux/poll.h>
  20. #include <linux/sched.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/uhid.h>
  23. #include <linux/wait.h>
  24. #include <linux/fb.h>
  25. #define UHID_NAME "uhid"
  26. #define UHID_BUFSIZE 32
  27. static DEFINE_MUTEX(uhid_open_mutex);
  28. struct uhid_device {
  29. struct mutex devlock;
  30. bool running;
  31. __u8 *rd_data;
  32. uint rd_size;
  33. struct hid_device *hid;
  34. struct uhid_event input_buf;
  35. wait_queue_head_t waitq;
  36. spinlock_t qlock;
  37. __u8 head;
  38. __u8 tail;
  39. struct uhid_event *outq[UHID_BUFSIZE];
  40. /* blocking GET_REPORT support; state changes protected by qlock */
  41. struct mutex report_lock;
  42. wait_queue_head_t report_wait;
  43. bool report_running;
  44. u32 report_id;
  45. struct uhid_event report_buf;
  46. struct work_struct worker;
  47. };
  48. static struct miscdevice uhid_misc;
  49. bool lcd_is_on = true;
  50. static void uhid_device_add_worker(struct work_struct *work)
  51. {
  52. struct uhid_device *uhid = container_of(work, struct uhid_device, worker);
  53. int ret;
  54. ret = hid_add_device(uhid->hid);
  55. if (ret) {
  56. hid_err(uhid->hid, "Cannot register HID device: error %d\n", ret);
  57. hid_destroy_device(uhid->hid);
  58. uhid->hid = NULL;
  59. uhid->running = false;
  60. }
  61. }
  62. static void uhid_queue(struct uhid_device *uhid, struct uhid_event *ev)
  63. {
  64. __u8 newhead;
  65. newhead = (uhid->head + 1) % UHID_BUFSIZE;
  66. if (newhead != uhid->tail) {
  67. uhid->outq[uhid->head] = ev;
  68. uhid->head = newhead;
  69. wake_up_interruptible(&uhid->waitq);
  70. } else {
  71. hid_warn(uhid->hid, "Output queue is full\n");
  72. kfree(ev);
  73. }
  74. }
  75. static int uhid_queue_event(struct uhid_device *uhid, __u32 event)
  76. {
  77. unsigned long flags;
  78. struct uhid_event *ev;
  79. ev = kzalloc(sizeof(*ev), GFP_KERNEL);
  80. if (!ev)
  81. return -ENOMEM;
  82. ev->type = event;
  83. spin_lock_irqsave(&uhid->qlock, flags);
  84. uhid_queue(uhid, ev);
  85. spin_unlock_irqrestore(&uhid->qlock, flags);
  86. return 0;
  87. }
  88. static int uhid_hid_start(struct hid_device *hid)
  89. {
  90. struct uhid_device *uhid = hid->driver_data;
  91. return uhid_queue_event(uhid, UHID_START);
  92. }
  93. static void uhid_hid_stop(struct hid_device *hid)
  94. {
  95. struct uhid_device *uhid = hid->driver_data;
  96. hid->claimed = 0;
  97. uhid_queue_event(uhid, UHID_STOP);
  98. }
  99. static int uhid_hid_open(struct hid_device *hid)
  100. {
  101. struct uhid_device *uhid = hid->driver_data;
  102. int retval = 0;
  103. mutex_lock(&uhid_open_mutex);
  104. if (!hid->open++) {
  105. retval = uhid_queue_event(uhid, UHID_OPEN);
  106. if (retval)
  107. hid->open--;
  108. }
  109. mutex_unlock(&uhid_open_mutex);
  110. return retval;
  111. }
  112. static void uhid_hid_close(struct hid_device *hid)
  113. {
  114. struct uhid_device *uhid = hid->driver_data;
  115. mutex_lock(&uhid_open_mutex);
  116. if (!--hid->open)
  117. uhid_queue_event(uhid, UHID_CLOSE);
  118. mutex_unlock(&uhid_open_mutex);
  119. }
  120. static int uhid_hid_input(struct input_dev *input, unsigned int type,
  121. unsigned int code, int value)
  122. {
  123. struct hid_device *hid = input_get_drvdata(input);
  124. struct uhid_device *uhid = hid->driver_data;
  125. unsigned long flags;
  126. struct uhid_event *ev;
  127. struct hid_field *field;
  128. struct hid_report *report;
  129. int offset;
  130. ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
  131. if (!ev)
  132. return -ENOMEM;
  133. switch (type) {
  134. case EV_LED:
  135. if(!lcd_is_on){
  136. dbg_hid("uhid_hid_input lcd is off, don't report LED event\n");
  137. kfree(ev);
  138. return -1;
  139. }
  140. offset = hidinput_find_field(hid, type, code, &field);
  141. if (offset == -1) {
  142. hid_warn(input, "event field not found\n");
  143. kfree(ev);
  144. return -1;
  145. }
  146. hid_set_field(field, offset, value);
  147. report = field->report;
  148. ev->type = UHID_OUTPUT;
  149. ev->u.output.rtype = UHID_OUTPUT_REPORT;
  150. hid_output_report(report, ev->u.output.data);
  151. ev->u.output.size = ((report->size - 1) >> 3) + 1 +
  152. (report->id > 0);
  153. break;
  154. default:
  155. ev->type = UHID_OUTPUT_EV;
  156. ev->u.output_ev.type = type;
  157. ev->u.output_ev.code = code;
  158. ev->u.output_ev.value = value;
  159. }
  160. spin_lock_irqsave(&uhid->qlock, flags);
  161. uhid_queue(uhid, ev);
  162. spin_unlock_irqrestore(&uhid->qlock, flags);
  163. return 0;
  164. }
  165. static int fb_state_change(struct notifier_block *nb,
  166. unsigned long val, void *data)
  167. {
  168. struct fb_event *evdata = data;
  169. unsigned int blank;
  170. dbg_hid("fb_state_change");
  171. if (val != FB_EVENT_BLANK)
  172. return 0;
  173. blank = *(int *)evdata->data;
  174. switch (blank) {
  175. case FB_BLANK_POWERDOWN:
  176. lcd_is_on = false;
  177. break;
  178. case FB_BLANK_UNBLANK:
  179. lcd_is_on = true;
  180. break;
  181. default:
  182. break;
  183. }
  184. return NOTIFY_OK;
  185. }
  186. static struct notifier_block fb_block = {
  187. .notifier_call = fb_state_change,
  188. };
  189. static int uhid_hid_parse(struct hid_device *hid)
  190. {
  191. struct uhid_device *uhid = hid->driver_data;
  192. return hid_parse_report(hid, uhid->rd_data, uhid->rd_size);
  193. }
  194. static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
  195. __u8 *buf, size_t count, unsigned char rtype)
  196. {
  197. struct uhid_device *uhid = hid->driver_data;
  198. __u8 report_type;
  199. struct uhid_event *ev;
  200. unsigned long flags;
  201. int ret;
  202. size_t uninitialized_var(len);
  203. struct uhid_feature_answer_req *req;
  204. if (!uhid->running)
  205. return -EIO;
  206. switch (rtype) {
  207. case HID_FEATURE_REPORT:
  208. report_type = UHID_FEATURE_REPORT;
  209. break;
  210. case HID_OUTPUT_REPORT:
  211. report_type = UHID_OUTPUT_REPORT;
  212. break;
  213. case HID_INPUT_REPORT:
  214. report_type = UHID_INPUT_REPORT;
  215. break;
  216. default:
  217. return -EINVAL;
  218. }
  219. ret = mutex_lock_interruptible(&uhid->report_lock);
  220. if (ret)
  221. return ret;
  222. ev = kzalloc(sizeof(*ev), GFP_KERNEL);
  223. if (!ev) {
  224. ret = -ENOMEM;
  225. goto unlock;
  226. }
  227. spin_lock_irqsave(&uhid->qlock, flags);
  228. ev->type = UHID_FEATURE;
  229. ev->u.feature.id = ++uhid->report_id;
  230. ev->u.feature.rnum = rnum;
  231. ev->u.feature.rtype = report_type;
  232. uhid->report_running = true;
  233. uhid_queue(uhid, ev);
  234. spin_unlock_irqrestore(&uhid->qlock, flags);
  235. ret = wait_event_interruptible_timeout(uhid->report_wait,
  236. !uhid->report_running || !uhid->running,
  237. 5 * HZ);
  238. if (!ret || !uhid->running) {
  239. ret = -EIO;
  240. } else if (ret < 0) {
  241. ret = -ERESTARTSYS;
  242. } else {
  243. spin_lock_irqsave(&uhid->qlock, flags);
  244. req = &uhid->report_buf.u.feature_answer;
  245. if (req->err) {
  246. ret = -EIO;
  247. } else {
  248. ret = 0;
  249. len = min(count,
  250. min_t(size_t, req->size, UHID_DATA_MAX));
  251. memcpy(buf, req->data, len);
  252. }
  253. spin_unlock_irqrestore(&uhid->qlock, flags);
  254. }
  255. uhid->report_running = false;
  256. unlock:
  257. mutex_unlock(&uhid->report_lock);
  258. return ret ? ret : len;
  259. }
  260. static int uhid_hid_output_raw(struct hid_device *hid, __u8 *buf, size_t count,
  261. unsigned char report_type)
  262. {
  263. struct uhid_device *uhid = hid->driver_data;
  264. __u8 rtype;
  265. unsigned long flags;
  266. struct uhid_event *ev;
  267. switch (report_type) {
  268. case HID_FEATURE_REPORT:
  269. rtype = UHID_FEATURE_REPORT;
  270. break;
  271. case HID_OUTPUT_REPORT:
  272. rtype = UHID_OUTPUT_REPORT;
  273. break;
  274. default:
  275. return -EINVAL;
  276. }
  277. if (count < 1 || count > UHID_DATA_MAX)
  278. return -EINVAL;
  279. ev = kzalloc(sizeof(*ev), GFP_KERNEL);
  280. if (!ev)
  281. return -ENOMEM;
  282. ev->type = UHID_OUTPUT;
  283. ev->u.output.size = count;
  284. ev->u.output.rtype = rtype;
  285. memcpy(ev->u.output.data, buf, count);
  286. spin_lock_irqsave(&uhid->qlock, flags);
  287. uhid_queue(uhid, ev);
  288. spin_unlock_irqrestore(&uhid->qlock, flags);
  289. return count;
  290. }
  291. static struct hid_ll_driver uhid_hid_driver = {
  292. .start = uhid_hid_start,
  293. .stop = uhid_hid_stop,
  294. .open = uhid_hid_open,
  295. .close = uhid_hid_close,
  296. .hidinput_input_event = uhid_hid_input,
  297. .parse = uhid_hid_parse,
  298. };
  299. static int uhid_dev_create(struct uhid_device *uhid,
  300. const struct uhid_event *ev)
  301. {
  302. struct hid_device *hid;
  303. int ret;
  304. if (uhid->running)
  305. return -EALREADY;
  306. uhid->rd_size = ev->u.create.rd_size;
  307. if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE)
  308. return -EINVAL;
  309. uhid->rd_data = kmalloc(uhid->rd_size, GFP_KERNEL);
  310. if (!uhid->rd_data)
  311. return -ENOMEM;
  312. if (copy_from_user(uhid->rd_data, ev->u.create.rd_data,
  313. uhid->rd_size)) {
  314. ret = -EFAULT;
  315. goto err_free;
  316. }
  317. hid = hid_allocate_device();
  318. if (IS_ERR(hid)) {
  319. ret = PTR_ERR(hid);
  320. goto err_free;
  321. }
  322. strncpy(hid->name, ev->u.create.name, 127);
  323. hid->name[127] = 0;
  324. strncpy(hid->phys, ev->u.create.phys, 63);
  325. hid->phys[63] = 0;
  326. strncpy(hid->uniq, ev->u.create.uniq, 63);
  327. hid->uniq[63] = 0;
  328. hid->ll_driver = &uhid_hid_driver;
  329. hid->hid_get_raw_report = uhid_hid_get_raw;
  330. hid->hid_output_raw_report = uhid_hid_output_raw;
  331. hid->bus = ev->u.create.bus;
  332. hid->vendor = ev->u.create.vendor;
  333. hid->product = ev->u.create.product;
  334. hid->version = ev->u.create.version;
  335. hid->country = ev->u.create.country;
  336. hid->driver_data = uhid;
  337. hid->dev.parent = uhid_misc.this_device;
  338. uhid->hid = hid;
  339. uhid->running = true;
  340. ret = hid_add_device(hid);
  341. if (ret) {
  342. hid_err(hid, "Cannot register HID device\n");
  343. goto err_hid;
  344. }
  345. return 0;
  346. err_hid:
  347. hid_destroy_device(hid);
  348. uhid->hid = NULL;
  349. uhid->running = false;
  350. err_free:
  351. kfree(uhid->rd_data);
  352. return ret;
  353. }
  354. static int uhid_dev_create2(struct uhid_device *uhid,
  355. const struct uhid_event *ev)
  356. {
  357. struct hid_device *hid;
  358. size_t rd_size, len;
  359. void *rd_data;
  360. int ret;
  361. if (uhid->running)
  362. return -EALREADY;
  363. rd_size = ev->u.create2.rd_size;
  364. if (rd_size <= 0 || rd_size > HID_MAX_DESCRIPTOR_SIZE)
  365. return -EINVAL;
  366. rd_data = kmemdup(ev->u.create2.rd_data, rd_size, GFP_KERNEL);
  367. if (!rd_data)
  368. return -ENOMEM;
  369. uhid->rd_size = rd_size;
  370. uhid->rd_data = rd_data;
  371. hid = hid_allocate_device();
  372. if (IS_ERR(hid)) {
  373. ret = PTR_ERR(hid);
  374. goto err_free;
  375. }
  376. len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1;
  377. strncpy(hid->name, ev->u.create2.name, len);
  378. len = min(sizeof(hid->phys), sizeof(ev->u.create2.phys)) - 1;
  379. strncpy(hid->phys, ev->u.create2.phys, len);
  380. len = min(sizeof(hid->uniq), sizeof(ev->u.create2.uniq)) - 1;
  381. strncpy(hid->uniq, ev->u.create2.uniq, len);
  382. hid->ll_driver = &uhid_hid_driver;
  383. hid->bus = ev->u.create2.bus;
  384. hid->vendor = ev->u.create2.vendor;
  385. hid->product = ev->u.create2.product;
  386. hid->version = ev->u.create2.version;
  387. hid->country = ev->u.create2.country;
  388. hid->driver_data = uhid;
  389. hid->dev.parent = uhid_misc.this_device;
  390. uhid->hid = hid;
  391. uhid->running = true;
  392. /* Adding of a HID device is done through a worker, to allow HID drivers
  393. * which use feature requests during .probe to work, without they would
  394. * be blocked on devlock, which is held by uhid_char_write.
  395. */
  396. schedule_work(&uhid->worker);
  397. return 0;
  398. err_free:
  399. kfree(uhid->rd_data);
  400. uhid->rd_data = NULL;
  401. uhid->rd_size = 0;
  402. return ret;
  403. }
  404. static int uhid_dev_destroy(struct uhid_device *uhid)
  405. {
  406. if (!uhid->running)
  407. return -EINVAL;
  408. uhid->running = false;
  409. wake_up_interruptible(&uhid->report_wait);
  410. cancel_work_sync(&uhid->worker);
  411. hid_destroy_device(uhid->hid);
  412. kfree(uhid->rd_data);
  413. return 0;
  414. }
  415. static int uhid_dev_input(struct uhid_device *uhid, struct uhid_event *ev)
  416. {
  417. if (!uhid->running)
  418. return -EINVAL;
  419. hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input.data,
  420. min_t(size_t, ev->u.input.size, UHID_DATA_MAX), 0);
  421. return 0;
  422. }
  423. static int uhid_dev_input2(struct uhid_device *uhid, struct uhid_event *ev)
  424. {
  425. if (!uhid->running)
  426. return -EINVAL;
  427. hid_input_report(uhid->hid, HID_INPUT_REPORT, ev->u.input2.data,
  428. min_t(size_t, ev->u.input2.size, UHID_DATA_MAX), 0);
  429. return 0;
  430. }
  431. static int uhid_dev_feature_answer(struct uhid_device *uhid,
  432. struct uhid_event *ev)
  433. {
  434. unsigned long flags;
  435. if (!uhid->running)
  436. return -EINVAL;
  437. spin_lock_irqsave(&uhid->qlock, flags);
  438. /* id for old report; drop it silently */
  439. if (uhid->report_id != ev->u.feature_answer.id)
  440. goto unlock;
  441. if (!uhid->report_running)
  442. goto unlock;
  443. memcpy(&uhid->report_buf, ev, sizeof(*ev));
  444. uhid->report_running = false;
  445. wake_up_interruptible(&uhid->report_wait);
  446. unlock:
  447. spin_unlock_irqrestore(&uhid->qlock, flags);
  448. return 0;
  449. }
  450. static int uhid_char_open(struct inode *inode, struct file *file)
  451. {
  452. struct uhid_device *uhid;
  453. uhid = kzalloc(sizeof(*uhid), GFP_KERNEL);
  454. if (!uhid)
  455. return -ENOMEM;
  456. mutex_init(&uhid->devlock);
  457. mutex_init(&uhid->report_lock);
  458. spin_lock_init(&uhid->qlock);
  459. init_waitqueue_head(&uhid->waitq);
  460. init_waitqueue_head(&uhid->report_wait);
  461. uhid->running = false;
  462. INIT_WORK(&uhid->worker, uhid_device_add_worker);
  463. file->private_data = uhid;
  464. nonseekable_open(inode, file);
  465. return 0;
  466. }
  467. static int uhid_char_release(struct inode *inode, struct file *file)
  468. {
  469. struct uhid_device *uhid = file->private_data;
  470. unsigned int i;
  471. uhid_dev_destroy(uhid);
  472. for (i = 0; i < UHID_BUFSIZE; ++i)
  473. kfree(uhid->outq[i]);
  474. kfree(uhid);
  475. return 0;
  476. }
  477. static ssize_t uhid_char_read(struct file *file, char __user *buffer,
  478. size_t count, loff_t *ppos)
  479. {
  480. struct uhid_device *uhid = file->private_data;
  481. int ret;
  482. unsigned long flags;
  483. size_t len;
  484. /* they need at least the "type" member of uhid_event */
  485. if (count < sizeof(__u32))
  486. return -EINVAL;
  487. try_again:
  488. if (file->f_flags & O_NONBLOCK) {
  489. if (uhid->head == uhid->tail)
  490. return -EAGAIN;
  491. } else {
  492. ret = wait_event_interruptible(uhid->waitq,
  493. uhid->head != uhid->tail);
  494. if (ret)
  495. return ret;
  496. }
  497. ret = mutex_lock_interruptible(&uhid->devlock);
  498. if (ret)
  499. return ret;
  500. if (uhid->head == uhid->tail) {
  501. mutex_unlock(&uhid->devlock);
  502. goto try_again;
  503. } else {
  504. len = min(count, sizeof(**uhid->outq));
  505. if (copy_to_user(buffer, uhid->outq[uhid->tail], len)) {
  506. ret = -EFAULT;
  507. } else {
  508. kfree(uhid->outq[uhid->tail]);
  509. uhid->outq[uhid->tail] = NULL;
  510. spin_lock_irqsave(&uhid->qlock, flags);
  511. uhid->tail = (uhid->tail + 1) % UHID_BUFSIZE;
  512. spin_unlock_irqrestore(&uhid->qlock, flags);
  513. }
  514. }
  515. mutex_unlock(&uhid->devlock);
  516. return ret ? ret : len;
  517. }
  518. static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
  519. size_t count, loff_t *ppos)
  520. {
  521. struct uhid_device *uhid = file->private_data;
  522. int ret;
  523. size_t len;
  524. /* we need at least the "type" member of uhid_event */
  525. if (count < sizeof(__u32))
  526. return -EINVAL;
  527. ret = mutex_lock_interruptible(&uhid->devlock);
  528. if (ret)
  529. return ret;
  530. memset(&uhid->input_buf, 0, sizeof(uhid->input_buf));
  531. len = min(count, sizeof(uhid->input_buf));
  532. if (copy_from_user(&uhid->input_buf, buffer, len)) {
  533. ret = -EFAULT;
  534. goto unlock;
  535. }
  536. switch (uhid->input_buf.type) {
  537. case UHID_CREATE:
  538. ret = uhid_dev_create(uhid, &uhid->input_buf);
  539. break;
  540. case UHID_CREATE2:
  541. ret = uhid_dev_create2(uhid, &uhid->input_buf);
  542. break;
  543. case UHID_DESTROY:
  544. ret = uhid_dev_destroy(uhid);
  545. break;
  546. case UHID_INPUT:
  547. ret = uhid_dev_input(uhid, &uhid->input_buf);
  548. break;
  549. case UHID_INPUT2:
  550. ret = uhid_dev_input2(uhid, &uhid->input_buf);
  551. break;
  552. case UHID_FEATURE_ANSWER:
  553. ret = uhid_dev_feature_answer(uhid, &uhid->input_buf);
  554. break;
  555. default:
  556. ret = -EOPNOTSUPP;
  557. }
  558. unlock:
  559. mutex_unlock(&uhid->devlock);
  560. /* return "count" not "len" to not confuse the caller */
  561. return ret ? ret : count;
  562. }
  563. static unsigned int uhid_char_poll(struct file *file, poll_table *wait)
  564. {
  565. struct uhid_device *uhid = file->private_data;
  566. unsigned int mask = POLLOUT | POLLWRNORM; /* uhid is always writable */
  567. poll_wait(file, &uhid->waitq, wait);
  568. if (uhid->head != uhid->tail)
  569. mask |= POLLIN | POLLRDNORM;
  570. return mask;
  571. }
  572. static const struct file_operations uhid_fops = {
  573. .owner = THIS_MODULE,
  574. .open = uhid_char_open,
  575. .release = uhid_char_release,
  576. .read = uhid_char_read,
  577. .write = uhid_char_write,
  578. .poll = uhid_char_poll,
  579. .llseek = no_llseek,
  580. };
  581. static struct miscdevice uhid_misc = {
  582. .fops = &uhid_fops,
  583. .minor = MISC_DYNAMIC_MINOR,
  584. .name = UHID_NAME,
  585. };
  586. static int __init uhid_init(void)
  587. {
  588. fb_register_client(&fb_block);
  589. return misc_register(&uhid_misc);
  590. }
  591. static void __exit uhid_exit(void)
  592. {
  593. fb_unregister_client(&fb_block);
  594. misc_deregister(&uhid_misc);
  595. }
  596. module_init(uhid_init);
  597. module_exit(uhid_exit);
  598. MODULE_LICENSE("GPL");
  599. MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
  600. MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem");