aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c445
1 files changed, 287 insertions, 158 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 14ae5583e198..3b1685ff9d10 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -22,12 +22,12 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/poll.h> 23#include <linux/poll.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/devfs_fs_kernel.h>
26 25
27MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 26MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
28MODULE_DESCRIPTION("Input core"); 27MODULE_DESCRIPTION("Input core");
29MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
30 29
30EXPORT_SYMBOL(input_allocate_device);
31EXPORT_SYMBOL(input_register_device); 31EXPORT_SYMBOL(input_register_device);
32EXPORT_SYMBOL(input_unregister_device); 32EXPORT_SYMBOL(input_unregister_device);
33EXPORT_SYMBOL(input_register_handler); 33EXPORT_SYMBOL(input_register_handler);
@@ -39,7 +39,7 @@ EXPORT_SYMBOL(input_close_device);
39EXPORT_SYMBOL(input_accept_process); 39EXPORT_SYMBOL(input_accept_process);
40EXPORT_SYMBOL(input_flush_device); 40EXPORT_SYMBOL(input_flush_device);
41EXPORT_SYMBOL(input_event); 41EXPORT_SYMBOL(input_event);
42EXPORT_SYMBOL(input_class); 42EXPORT_SYMBOL_GPL(input_class);
43 43
44#define INPUT_DEVICES 256 44#define INPUT_DEVICES 256
45 45
@@ -316,124 +316,21 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st
316 return NULL; 316 return NULL;
317} 317}
318 318
319 319static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, int max)
320/*
321 * Input hotplugging interface - loading event handlers based on
322 * device bitfields.
323 */
324
325#ifdef CONFIG_HOTPLUG
326
327/*
328 * Input hotplugging invokes what /proc/sys/kernel/hotplug says
329 * (normally /sbin/hotplug) when input devices get added or removed.
330 *
331 * This invokes a user mode policy agent, typically helping to load driver
332 * or other modules, configure the device, and more. Drivers can provide
333 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
334 *
335 */
336
337#define SPRINTF_BIT_A(bit, name, max) \
338 do { \
339 envp[i++] = scratch; \
340 scratch += sprintf(scratch, name); \
341 for (j = NBITS(max) - 1; j >= 0; j--) \
342 if (dev->bit[j]) break; \
343 for (; j >= 0; j--) \
344 scratch += sprintf(scratch, "%lx ", dev->bit[j]); \
345 scratch++; \
346 } while (0)
347
348#define SPRINTF_BIT_A2(bit, name, max, ev) \
349 do { \
350 if (test_bit(ev, dev->evbit)) \
351 SPRINTF_BIT_A(bit, name, max); \
352 } while (0)
353
354static void input_call_hotplug(char *verb, struct input_dev *dev)
355{ 320{
356 char *argv[3], **envp, *buf, *scratch; 321 int i;
357 int i = 0, j, value; 322 int len = 0;
358
359 if (!hotplug_path[0]) {
360 printk(KERN_ERR "input.c: calling hotplug without a hotplug agent defined\n");
361 return;
362 }
363 if (in_interrupt()) {
364 printk(KERN_ERR "input.c: calling hotplug from interrupt\n");
365 return;
366 }
367 if (!current->fs->root) {
368 printk(KERN_WARNING "input.c: calling hotplug without valid filesystem\n");
369 return;
370 }
371 if (!(envp = (char **) kmalloc(20 * sizeof(char *), GFP_KERNEL))) {
372 printk(KERN_ERR "input.c: not enough memory allocating hotplug environment\n");
373 return;
374 }
375 if (!(buf = kmalloc(1024, GFP_KERNEL))) {
376 kfree (envp);
377 printk(KERN_ERR "input.c: not enough memory allocating hotplug environment\n");
378 return;
379 }
380
381 argv[0] = hotplug_path;
382 argv[1] = "input";
383 argv[2] = NULL;
384
385 envp[i++] = "HOME=/";
386 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
387
388 scratch = buf;
389
390 envp[i++] = scratch;
391 scratch += sprintf(scratch, "ACTION=%s", verb) + 1;
392
393 envp[i++] = scratch;
394 scratch += sprintf(scratch, "PRODUCT=%x/%x/%x/%x",
395 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version) + 1;
396
397 if (dev->name) {
398 envp[i++] = scratch;
399 scratch += sprintf(scratch, "NAME=%s", dev->name) + 1;
400 }
401
402 if (dev->phys) {
403 envp[i++] = scratch;
404 scratch += sprintf(scratch, "PHYS=%s", dev->phys) + 1;
405 }
406
407 SPRINTF_BIT_A(evbit, "EV=", EV_MAX);
408 SPRINTF_BIT_A2(keybit, "KEY=", KEY_MAX, EV_KEY);
409 SPRINTF_BIT_A2(relbit, "REL=", REL_MAX, EV_REL);
410 SPRINTF_BIT_A2(absbit, "ABS=", ABS_MAX, EV_ABS);
411 SPRINTF_BIT_A2(mscbit, "MSC=", MSC_MAX, EV_MSC);
412 SPRINTF_BIT_A2(ledbit, "LED=", LED_MAX, EV_LED);
413 SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND);
414 SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF);
415 SPRINTF_BIT_A2(swbit, "SW=", SW_MAX, EV_SW);
416
417 envp[i++] = NULL;
418
419#ifdef INPUT_DEBUG
420 printk(KERN_DEBUG "input.c: calling %s %s [%s %s %s %s %s]\n",
421 argv[0], argv[1], envp[0], envp[1], envp[2], envp[3], envp[4]);
422#endif
423
424 value = call_usermodehelper(argv [0], argv, envp, 0);
425 323
426 kfree(buf); 324 for (i = NBITS(max) - 1; i > 0; i--)
427 kfree(envp); 325 if (bitmap[i])
326 break;
428 327
429#ifdef INPUT_DEBUG 328 for (; i >= 0; i--)
430 if (value != 0) 329 len += snprintf(buf + len, max(buf_size - len, 0),
431 printk(KERN_DEBUG "input.c: hotplug returned %d\n", value); 330 "%lx%s", bitmap[i], i > 0 ? " " : "");
432#endif 331 return len;
433} 332}
434 333
435#endif
436
437#ifdef CONFIG_PROC_FS 334#ifdef CONFIG_PROC_FS
438 335
439static struct proc_dir_entry *proc_bus_input_dir; 336static struct proc_dir_entry *proc_bus_input_dir;
@@ -455,37 +352,39 @@ static unsigned int input_devices_poll(struct file *file, poll_table *wait)
455 return 0; 352 return 0;
456} 353}
457 354
458#define SPRINTF_BIT_B(bit, name, max) \ 355#define SPRINTF_BIT(ev, bm) \
459 do { \ 356 do { \
460 len += sprintf(buf + len, "B: %s", name); \ 357 len += sprintf(buf + len, "B: %s=", #ev); \
461 for (i = NBITS(max) - 1; i >= 0; i--) \ 358 len += input_print_bitmap(buf + len, INT_MAX, \
462 if (dev->bit[i]) break; \ 359 dev->bm##bit, ev##_MAX); \
463 for (; i >= 0; i--) \ 360 len += sprintf(buf + len, "\n"); \
464 len += sprintf(buf + len, "%lx ", dev->bit[i]); \
465 len += sprintf(buf + len, "\n"); \
466 } while (0) 361 } while (0)
467 362
468#define SPRINTF_BIT_B2(bit, name, max, ev) \ 363#define TEST_AND_SPRINTF_BIT(ev, bm) \
469 do { \ 364 do { \
470 if (test_bit(ev, dev->evbit)) \ 365 if (test_bit(EV_##ev, dev->evbit)) \
471 SPRINTF_BIT_B(bit, name, max); \ 366 SPRINTF_BIT(ev, bm); \
472 } while (0) 367 } while (0)
473 368
474static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) 369static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data)
475{ 370{
476 struct input_dev *dev; 371 struct input_dev *dev;
477 struct input_handle *handle; 372 struct input_handle *handle;
373 const char *path;
478 374
479 off_t at = 0; 375 off_t at = 0;
480 int i, len, cnt = 0; 376 int len, cnt = 0;
481 377
482 list_for_each_entry(dev, &input_dev_list, node) { 378 list_for_each_entry(dev, &input_dev_list, node) {
483 379
380 path = dev->dynalloc ? kobject_get_path(&dev->cdev.kobj, GFP_KERNEL) : NULL;
381
484 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", 382 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
485 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); 383 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
486 384
487 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); 385 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : "");
488 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : ""); 386 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : "");
387 len += sprintf(buf + len, "S: Sysfs=%s\n", path ? path : "");
489 len += sprintf(buf + len, "H: Handlers="); 388 len += sprintf(buf + len, "H: Handlers=");
490 389
491 list_for_each_entry(handle, &dev->h_list, d_node) 390 list_for_each_entry(handle, &dev->h_list, d_node)
@@ -493,15 +392,15 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
493 392
494 len += sprintf(buf + len, "\n"); 393 len += sprintf(buf + len, "\n");
495 394
496 SPRINTF_BIT_B(evbit, "EV=", EV_MAX); 395 SPRINTF_BIT(EV, ev);
497 SPRINTF_BIT_B2(keybit, "KEY=", KEY_MAX, EV_KEY); 396 TEST_AND_SPRINTF_BIT(KEY, key);
498 SPRINTF_BIT_B2(relbit, "REL=", REL_MAX, EV_REL); 397 TEST_AND_SPRINTF_BIT(REL, rel);
499 SPRINTF_BIT_B2(absbit, "ABS=", ABS_MAX, EV_ABS); 398 TEST_AND_SPRINTF_BIT(ABS, abs);
500 SPRINTF_BIT_B2(mscbit, "MSC=", MSC_MAX, EV_MSC); 399 TEST_AND_SPRINTF_BIT(MSC, msc);
501 SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED); 400 TEST_AND_SPRINTF_BIT(LED, led);
502 SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND); 401 TEST_AND_SPRINTF_BIT(SND, snd);
503 SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF); 402 TEST_AND_SPRINTF_BIT(FF, ff);
504 SPRINTF_BIT_B2(swbit, "SW=", SW_MAX, EV_SW); 403 TEST_AND_SPRINTF_BIT(SW, sw);
505 404
506 len += sprintf(buf + len, "\n"); 405 len += sprintf(buf + len, "\n");
507 406
@@ -516,6 +415,8 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
516 if (cnt >= count) 415 if (cnt >= count)
517 break; 416 break;
518 } 417 }
418
419 kfree(path);
519 } 420 }
520 421
521 if (&dev->node == &input_dev_list) 422 if (&dev->node == &input_dev_list)
@@ -606,6 +507,240 @@ static inline int input_proc_init(void) { return 0; }
606static inline void input_proc_exit(void) { } 507static inline void input_proc_exit(void) { }
607#endif 508#endif
608 509
510#define INPUT_DEV_STRING_ATTR_SHOW(name) \
511static ssize_t input_dev_show_##name(struct class_device *dev, char *buf) \
512{ \
513 struct input_dev *input_dev = to_input_dev(dev); \
514 int retval; \
515 \
516 retval = down_interruptible(&input_dev->sem); \
517 if (retval) \
518 return retval; \
519 \
520 retval = sprintf(buf, "%s\n", input_dev->name ? input_dev->name : ""); \
521 \
522 up(&input_dev->sem); \
523 \
524 return retval; \
525} \
526static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_##name, NULL);
527
528INPUT_DEV_STRING_ATTR_SHOW(name);
529INPUT_DEV_STRING_ATTR_SHOW(phys);
530INPUT_DEV_STRING_ATTR_SHOW(uniq);
531
532static struct attribute *input_dev_attrs[] = {
533 &class_device_attr_name.attr,
534 &class_device_attr_phys.attr,
535 &class_device_attr_uniq.attr,
536 NULL
537};
538
539static struct attribute_group input_dev_group = {
540 .attrs = input_dev_attrs,
541};
542
543#define INPUT_DEV_ID_ATTR(name) \
544static ssize_t input_dev_show_id_##name(struct class_device *dev, char *buf) \
545{ \
546 struct input_dev *input_dev = to_input_dev(dev); \
547 return sprintf(buf, "%04x\n", input_dev->id.name); \
548} \
549static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_id_##name, NULL);
550
551INPUT_DEV_ID_ATTR(bustype);
552INPUT_DEV_ID_ATTR(vendor);
553INPUT_DEV_ID_ATTR(product);
554INPUT_DEV_ID_ATTR(version);
555
556static struct attribute *input_dev_id_attrs[] = {
557 &class_device_attr_bustype.attr,
558 &class_device_attr_vendor.attr,
559 &class_device_attr_product.attr,
560 &class_device_attr_version.attr,
561 NULL
562};
563
564static struct attribute_group input_dev_id_attr_group = {
565 .name = "id",
566 .attrs = input_dev_id_attrs,
567};
568
569#define INPUT_DEV_CAP_ATTR(ev, bm) \
570static ssize_t input_dev_show_cap_##bm(struct class_device *dev, char *buf) \
571{ \
572 struct input_dev *input_dev = to_input_dev(dev); \
573 return input_print_bitmap(buf, PAGE_SIZE, input_dev->bm##bit, ev##_MAX);\
574} \
575static CLASS_DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL);
576
577INPUT_DEV_CAP_ATTR(EV, ev);
578INPUT_DEV_CAP_ATTR(KEY, key);
579INPUT_DEV_CAP_ATTR(REL, rel);
580INPUT_DEV_CAP_ATTR(ABS, abs);
581INPUT_DEV_CAP_ATTR(MSC, msc);
582INPUT_DEV_CAP_ATTR(LED, led);
583INPUT_DEV_CAP_ATTR(SND, snd);
584INPUT_DEV_CAP_ATTR(FF, ff);
585INPUT_DEV_CAP_ATTR(SW, sw);
586
587static struct attribute *input_dev_caps_attrs[] = {
588 &class_device_attr_ev.attr,
589 &class_device_attr_key.attr,
590 &class_device_attr_rel.attr,
591 &class_device_attr_abs.attr,
592 &class_device_attr_msc.attr,
593 &class_device_attr_led.attr,
594 &class_device_attr_snd.attr,
595 &class_device_attr_ff.attr,
596 &class_device_attr_sw.attr,
597 NULL
598};
599
600static struct attribute_group input_dev_caps_attr_group = {
601 .name = "capabilities",
602 .attrs = input_dev_caps_attrs,
603};
604
605static void input_dev_release(struct class_device *class_dev)
606{
607 struct input_dev *dev = to_input_dev(class_dev);
608
609 kfree(dev);
610 module_put(THIS_MODULE);
611}
612
613/*
614 * Input hotplugging interface - loading event handlers based on
615 * device bitfields.
616 */
617static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index,
618 char *buffer, int buffer_size, int *cur_len,
619 const char *name, unsigned long *bitmap, int max)
620{
621 if (*cur_index >= num_envp - 1)
622 return -ENOMEM;
623
624 envp[*cur_index] = buffer + *cur_len;
625
626 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), name);
627 if (*cur_len > buffer_size)
628 return -ENOMEM;
629
630 *cur_len += input_print_bitmap(buffer + *cur_len,
631 max(buffer_size - *cur_len, 0),
632 bitmap, max) + 1;
633 if (*cur_len > buffer_size)
634 return -ENOMEM;
635
636 (*cur_index)++;
637 return 0;
638}
639
640#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
641 do { \
642 int err = add_hotplug_env_var(envp, num_envp, &i, \
643 buffer, buffer_size, &len, \
644 fmt, val); \
645 if (err) \
646 return err; \
647 } while (0)
648
649#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \
650 do { \
651 int err = input_add_hotplug_bm_var(envp, num_envp, &i, \
652 buffer, buffer_size, &len, \
653 name, bm, max); \
654 if (err) \
655 return err; \
656 } while (0)
657
658static int input_dev_hotplug(struct class_device *cdev, char **envp,
659 int num_envp, char *buffer, int buffer_size)
660{
661 struct input_dev *dev = to_input_dev(cdev);
662 int i = 0;
663 int len = 0;
664
665 INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x",
666 dev->id.bustype, dev->id.vendor,
667 dev->id.product, dev->id.version);
668 if (dev->name)
669 INPUT_ADD_HOTPLUG_VAR("NAME=\"%s\"", dev->name);
670 if (dev->phys)
671 INPUT_ADD_HOTPLUG_VAR("PHYS=\"%s\"", dev->phys);
672 if (dev->phys)
673 INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq);
674
675 INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX);
676 if (test_bit(EV_KEY, dev->evbit))
677 INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX);
678 if (test_bit(EV_REL, dev->evbit))
679 INPUT_ADD_HOTPLUG_BM_VAR("REL=", dev->relbit, REL_MAX);
680 if (test_bit(EV_ABS, dev->evbit))
681 INPUT_ADD_HOTPLUG_BM_VAR("ABS=", dev->absbit, ABS_MAX);
682 if (test_bit(EV_MSC, dev->evbit))
683 INPUT_ADD_HOTPLUG_BM_VAR("MSC=", dev->mscbit, MSC_MAX);
684 if (test_bit(EV_LED, dev->evbit))
685 INPUT_ADD_HOTPLUG_BM_VAR("LED=", dev->ledbit, LED_MAX);
686 if (test_bit(EV_SND, dev->evbit))
687 INPUT_ADD_HOTPLUG_BM_VAR("SND=", dev->sndbit, SND_MAX);
688 if (test_bit(EV_FF, dev->evbit))
689 INPUT_ADD_HOTPLUG_BM_VAR("FF=", dev->ffbit, FF_MAX);
690 if (test_bit(EV_SW, dev->evbit))
691 INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
692
693 envp[i] = NULL;
694
695 return 0;
696}
697
698struct class input_class = {
699 .name = "input",
700 .release = input_dev_release,
701 .hotplug = input_dev_hotplug,
702};
703
704struct input_dev *input_allocate_device(void)
705{
706 struct input_dev *dev;
707
708 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
709 if (dev) {
710 dev->dynalloc = 1;
711 dev->cdev.class = &input_class;
712 class_device_initialize(&dev->cdev);
713 INIT_LIST_HEAD(&dev->h_list);
714 INIT_LIST_HEAD(&dev->node);
715 }
716
717 return dev;
718}
719
720static void input_register_classdevice(struct input_dev *dev)
721{
722 static atomic_t input_no = ATOMIC_INIT(0);
723 const char *path;
724
725 __module_get(THIS_MODULE);
726
727 dev->dev = dev->cdev.dev;
728
729 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
730 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
731
732 path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL);
733 printk(KERN_INFO "input: %s/%s as %s\n",
734 dev->name ? dev->name : "Unspecified device",
735 path ? path : "", dev->cdev.class_id);
736 kfree(path);
737
738 class_device_add(&dev->cdev);
739 sysfs_create_group(&dev->cdev.kobj, &input_dev_group);
740 sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
741 sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
742}
743
609void input_register_device(struct input_dev *dev) 744void input_register_device(struct input_dev *dev)
610{ 745{
611 struct input_handle *handle; 746 struct input_handle *handle;
@@ -632,15 +767,15 @@ void input_register_device(struct input_dev *dev)
632 INIT_LIST_HEAD(&dev->h_list); 767 INIT_LIST_HEAD(&dev->h_list);
633 list_add_tail(&dev->node, &input_dev_list); 768 list_add_tail(&dev->node, &input_dev_list);
634 769
770 if (dev->dynalloc)
771 input_register_classdevice(dev);
772
635 list_for_each_entry(handler, &input_handler_list, node) 773 list_for_each_entry(handler, &input_handler_list, node)
636 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 774 if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
637 if ((id = input_match_device(handler->id_table, dev))) 775 if ((id = input_match_device(handler->id_table, dev)))
638 if ((handle = handler->connect(handler, dev, id))) 776 if ((handle = handler->connect(handler, dev, id)))
639 input_link_handle(handle); 777 input_link_handle(handle);
640 778
641#ifdef CONFIG_HOTPLUG
642 input_call_hotplug("add", dev);
643#endif
644 779
645 input_wakeup_procfs_readers(); 780 input_wakeup_procfs_readers();
646} 781}
@@ -660,12 +795,14 @@ void input_unregister_device(struct input_dev *dev)
660 handle->handler->disconnect(handle); 795 handle->handler->disconnect(handle);
661 } 796 }
662 797
663#ifdef CONFIG_HOTPLUG
664 input_call_hotplug("remove", dev);
665#endif
666
667 list_del_init(&dev->node); 798 list_del_init(&dev->node);
668 799
800 if (dev->dynalloc) {
801 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
802 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
803 class_device_unregister(&dev->cdev);
804 }
805
669 input_wakeup_procfs_readers(); 806 input_wakeup_procfs_readers();
670} 807}
671 808
@@ -748,16 +885,14 @@ static struct file_operations input_fops = {
748 .open = input_open_file, 885 .open = input_open_file,
749}; 886};
750 887
751struct class *input_class;
752
753static int __init input_init(void) 888static int __init input_init(void)
754{ 889{
755 int err; 890 int err;
756 891
757 input_class = class_create(THIS_MODULE, "input"); 892 err = class_register(&input_class);
758 if (IS_ERR(input_class)) { 893 if (err) {
759 printk(KERN_ERR "input: unable to register input class\n"); 894 printk(KERN_ERR "input: unable to register input_dev class\n");
760 return PTR_ERR(input_class); 895 return err;
761 } 896 }
762 897
763 err = input_proc_init(); 898 err = input_proc_init();
@@ -770,24 +905,18 @@ static int __init input_init(void)
770 goto fail2; 905 goto fail2;
771 } 906 }
772 907
773 err = devfs_mk_dir("input");
774 if (err)
775 goto fail3;
776
777 return 0; 908 return 0;
778 909
779 fail3: unregister_chrdev(INPUT_MAJOR, "input");
780 fail2: input_proc_exit(); 910 fail2: input_proc_exit();
781 fail1: class_destroy(input_class); 911 fail1: class_unregister(&input_class);
782 return err; 912 return err;
783} 913}
784 914
785static void __exit input_exit(void) 915static void __exit input_exit(void)
786{ 916{
787 input_proc_exit(); 917 input_proc_exit();
788 devfs_remove("input");
789 unregister_chrdev(INPUT_MAJOR, "input"); 918 unregister_chrdev(INPUT_MAJOR, "input");
790 class_destroy(input_class); 919 class_unregister(&input_class);
791} 920}
792 921
793subsys_initcall(input_init); 922subsys_initcall(input_init);