evdev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * Event char devices, giving access to raw input device events.
  3. *
  4. * Copyright (c) 1999-2002 Vojtech Pavlik
  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 version 2 as published by
  8. * the Free Software Foundation.
  9. */
  10. #define EVDEV_MINOR_BASE 64
  11. #define EVDEV_MINORS 32
  12. #define EVDEV_BUFFER_SIZE 64
  13. #include <linux/poll.h>
  14. #include <linux/slab.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <linux/input.h>
  18. #include <linux/major.h>
  19. #include <linux/smp_lock.h>
  20. #include <linux/device.h>
  21. #include <linux/compat.h>
  22. struct evdev {
  23. int exist;
  24. int open;
  25. int minor;
  26. char name[16];
  27. struct input_handle handle;
  28. wait_queue_head_t wait;
  29. struct evdev_list *grab;
  30. struct list_head list;
  31. };
  32. struct evdev_list {
  33. struct input_event buffer[EVDEV_BUFFER_SIZE];
  34. int head;
  35. int tail;
  36. struct fasync_struct *fasync;
  37. struct evdev *evdev;
  38. struct list_head node;
  39. };
  40. static struct evdev *evdev_table[EVDEV_MINORS];
  41. static void evdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
  42. {
  43. struct evdev *evdev = handle->private;
  44. struct evdev_list *list;
  45. if (evdev->grab) {
  46. list = evdev->grab;
  47. do_gettimeofday(&list->buffer[list->head].time);
  48. list->buffer[list->head].type = type;
  49. list->buffer[list->head].code = code;
  50. list->buffer[list->head].value = value;
  51. list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1);
  52. kill_fasync(&list->fasync, SIGIO, POLL_IN);
  53. } else
  54. list_for_each_entry(list, &evdev->list, node) {
  55. do_gettimeofday(&list->buffer[list->head].time);
  56. list->buffer[list->head].type = type;
  57. list->buffer[list->head].code = code;
  58. list->buffer[list->head].value = value;
  59. list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1);
  60. kill_fasync(&list->fasync, SIGIO, POLL_IN);
  61. }
  62. wake_up_interruptible(&evdev->wait);
  63. }
  64. static int evdev_fasync(int fd, struct file *file, int on)
  65. {
  66. int retval;
  67. struct evdev_list *list = file->private_data;
  68. retval = fasync_helper(fd, file, on, &list->fasync);
  69. return retval < 0 ? retval : 0;
  70. }
  71. static int evdev_flush(struct file *file, fl_owner_t id)
  72. {
  73. struct evdev_list *list = file->private_data;
  74. if (!list->evdev->exist)
  75. return -ENODEV;
  76. return input_flush_device(&list->evdev->handle, file);
  77. }
  78. static void evdev_free(struct evdev *evdev)
  79. {
  80. evdev_table[evdev->minor] = NULL;
  81. kfree(evdev);
  82. }
  83. static int evdev_release(struct inode * inode, struct file * file)
  84. {
  85. struct evdev_list *list = file->private_data;
  86. if (list->evdev->grab == list) {
  87. input_release_device(&list->evdev->handle);
  88. list->evdev->grab = NULL;
  89. }
  90. evdev_fasync(-1, file, 0);
  91. list_del(&list->node);
  92. if (!--list->evdev->open) {
  93. if (list->evdev->exist)
  94. input_close_device(&list->evdev->handle);
  95. else
  96. evdev_free(list->evdev);
  97. }
  98. kfree(list);
  99. return 0;
  100. }
  101. static int evdev_open(struct inode * inode, struct file * file)
  102. {
  103. struct evdev_list *list;
  104. int i = iminor(inode) - EVDEV_MINOR_BASE;
  105. if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist)
  106. return -ENODEV;
  107. if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
  108. return -ENOMEM;
  109. list->evdev = evdev_table[i];
  110. list_add_tail(&list->node, &evdev_table[i]->list);
  111. file->private_data = list;
  112. if (!list->evdev->open++)
  113. if (list->evdev->exist)
  114. input_open_device(&list->evdev->handle);
  115. return 0;
  116. }
  117. #ifdef CONFIG_COMPAT
  118. struct input_event_compat {
  119. struct compat_timeval time;
  120. __u16 type;
  121. __u16 code;
  122. __s32 value;
  123. };
  124. /* Note to the author of this code: did it ever occur to
  125. you why the ifdefs are needed? Think about it again. -AK */
  126. #ifdef CONFIG_X86_64
  127. # define COMPAT_TEST is_compat_task()
  128. #elif defined(CONFIG_IA64)
  129. # define COMPAT_TEST IS_IA32_PROCESS(task_pt_regs(current))
  130. #elif defined(CONFIG_S390)
  131. # define COMPAT_TEST test_thread_flag(TIF_31BIT)
  132. #elif defined(CONFIG_MIPS)
  133. # define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR)
  134. #else
  135. # define COMPAT_TEST test_thread_flag(TIF_32BIT)
  136. #endif
  137. static inline size_t evdev_event_size(void)
  138. {
  139. return COMPAT_TEST ?
  140. sizeof(struct input_event_compat) : sizeof(struct input_event);
  141. }
  142. static int evdev_event_from_user(const char __user *buffer, struct input_event *event)
  143. {
  144. if (COMPAT_TEST) {
  145. struct input_event_compat compat_event;
  146. if (copy_from_user(&compat_event, buffer, sizeof(struct input_event_compat)))
  147. return -EFAULT;
  148. event->time.tv_sec = compat_event.time.tv_sec;
  149. event->time.tv_usec = compat_event.time.tv_usec;
  150. event->type = compat_event.type;
  151. event->code = compat_event.code;
  152. event->value = compat_event.value;
  153. } else {
  154. if (copy_from_user(event, buffer, sizeof(struct input_event)))
  155. return -EFAULT;
  156. }
  157. return 0;
  158. }
  159. static int evdev_event_to_user(char __user *buffer, const struct input_event *event)
  160. {
  161. if (COMPAT_TEST) {
  162. struct input_event_compat compat_event;
  163. compat_event.time.tv_sec = event->time.tv_sec;
  164. compat_event.time.tv_usec = event->time.tv_usec;
  165. compat_event.type = event->type;
  166. compat_event.code = event->code;
  167. compat_event.value = event->value;
  168. if (copy_to_user(buffer, &compat_event, sizeof(struct input_event_compat)))
  169. return -EFAULT;
  170. } else {
  171. if (copy_to_user(buffer, event, sizeof(struct input_event)))
  172. return -EFAULT;
  173. }
  174. return 0;
  175. }
  176. #else
  177. static inline size_t evdev_event_size(void)
  178. {
  179. return sizeof(struct input_event);
  180. }
  181. static int evdev_event_from_user(const char __user *buffer, struct input_event *event)
  182. {
  183. if (copy_from_user(event, buffer, sizeof(struct input_event)))
  184. return -EFAULT;
  185. return 0;
  186. }
  187. static int evdev_event_to_user(char __user *buffer, const struct input_event *event)
  188. {
  189. if (copy_to_user(buffer, event, sizeof(struct input_event)))
  190. return -EFAULT;
  191. return 0;
  192. }
  193. #endif /* CONFIG_COMPAT */
  194. static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos)
  195. {
  196. struct evdev_list *list = file->private_data;
  197. struct input_event event;
  198. int retval = 0;
  199. if (!list->evdev->exist)
  200. return -ENODEV;
  201. while (retval < count) {
  202. if (evdev_event_from_user(buffer + retval, &event))
  203. return -EFAULT;
  204. input_inject_event(&list->evdev->handle, event.type, event.code, event.value);
  205. retval += evdev_event_size();
  206. }
  207. return retval;
  208. }
  209. static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos)
  210. {
  211. struct evdev_list *list = file->private_data;
  212. int retval;
  213. if (count < evdev_event_size())
  214. return -EINVAL;
  215. if (list->head == list->tail && list->evdev->exist && (file->f_flags & O_NONBLOCK))
  216. return -EAGAIN;
  217. retval = wait_event_interruptible(list->evdev->wait,
  218. list->head != list->tail || (!list->evdev->exist));
  219. if (retval)
  220. return retval;
  221. if (!list->evdev->exist)
  222. return -ENODEV;
  223. while (list->head != list->tail && retval + evdev_event_size() <= count) {
  224. struct input_event *event = (struct input_event *) list->buffer + list->tail;
  225. if (evdev_event_to_user(buffer + retval, event))
  226. return -EFAULT;
  227. list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1);
  228. retval += evdev_event_size();
  229. }
  230. return retval;
  231. }
  232. /* No kernel lock - fine */
  233. static unsigned int evdev_poll(struct file *file, poll_table *wait)
  234. {
  235. struct evdev_list *list = file->private_data;
  236. poll_wait(file, &list->evdev->wait, wait);
  237. return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) |
  238. (list->evdev->exist ? 0 : (POLLHUP | POLLERR));
  239. }
  240. #ifdef CONFIG_COMPAT
  241. #define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8)
  242. #define NBITS_COMPAT(x) ((((x) - 1) / BITS_PER_LONG_COMPAT) + 1)
  243. #ifdef __BIG_ENDIAN
  244. static int bits_to_user(unsigned long *bits, unsigned int maxbit,
  245. unsigned int maxlen, void __user *p, int compat)
  246. {
  247. int len, i;
  248. if (compat) {
  249. len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t);
  250. if (len < maxlen)
  251. len = maxlen;
  252. for (i = 0; i < len / sizeof(compat_long_t); i++)
  253. if (copy_to_user((compat_long_t __user *) p + i,
  254. (compat_long_t *) bits +
  255. i + 1 - ((i % 2) << 1),
  256. sizeof(compat_long_t)))
  257. return -EFAULT;
  258. } else {
  259. len = NBITS(maxbit) * sizeof(long);
  260. if (len > maxlen)
  261. len = maxlen;
  262. if (copy_to_user(p, bits, len))
  263. return -EFAULT;
  264. }
  265. return len;
  266. }
  267. #else
  268. static int bits_to_user(unsigned long *bits, unsigned int maxbit,
  269. unsigned int maxlen, void __user *p, int compat)
  270. {
  271. int len = compat ?
  272. NBITS_COMPAT(maxbit) * sizeof(compat_long_t) :
  273. NBITS(maxbit) * sizeof(long);
  274. if (len > maxlen)
  275. len = maxlen;
  276. return copy_to_user(p, bits, len) ? -EFAULT : len;
  277. }
  278. #endif /* __BIG_ENDIAN */
  279. #else
  280. static int bits_to_user(unsigned long *bits, unsigned int maxbit,
  281. unsigned int maxlen, void __user *p, int compat)
  282. {
  283. int len = NBITS(maxbit) * sizeof(long);
  284. if (len > maxlen)
  285. len = maxlen;
  286. return copy_to_user(p, bits, len) ? -EFAULT : len;
  287. }
  288. #endif /* CONFIG_COMPAT */
  289. static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
  290. {
  291. int len;
  292. if (!str)
  293. return -ENOENT;
  294. len = strlen(str) + 1;
  295. if (len > maxlen)
  296. len = maxlen;
  297. return copy_to_user(p, str, len) ? -EFAULT : len;
  298. }
  299. static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
  300. void __user *p, int compat_mode)
  301. {
  302. struct evdev_list *list = file->private_data;
  303. struct evdev *evdev = list->evdev;
  304. struct input_dev *dev = evdev->handle.dev;
  305. struct input_absinfo abs;
  306. struct ff_effect effect;
  307. int __user *ip = (int __user *)p;
  308. int i, t, u, v;
  309. int error;
  310. if (!evdev->exist)
  311. return -ENODEV;
  312. switch (cmd) {
  313. case EVIOCGVERSION:
  314. return put_user(EV_VERSION, ip);
  315. case EVIOCGID:
  316. if (copy_to_user(p, &dev->id, sizeof(struct input_id)))
  317. return -EFAULT;
  318. return 0;
  319. case EVIOCGREP:
  320. if (!test_bit(EV_REP, dev->evbit))
  321. return -ENOSYS;
  322. if (put_user(dev->rep[REP_DELAY], ip))
  323. return -EFAULT;
  324. if (put_user(dev->rep[REP_PERIOD], ip + 1))
  325. return -EFAULT;
  326. return 0;
  327. case EVIOCSREP:
  328. if (!test_bit(EV_REP, dev->evbit))
  329. return -ENOSYS;
  330. if (get_user(u, ip))
  331. return -EFAULT;
  332. if (get_user(v, ip + 1))
  333. return -EFAULT;
  334. input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u);
  335. input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v);
  336. return 0;
  337. case EVIOCGKEYCODE:
  338. if (get_user(t, ip))
  339. return -EFAULT;
  340. if (t < 0 || t >= dev->keycodemax || !dev->keycodesize)
  341. return -EINVAL;
  342. if (put_user(INPUT_KEYCODE(dev, t), ip + 1))
  343. return -EFAULT;
  344. return 0;
  345. case EVIOCSKEYCODE:
  346. if (get_user(t, ip))
  347. return -EFAULT;
  348. if (t < 0 || t >= dev->keycodemax || !dev->keycodesize)
  349. return -EINVAL;
  350. if (get_user(v, ip + 1))
  351. return -EFAULT;
  352. if (v < 0 || v > KEY_MAX)
  353. return -EINVAL;
  354. if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8)))
  355. return -EINVAL;
  356. u = SET_INPUT_KEYCODE(dev, t, v);
  357. clear_bit(u, dev->keybit);
  358. set_bit(v, dev->keybit);
  359. for (i = 0; i < dev->keycodemax; i++)
  360. if (INPUT_KEYCODE(dev, i) == u)
  361. set_bit(u, dev->keybit);
  362. return 0;
  363. case EVIOCSFF:
  364. if (copy_from_user(&effect, p, sizeof(effect)))
  365. return -EFAULT;
  366. error = input_ff_upload(dev, &effect, file);
  367. if (put_user(effect.id, &(((struct ff_effect __user *)p)->id)))
  368. return -EFAULT;
  369. return error;
  370. case EVIOCRMFF:
  371. return input_ff_erase(dev, (int)(unsigned long) p, file);
  372. case EVIOCGEFFECTS:
  373. i = test_bit(EV_FF, dev->evbit) ? dev->ff->max_effects : 0;
  374. if (put_user(i, ip))
  375. return -EFAULT;
  376. return 0;
  377. case EVIOCGRAB:
  378. if (p) {
  379. if (evdev->grab)
  380. return -EBUSY;
  381. if (input_grab_device(&evdev->handle))
  382. return -EBUSY;
  383. evdev->grab = list;
  384. return 0;
  385. } else {
  386. if (evdev->grab != list)
  387. return -EINVAL;
  388. input_release_device(&evdev->handle);
  389. evdev->grab = NULL;
  390. return 0;
  391. }
  392. default:
  393. if (_IOC_TYPE(cmd) != 'E')
  394. return -EINVAL;
  395. if (_IOC_DIR(cmd) == _IOC_READ) {
  396. if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) {
  397. long *bits;
  398. int len;
  399. switch (_IOC_NR(cmd) & EV_MAX) {
  400. case 0: bits = dev->evbit; len = EV_MAX; break;
  401. case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
  402. case EV_REL: bits = dev->relbit; len = REL_MAX; break;
  403. case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
  404. case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
  405. case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
  406. case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
  407. case EV_FF: bits = dev->ffbit; len = FF_MAX; break;
  408. case EV_SW: bits = dev->swbit; len = SW_MAX; break;
  409. default: return -EINVAL;
  410. }
  411. return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
  412. }
  413. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0)))
  414. return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd),
  415. p, compat_mode);
  416. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0)))
  417. return bits_to_user(dev->led, LED_MAX, _IOC_SIZE(cmd),
  418. p, compat_mode);
  419. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0)))
  420. return bits_to_user(dev->snd, SND_MAX, _IOC_SIZE(cmd),
  421. p, compat_mode);
  422. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSW(0)))
  423. return bits_to_user(dev->sw, SW_MAX, _IOC_SIZE(cmd),
  424. p, compat_mode);
  425. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
  426. return str_to_user(dev->name, _IOC_SIZE(cmd), p);
  427. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
  428. return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
  429. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0)))
  430. return str_to_user(dev->uniq, _IOC_SIZE(cmd), p);
  431. if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) {
  432. int t = _IOC_NR(cmd) & ABS_MAX;
  433. abs.value = dev->abs[t];
  434. abs.minimum = dev->absmin[t];
  435. abs.maximum = dev->absmax[t];
  436. abs.fuzz = dev->absfuzz[t];
  437. abs.flat = dev->absflat[t];
  438. if (copy_to_user(p, &abs, sizeof(struct input_absinfo)))
  439. return -EFAULT;
  440. return 0;
  441. }
  442. }
  443. if (_IOC_DIR(cmd) == _IOC_WRITE) {
  444. if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) {
  445. int t = _IOC_NR(cmd) & ABS_MAX;
  446. if (copy_from_user(&abs, p, sizeof(struct input_absinfo)))
  447. return -EFAULT;
  448. dev->abs[t] = abs.value;
  449. dev->absmin[t] = abs.minimum;
  450. dev->absmax[t] = abs.maximum;
  451. dev->absfuzz[t] = abs.fuzz;
  452. dev->absflat[t] = abs.flat;
  453. return 0;
  454. }
  455. }
  456. }
  457. return -EINVAL;
  458. }
  459. static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  460. {
  461. return evdev_ioctl_handler(file, cmd, (void __user *)arg, 0);
  462. }
  463. #ifdef CONFIG_COMPAT
  464. static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
  465. {
  466. return evdev_ioctl_handler(file, cmd, compat_ptr(arg), 1);
  467. }
  468. #endif
  469. static const struct file_operations evdev_fops = {
  470. .owner = THIS_MODULE,
  471. .read = evdev_read,
  472. .write = evdev_write,
  473. .poll = evdev_poll,
  474. .open = evdev_open,
  475. .release = evdev_release,
  476. .unlocked_ioctl = evdev_ioctl,
  477. #ifdef CONFIG_COMPAT
  478. .compat_ioctl = evdev_ioctl_compat,
  479. #endif
  480. .fasync = evdev_fasync,
  481. .flush = evdev_flush
  482. };
  483. static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev,
  484. const struct input_device_id *id)
  485. {
  486. struct evdev *evdev;
  487. struct class_device *cdev;
  488. int minor;
  489. for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++);
  490. if (minor == EVDEV_MINORS) {
  491. printk(KERN_ERR "evdev: no more free evdev devices\n");
  492. return NULL;
  493. }
  494. if (!(evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL)))
  495. return NULL;
  496. INIT_LIST_HEAD(&evdev->list);
  497. init_waitqueue_head(&evdev->wait);
  498. evdev->exist = 1;
  499. evdev->minor = minor;
  500. evdev->handle.dev = dev;
  501. evdev->handle.name = evdev->name;
  502. evdev->handle.handler = handler;
  503. evdev->handle.private = evdev;
  504. sprintf(evdev->name, "event%d", minor);
  505. evdev_table[minor] = evdev;
  506. cdev = class_device_create(&input_class, &dev->cdev,
  507. MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
  508. dev->cdev.dev, evdev->name);
  509. /* temporary symlink to keep userspace happy */
  510. sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
  511. evdev->name);
  512. return &evdev->handle;
  513. }
  514. static void evdev_disconnect(struct input_handle *handle)
  515. {
  516. struct evdev *evdev = handle->private;
  517. struct evdev_list *list;
  518. sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name);
  519. class_device_destroy(&input_class,
  520. MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
  521. evdev->exist = 0;
  522. if (evdev->open) {
  523. input_flush_device(handle, NULL);
  524. input_close_device(handle);
  525. wake_up_interruptible(&evdev->wait);
  526. list_for_each_entry(list, &evdev->list, node)
  527. kill_fasync(&list->fasync, SIGIO, POLL_HUP);
  528. } else
  529. evdev_free(evdev);
  530. }
  531. static const struct input_device_id evdev_ids[] = {
  532. { .driver_info = 1 }, /* Matches all devices */
  533. { }, /* Terminating zero entry */
  534. };
  535. MODULE_DEVICE_TABLE(input, evdev_ids);
  536. static struct input_handler evdev_handler = {
  537. .event = evdev_event,
  538. .connect = evdev_connect,
  539. .disconnect = evdev_disconnect,
  540. .fops = &evdev_fops,
  541. .minor = EVDEV_MINOR_BASE,
  542. .name = "evdev",
  543. .id_table = evdev_ids,
  544. };
  545. static int __init evdev_init(void)
  546. {
  547. return input_register_handler(&evdev_handler);
  548. }
  549. static void __exit evdev_exit(void)
  550. {
  551. input_unregister_handler(&evdev_handler);
  552. }
  553. module_init(evdev_init);
  554. module_exit(evdev_exit);
  555. MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
  556. MODULE_DESCRIPTION("Input driver event char devices");
  557. MODULE_LICENSE("GPL");