evdev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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. error = dev->getkeycode(dev, t, &v);
  341. if (error)
  342. return error;
  343. if (put_user(v, ip + 1))
  344. return -EFAULT;
  345. return 0;
  346. case EVIOCSKEYCODE:
  347. if (get_user(t, ip) || get_user(v, ip + 1))
  348. return -EFAULT;
  349. return dev->setkeycode(dev, t, v);
  350. case EVIOCSFF:
  351. if (copy_from_user(&effect, p, sizeof(effect)))
  352. return -EFAULT;
  353. error = input_ff_upload(dev, &effect, file);
  354. if (put_user(effect.id, &(((struct ff_effect __user *)p)->id)))
  355. return -EFAULT;
  356. return error;
  357. case EVIOCRMFF:
  358. return input_ff_erase(dev, (int)(unsigned long) p, file);
  359. case EVIOCGEFFECTS:
  360. i = test_bit(EV_FF, dev->evbit) ? dev->ff->max_effects : 0;
  361. if (put_user(i, ip))
  362. return -EFAULT;
  363. return 0;
  364. case EVIOCGRAB:
  365. if (p) {
  366. if (evdev->grab)
  367. return -EBUSY;
  368. if (input_grab_device(&evdev->handle))
  369. return -EBUSY;
  370. evdev->grab = list;
  371. return 0;
  372. } else {
  373. if (evdev->grab != list)
  374. return -EINVAL;
  375. input_release_device(&evdev->handle);
  376. evdev->grab = NULL;
  377. return 0;
  378. }
  379. default:
  380. if (_IOC_TYPE(cmd) != 'E')
  381. return -EINVAL;
  382. if (_IOC_DIR(cmd) == _IOC_READ) {
  383. if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) {
  384. long *bits;
  385. int len;
  386. switch (_IOC_NR(cmd) & EV_MAX) {
  387. case 0: bits = dev->evbit; len = EV_MAX; break;
  388. case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
  389. case EV_REL: bits = dev->relbit; len = REL_MAX; break;
  390. case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
  391. case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
  392. case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
  393. case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
  394. case EV_FF: bits = dev->ffbit; len = FF_MAX; break;
  395. case EV_SW: bits = dev->swbit; len = SW_MAX; break;
  396. default: return -EINVAL;
  397. }
  398. return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
  399. }
  400. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0)))
  401. return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd),
  402. p, compat_mode);
  403. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0)))
  404. return bits_to_user(dev->led, LED_MAX, _IOC_SIZE(cmd),
  405. p, compat_mode);
  406. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0)))
  407. return bits_to_user(dev->snd, SND_MAX, _IOC_SIZE(cmd),
  408. p, compat_mode);
  409. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSW(0)))
  410. return bits_to_user(dev->sw, SW_MAX, _IOC_SIZE(cmd),
  411. p, compat_mode);
  412. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
  413. return str_to_user(dev->name, _IOC_SIZE(cmd), p);
  414. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
  415. return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
  416. if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0)))
  417. return str_to_user(dev->uniq, _IOC_SIZE(cmd), p);
  418. if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) {
  419. int t = _IOC_NR(cmd) & ABS_MAX;
  420. abs.value = dev->abs[t];
  421. abs.minimum = dev->absmin[t];
  422. abs.maximum = dev->absmax[t];
  423. abs.fuzz = dev->absfuzz[t];
  424. abs.flat = dev->absflat[t];
  425. if (copy_to_user(p, &abs, sizeof(struct input_absinfo)))
  426. return -EFAULT;
  427. return 0;
  428. }
  429. }
  430. if (_IOC_DIR(cmd) == _IOC_WRITE) {
  431. if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) {
  432. int t = _IOC_NR(cmd) & ABS_MAX;
  433. if (copy_from_user(&abs, p, sizeof(struct input_absinfo)))
  434. return -EFAULT;
  435. dev->abs[t] = abs.value;
  436. dev->absmin[t] = abs.minimum;
  437. dev->absmax[t] = abs.maximum;
  438. dev->absfuzz[t] = abs.fuzz;
  439. dev->absflat[t] = abs.flat;
  440. return 0;
  441. }
  442. }
  443. }
  444. return -EINVAL;
  445. }
  446. static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  447. {
  448. return evdev_ioctl_handler(file, cmd, (void __user *)arg, 0);
  449. }
  450. #ifdef CONFIG_COMPAT
  451. static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
  452. {
  453. return evdev_ioctl_handler(file, cmd, compat_ptr(arg), 1);
  454. }
  455. #endif
  456. static const struct file_operations evdev_fops = {
  457. .owner = THIS_MODULE,
  458. .read = evdev_read,
  459. .write = evdev_write,
  460. .poll = evdev_poll,
  461. .open = evdev_open,
  462. .release = evdev_release,
  463. .unlocked_ioctl = evdev_ioctl,
  464. #ifdef CONFIG_COMPAT
  465. .compat_ioctl = evdev_ioctl_compat,
  466. #endif
  467. .fasync = evdev_fasync,
  468. .flush = evdev_flush
  469. };
  470. static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
  471. const struct input_device_id *id)
  472. {
  473. struct evdev *evdev;
  474. struct class_device *cdev;
  475. dev_t devt;
  476. int minor;
  477. int error;
  478. for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++);
  479. if (minor == EVDEV_MINORS) {
  480. printk(KERN_ERR "evdev: no more free evdev devices\n");
  481. return -ENFILE;
  482. }
  483. evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL);
  484. if (!evdev)
  485. return -ENOMEM;
  486. INIT_LIST_HEAD(&evdev->list);
  487. init_waitqueue_head(&evdev->wait);
  488. evdev->exist = 1;
  489. evdev->minor = minor;
  490. evdev->handle.dev = dev;
  491. evdev->handle.name = evdev->name;
  492. evdev->handle.handler = handler;
  493. evdev->handle.private = evdev;
  494. sprintf(evdev->name, "event%d", minor);
  495. evdev_table[minor] = evdev;
  496. devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
  497. cdev = class_device_create(&input_class, &dev->cdev, devt,
  498. dev->cdev.dev, evdev->name);
  499. if (IS_ERR(cdev)) {
  500. error = PTR_ERR(cdev);
  501. goto err_free_evdev;
  502. }
  503. /* temporary symlink to keep userspace happy */
  504. error = sysfs_create_link(&input_class.subsys.kset.kobj,
  505. &cdev->kobj, evdev->name);
  506. if (error)
  507. goto err_cdev_destroy;
  508. error = input_register_handle(&evdev->handle);
  509. if (error)
  510. goto err_remove_link;
  511. return 0;
  512. err_remove_link:
  513. sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name);
  514. err_cdev_destroy:
  515. class_device_destroy(&input_class, devt);
  516. err_free_evdev:
  517. kfree(evdev);
  518. evdev_table[minor] = NULL;
  519. return error;
  520. }
  521. static void evdev_disconnect(struct input_handle *handle)
  522. {
  523. struct evdev *evdev = handle->private;
  524. struct evdev_list *list;
  525. input_unregister_handle(handle);
  526. sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name);
  527. class_device_destroy(&input_class,
  528. MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
  529. evdev->exist = 0;
  530. if (evdev->open) {
  531. input_flush_device(handle, NULL);
  532. input_close_device(handle);
  533. wake_up_interruptible(&evdev->wait);
  534. list_for_each_entry(list, &evdev->list, node)
  535. kill_fasync(&list->fasync, SIGIO, POLL_HUP);
  536. } else
  537. evdev_free(evdev);
  538. }
  539. static const struct input_device_id evdev_ids[] = {
  540. { .driver_info = 1 }, /* Matches all devices */
  541. { }, /* Terminating zero entry */
  542. };
  543. MODULE_DEVICE_TABLE(input, evdev_ids);
  544. static struct input_handler evdev_handler = {
  545. .event = evdev_event,
  546. .connect = evdev_connect,
  547. .disconnect = evdev_disconnect,
  548. .fops = &evdev_fops,
  549. .minor = EVDEV_MINOR_BASE,
  550. .name = "evdev",
  551. .id_table = evdev_ids,
  552. };
  553. static int __init evdev_init(void)
  554. {
  555. return input_register_handler(&evdev_handler);
  556. }
  557. static void __exit evdev_exit(void)
  558. {
  559. input_unregister_handler(&evdev_handler);
  560. }
  561. module_init(evdev_init);
  562. module_exit(evdev_exit);
  563. MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
  564. MODULE_DESCRIPTION("Input driver event char devices");
  565. MODULE_LICENSE("GPL");