joydev.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. * Joystick device driver for the input driver suite.
  3. *
  4. * Copyright (c) 1999-2002 Vojtech Pavlik
  5. * Copyright (c) 1999 Colin Van Dyke
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <asm/io.h>
  13. #include <asm/system.h>
  14. #include <linux/delay.h>
  15. #include <linux/errno.h>
  16. #include <linux/joystick.h>
  17. #include <linux/input.h>
  18. #include <linux/kernel.h>
  19. #include <linux/major.h>
  20. #include <linux/slab.h>
  21. #include <linux/mm.h>
  22. #include <linux/miscdevice.h>
  23. #include <linux/module.h>
  24. #include <linux/poll.h>
  25. #include <linux/init.h>
  26. #include <linux/smp_lock.h>
  27. #include <linux/device.h>
  28. MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
  29. MODULE_DESCRIPTION("Joystick device interfaces");
  30. MODULE_SUPPORTED_DEVICE("input/js");
  31. MODULE_LICENSE("GPL");
  32. #define JOYDEV_MINOR_BASE 0
  33. #define JOYDEV_MINORS 16
  34. #define JOYDEV_BUFFER_SIZE 64
  35. struct joydev {
  36. int exist;
  37. int open;
  38. int minor;
  39. char name[16];
  40. struct input_handle handle;
  41. wait_queue_head_t wait;
  42. struct list_head list;
  43. struct js_corr corr[ABS_MAX + 1];
  44. struct JS_DATA_SAVE_TYPE glue;
  45. int nabs;
  46. int nkey;
  47. __u16 keymap[KEY_MAX - BTN_MISC + 1];
  48. __u16 keypam[KEY_MAX - BTN_MISC + 1];
  49. __u8 absmap[ABS_MAX + 1];
  50. __u8 abspam[ABS_MAX + 1];
  51. __s16 abs[ABS_MAX + 1];
  52. };
  53. struct joydev_list {
  54. struct js_event buffer[JOYDEV_BUFFER_SIZE];
  55. int head;
  56. int tail;
  57. int startup;
  58. struct fasync_struct *fasync;
  59. struct joydev *joydev;
  60. struct list_head node;
  61. };
  62. static struct joydev *joydev_table[JOYDEV_MINORS];
  63. static int joydev_correct(int value, struct js_corr *corr)
  64. {
  65. switch (corr->type) {
  66. case JS_CORR_NONE:
  67. break;
  68. case JS_CORR_BROKEN:
  69. value = value > corr->coef[0] ? (value < corr->coef[1] ? 0 :
  70. ((corr->coef[3] * (value - corr->coef[1])) >> 14)) :
  71. ((corr->coef[2] * (value - corr->coef[0])) >> 14);
  72. break;
  73. default:
  74. return 0;
  75. }
  76. return value < -32767 ? -32767 : (value > 32767 ? 32767 : value);
  77. }
  78. static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
  79. {
  80. struct joydev *joydev = handle->private;
  81. struct joydev_list *list;
  82. struct js_event event;
  83. switch (type) {
  84. case EV_KEY:
  85. if (code < BTN_MISC || value == 2)
  86. return;
  87. event.type = JS_EVENT_BUTTON;
  88. event.number = joydev->keymap[code - BTN_MISC];
  89. event.value = value;
  90. break;
  91. case EV_ABS:
  92. event.type = JS_EVENT_AXIS;
  93. event.number = joydev->absmap[code];
  94. event.value = joydev_correct(value, joydev->corr + event.number);
  95. if (event.value == joydev->abs[event.number])
  96. return;
  97. joydev->abs[event.number] = event.value;
  98. break;
  99. default:
  100. return;
  101. }
  102. event.time = jiffies_to_msecs(jiffies);
  103. list_for_each_entry(list, &joydev->list, node) {
  104. memcpy(list->buffer + list->head, &event, sizeof(struct js_event));
  105. if (list->startup == joydev->nabs + joydev->nkey)
  106. if (list->tail == (list->head = (list->head + 1) & (JOYDEV_BUFFER_SIZE - 1)))
  107. list->startup = 0;
  108. kill_fasync(&list->fasync, SIGIO, POLL_IN);
  109. }
  110. wake_up_interruptible(&joydev->wait);
  111. }
  112. static int joydev_fasync(int fd, struct file *file, int on)
  113. {
  114. int retval;
  115. struct joydev_list *list = file->private_data;
  116. retval = fasync_helper(fd, file, on, &list->fasync);
  117. return retval < 0 ? retval : 0;
  118. }
  119. static void joydev_free(struct joydev *joydev)
  120. {
  121. joydev_table[joydev->minor] = NULL;
  122. kfree(joydev);
  123. }
  124. static int joydev_release(struct inode * inode, struct file * file)
  125. {
  126. struct joydev_list *list = file->private_data;
  127. joydev_fasync(-1, file, 0);
  128. list_del(&list->node);
  129. if (!--list->joydev->open) {
  130. if (list->joydev->exist)
  131. input_close_device(&list->joydev->handle);
  132. else
  133. joydev_free(list->joydev);
  134. }
  135. kfree(list);
  136. return 0;
  137. }
  138. static int joydev_open(struct inode *inode, struct file *file)
  139. {
  140. struct joydev_list *list;
  141. int i = iminor(inode) - JOYDEV_MINOR_BASE;
  142. if (i >= JOYDEV_MINORS || !joydev_table[i])
  143. return -ENODEV;
  144. if (!(list = kzalloc(sizeof(struct joydev_list), GFP_KERNEL)))
  145. return -ENOMEM;
  146. list->joydev = joydev_table[i];
  147. list_add_tail(&list->node, &joydev_table[i]->list);
  148. file->private_data = list;
  149. if (!list->joydev->open++)
  150. if (list->joydev->exist)
  151. input_open_device(&list->joydev->handle);
  152. return 0;
  153. }
  154. static ssize_t joydev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos)
  155. {
  156. return -EINVAL;
  157. }
  158. static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
  159. {
  160. struct joydev_list *list = file->private_data;
  161. struct joydev *joydev = list->joydev;
  162. struct input_dev *input = joydev->handle.dev;
  163. int retval = 0;
  164. if (!list->joydev->exist)
  165. return -ENODEV;
  166. if (count < sizeof(struct js_event))
  167. return -EINVAL;
  168. if (count == sizeof(struct JS_DATA_TYPE)) {
  169. struct JS_DATA_TYPE data;
  170. int i;
  171. for (data.buttons = i = 0; i < 32 && i < joydev->nkey; i++)
  172. data.buttons |= test_bit(joydev->keypam[i], input->key) ? (1 << i) : 0;
  173. data.x = (joydev->abs[0] / 256 + 128) >> joydev->glue.JS_CORR.x;
  174. data.y = (joydev->abs[1] / 256 + 128) >> joydev->glue.JS_CORR.y;
  175. if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE)))
  176. return -EFAULT;
  177. list->startup = 0;
  178. list->tail = list->head;
  179. return sizeof(struct JS_DATA_TYPE);
  180. }
  181. if (list->startup == joydev->nabs + joydev->nkey &&
  182. list->head == list->tail && (file->f_flags & O_NONBLOCK))
  183. return -EAGAIN;
  184. retval = wait_event_interruptible(list->joydev->wait,
  185. !list->joydev->exist ||
  186. list->startup < joydev->nabs + joydev->nkey ||
  187. list->head != list->tail);
  188. if (retval)
  189. return retval;
  190. if (!list->joydev->exist)
  191. return -ENODEV;
  192. while (list->startup < joydev->nabs + joydev->nkey && retval + sizeof(struct js_event) <= count) {
  193. struct js_event event;
  194. event.time = jiffies_to_msecs(jiffies);
  195. if (list->startup < joydev->nkey) {
  196. event.type = JS_EVENT_BUTTON | JS_EVENT_INIT;
  197. event.number = list->startup;
  198. event.value = !!test_bit(joydev->keypam[event.number], input->key);
  199. } else {
  200. event.type = JS_EVENT_AXIS | JS_EVENT_INIT;
  201. event.number = list->startup - joydev->nkey;
  202. event.value = joydev->abs[event.number];
  203. }
  204. if (copy_to_user(buf + retval, &event, sizeof(struct js_event)))
  205. return -EFAULT;
  206. list->startup++;
  207. retval += sizeof(struct js_event);
  208. }
  209. while (list->head != list->tail && retval + sizeof(struct js_event) <= count) {
  210. if (copy_to_user(buf + retval, list->buffer + list->tail, sizeof(struct js_event)))
  211. return -EFAULT;
  212. list->tail = (list->tail + 1) & (JOYDEV_BUFFER_SIZE - 1);
  213. retval += sizeof(struct js_event);
  214. }
  215. return retval;
  216. }
  217. /* No kernel lock - fine */
  218. static unsigned int joydev_poll(struct file *file, poll_table *wait)
  219. {
  220. struct joydev_list *list = file->private_data;
  221. poll_wait(file, &list->joydev->wait, wait);
  222. return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ?
  223. (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR));
  224. }
  225. static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp)
  226. {
  227. struct input_dev *dev = joydev->handle.dev;
  228. int i, j;
  229. switch (cmd) {
  230. case JS_SET_CAL:
  231. return copy_from_user(&joydev->glue.JS_CORR, argp,
  232. sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0;
  233. case JS_GET_CAL:
  234. return copy_to_user(argp, &joydev->glue.JS_CORR,
  235. sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0;
  236. case JS_SET_TIMEOUT:
  237. return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp);
  238. case JS_GET_TIMEOUT:
  239. return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp);
  240. case JSIOCGVERSION:
  241. return put_user(JS_VERSION, (__u32 __user *) argp);
  242. case JSIOCGAXES:
  243. return put_user(joydev->nabs, (__u8 __user *) argp);
  244. case JSIOCGBUTTONS:
  245. return put_user(joydev->nkey, (__u8 __user *) argp);
  246. case JSIOCSCORR:
  247. if (copy_from_user(joydev->corr, argp,
  248. sizeof(joydev->corr[0]) * joydev->nabs))
  249. return -EFAULT;
  250. for (i = 0; i < joydev->nabs; i++) {
  251. j = joydev->abspam[i];
  252. joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i);
  253. }
  254. return 0;
  255. case JSIOCGCORR:
  256. return copy_to_user(argp, joydev->corr,
  257. sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0;
  258. case JSIOCSAXMAP:
  259. if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1)))
  260. return -EFAULT;
  261. for (i = 0; i < joydev->nabs; i++) {
  262. if (joydev->abspam[i] > ABS_MAX)
  263. return -EINVAL;
  264. joydev->absmap[joydev->abspam[i]] = i;
  265. }
  266. return 0;
  267. case JSIOCGAXMAP:
  268. return copy_to_user(argp, joydev->abspam,
  269. sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0;
  270. case JSIOCSBTNMAP:
  271. if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)))
  272. return -EFAULT;
  273. for (i = 0; i < joydev->nkey; i++) {
  274. if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC)
  275. return -EINVAL;
  276. joydev->keymap[joydev->keypam[i] - BTN_MISC] = i;
  277. }
  278. return 0;
  279. case JSIOCGBTNMAP:
  280. return copy_to_user(argp, joydev->keypam,
  281. sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0;
  282. default:
  283. if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) {
  284. int len;
  285. if (!dev->name)
  286. return 0;
  287. len = strlen(dev->name) + 1;
  288. if (len > _IOC_SIZE(cmd))
  289. len = _IOC_SIZE(cmd);
  290. if (copy_to_user(argp, dev->name, len))
  291. return -EFAULT;
  292. return len;
  293. }
  294. }
  295. return -EINVAL;
  296. }
  297. #ifdef CONFIG_COMPAT
  298. static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  299. {
  300. struct joydev_list *list = file->private_data;
  301. struct joydev *joydev = list->joydev;
  302. void __user *argp = (void __user *)arg;
  303. s32 tmp32;
  304. struct JS_DATA_SAVE_TYPE_32 ds32;
  305. int err;
  306. if (!joydev->exist)
  307. return -ENODEV;
  308. switch(cmd) {
  309. case JS_SET_TIMELIMIT:
  310. err = get_user(tmp32, (s32 __user *) arg);
  311. if (err == 0)
  312. joydev->glue.JS_TIMELIMIT = tmp32;
  313. break;
  314. case JS_GET_TIMELIMIT:
  315. tmp32 = joydev->glue.JS_TIMELIMIT;
  316. err = put_user(tmp32, (s32 __user *) arg);
  317. break;
  318. case JS_SET_ALL:
  319. err = copy_from_user(&ds32, argp,
  320. sizeof(ds32)) ? -EFAULT : 0;
  321. if (err == 0) {
  322. joydev->glue.JS_TIMEOUT = ds32.JS_TIMEOUT;
  323. joydev->glue.BUSY = ds32.BUSY;
  324. joydev->glue.JS_EXPIRETIME = ds32.JS_EXPIRETIME;
  325. joydev->glue.JS_TIMELIMIT = ds32.JS_TIMELIMIT;
  326. joydev->glue.JS_SAVE = ds32.JS_SAVE;
  327. joydev->glue.JS_CORR = ds32.JS_CORR;
  328. }
  329. break;
  330. case JS_GET_ALL:
  331. ds32.JS_TIMEOUT = joydev->glue.JS_TIMEOUT;
  332. ds32.BUSY = joydev->glue.BUSY;
  333. ds32.JS_EXPIRETIME = joydev->glue.JS_EXPIRETIME;
  334. ds32.JS_TIMELIMIT = joydev->glue.JS_TIMELIMIT;
  335. ds32.JS_SAVE = joydev->glue.JS_SAVE;
  336. ds32.JS_CORR = joydev->glue.JS_CORR;
  337. err = copy_to_user(argp, &ds32, sizeof(ds32)) ? -EFAULT : 0;
  338. break;
  339. default:
  340. err = joydev_ioctl_common(joydev, cmd, argp);
  341. }
  342. return err;
  343. }
  344. #endif /* CONFIG_COMPAT */
  345. static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
  346. {
  347. struct joydev_list *list = file->private_data;
  348. struct joydev *joydev = list->joydev;
  349. void __user *argp = (void __user *)arg;
  350. if (!joydev->exist)
  351. return -ENODEV;
  352. switch(cmd) {
  353. case JS_SET_TIMELIMIT:
  354. return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg);
  355. case JS_GET_TIMELIMIT:
  356. return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg);
  357. case JS_SET_ALL:
  358. return copy_from_user(&joydev->glue, argp,
  359. sizeof(joydev->glue)) ? -EFAULT : 0;
  360. case JS_GET_ALL:
  361. return copy_to_user(argp, &joydev->glue,
  362. sizeof(joydev->glue)) ? -EFAULT : 0;
  363. default:
  364. return joydev_ioctl_common(joydev, cmd, argp);
  365. }
  366. }
  367. static const struct file_operations joydev_fops = {
  368. .owner = THIS_MODULE,
  369. .read = joydev_read,
  370. .write = joydev_write,
  371. .poll = joydev_poll,
  372. .open = joydev_open,
  373. .release = joydev_release,
  374. .ioctl = joydev_ioctl,
  375. #ifdef CONFIG_COMPAT
  376. .compat_ioctl = joydev_compat_ioctl,
  377. #endif
  378. .fasync = joydev_fasync,
  379. };
  380. static struct input_handle *joydev_connect(struct input_handler *handler, struct input_dev *dev,
  381. const struct input_device_id *id)
  382. {
  383. struct joydev *joydev;
  384. struct class_device *cdev;
  385. int i, j, t, minor;
  386. for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
  387. if (minor == JOYDEV_MINORS) {
  388. printk(KERN_ERR "joydev: no more free joydev devices\n");
  389. return NULL;
  390. }
  391. if (!(joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL)))
  392. return NULL;
  393. INIT_LIST_HEAD(&joydev->list);
  394. init_waitqueue_head(&joydev->wait);
  395. joydev->minor = minor;
  396. joydev->exist = 1;
  397. joydev->handle.dev = dev;
  398. joydev->handle.name = joydev->name;
  399. joydev->handle.handler = handler;
  400. joydev->handle.private = joydev;
  401. sprintf(joydev->name, "js%d", minor);
  402. for (i = 0; i < ABS_MAX + 1; i++)
  403. if (test_bit(i, dev->absbit)) {
  404. joydev->absmap[i] = joydev->nabs;
  405. joydev->abspam[joydev->nabs] = i;
  406. joydev->nabs++;
  407. }
  408. for (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
  409. if (test_bit(i + BTN_MISC, dev->keybit)) {
  410. joydev->keymap[i] = joydev->nkey;
  411. joydev->keypam[joydev->nkey] = i + BTN_MISC;
  412. joydev->nkey++;
  413. }
  414. for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
  415. if (test_bit(i + BTN_MISC, dev->keybit)) {
  416. joydev->keymap[i] = joydev->nkey;
  417. joydev->keypam[joydev->nkey] = i + BTN_MISC;
  418. joydev->nkey++;
  419. }
  420. for (i = 0; i < joydev->nabs; i++) {
  421. j = joydev->abspam[i];
  422. if (dev->absmax[j] == dev->absmin[j]) {
  423. joydev->corr[i].type = JS_CORR_NONE;
  424. joydev->abs[i] = dev->abs[j];
  425. continue;
  426. }
  427. joydev->corr[i].type = JS_CORR_BROKEN;
  428. joydev->corr[i].prec = dev->absfuzz[j];
  429. joydev->corr[i].coef[0] = (dev->absmax[j] + dev->absmin[j]) / 2 - dev->absflat[j];
  430. joydev->corr[i].coef[1] = (dev->absmax[j] + dev->absmin[j]) / 2 + dev->absflat[j];
  431. if (!(t = ((dev->absmax[j] - dev->absmin[j]) / 2 - 2 * dev->absflat[j])))
  432. continue;
  433. joydev->corr[i].coef[2] = (1 << 29) / t;
  434. joydev->corr[i].coef[3] = (1 << 29) / t;
  435. joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i);
  436. }
  437. joydev_table[minor] = joydev;
  438. cdev = class_device_create(&input_class, &dev->cdev,
  439. MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
  440. dev->cdev.dev, joydev->name);
  441. /* temporary symlink to keep userspace happy */
  442. sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
  443. joydev->name);
  444. return &joydev->handle;
  445. }
  446. static void joydev_disconnect(struct input_handle *handle)
  447. {
  448. struct joydev *joydev = handle->private;
  449. struct joydev_list *list;
  450. sysfs_remove_link(&input_class.subsys.kset.kobj, joydev->name);
  451. class_device_destroy(&input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
  452. joydev->exist = 0;
  453. if (joydev->open) {
  454. input_close_device(handle);
  455. wake_up_interruptible(&joydev->wait);
  456. list_for_each_entry(list, &joydev->list, node)
  457. kill_fasync(&list->fasync, SIGIO, POLL_HUP);
  458. } else
  459. joydev_free(joydev);
  460. }
  461. static const struct input_device_id joydev_blacklist[] = {
  462. {
  463. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
  464. .evbit = { BIT(EV_KEY) },
  465. .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
  466. }, /* Avoid itouchpads, touchscreens and tablets */
  467. { } /* Terminating entry */
  468. };
  469. static const struct input_device_id joydev_ids[] = {
  470. {
  471. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  472. .evbit = { BIT(EV_ABS) },
  473. .absbit = { BIT(ABS_X) },
  474. },
  475. {
  476. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  477. .evbit = { BIT(EV_ABS) },
  478. .absbit = { BIT(ABS_WHEEL) },
  479. },
  480. {
  481. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  482. .evbit = { BIT(EV_ABS) },
  483. .absbit = { BIT(ABS_THROTTLE) },
  484. },
  485. { } /* Terminating entry */
  486. };
  487. MODULE_DEVICE_TABLE(input, joydev_ids);
  488. static struct input_handler joydev_handler = {
  489. .event = joydev_event,
  490. .connect = joydev_connect,
  491. .disconnect = joydev_disconnect,
  492. .fops = &joydev_fops,
  493. .minor = JOYDEV_MINOR_BASE,
  494. .name = "joydev",
  495. .id_table = joydev_ids,
  496. .blacklist = joydev_blacklist,
  497. };
  498. static int __init joydev_init(void)
  499. {
  500. return input_register_handler(&joydev_handler);
  501. }
  502. static void __exit joydev_exit(void)
  503. {
  504. input_unregister_handler(&joydev_handler);
  505. }
  506. module_init(joydev_init);
  507. module_exit(joydev_exit);