Commit 4263cf0fac28122c8381b6f4f9441a43cd93c81f

Authored by Dmitry Torokhov
1 parent 68c2a1607c

Input: make input_register_handler() return error codes

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Showing 9 changed files with 34 additions and 22 deletions Side-by-side Diff

drivers/char/keyboard.c
... ... @@ -1362,6 +1362,7 @@
1362 1362 int __init kbd_init(void)
1363 1363 {
1364 1364 int i;
  1365 + int error;
1365 1366  
1366 1367 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1367 1368 kbd_table[i].ledflagstate = KBD_DEFLEDS;
... ... @@ -1373,7 +1374,9 @@
1373 1374 kbd_table[i].kbdmode = VC_XLATE;
1374 1375 }
1375 1376  
1376   - input_register_handler(&kbd_handler);
  1377 + error = input_register_handler(&kbd_handler);
  1378 + if (error)
  1379 + return error;
1377 1380  
1378 1381 tasklet_enable(&keyboard_tasklet);
1379 1382 tasklet_schedule(&keyboard_tasklet);
drivers/input/evbug.c
... ... @@ -91,8 +91,7 @@
91 91  
92 92 static int __init evbug_init(void)
93 93 {
94   - input_register_handler(&evbug_handler);
95   - return 0;
  94 + return input_register_handler(&evbug_handler);
96 95 }
97 96  
98 97 static void __exit evbug_exit(void)
drivers/input/evdev.c
... ... @@ -695,8 +695,7 @@
695 695  
696 696 static int __init evdev_init(void)
697 697 {
698   - input_register_handler(&evdev_handler);
699   - return 0;
  698 + return input_register_handler(&evdev_handler);
700 699 }
701 700  
702 701 static void __exit evdev_exit(void)
drivers/input/input.c
... ... @@ -1037,19 +1037,20 @@
1037 1037 }
1038 1038 EXPORT_SYMBOL(input_unregister_device);
1039 1039  
1040   -void input_register_handler(struct input_handler *handler)
  1040 +int input_register_handler(struct input_handler *handler)
1041 1041 {
1042 1042 struct input_dev *dev;
1043 1043 struct input_handle *handle;
1044 1044 const struct input_device_id *id;
1045 1045  
1046   - if (!handler)
1047   - return;
1048   -
1049 1046 INIT_LIST_HEAD(&handler->h_list);
1050 1047  
1051   - if (handler->fops != NULL)
  1048 + if (handler->fops != NULL) {
  1049 + if (input_table[handler->minor >> 5])
  1050 + return -EBUSY;
  1051 +
1052 1052 input_table[handler->minor >> 5] = handler;
  1053 + }
1053 1054  
1054 1055 list_add_tail(&handler->node, &input_handler_list);
1055 1056  
... ... @@ -1063,6 +1064,7 @@
1063 1064 }
1064 1065  
1065 1066 input_wakeup_procfs_readers();
  1067 + return 0;
1066 1068 }
1067 1069 EXPORT_SYMBOL(input_register_handler);
1068 1070  
drivers/input/joydev.c
... ... @@ -606,8 +606,7 @@
606 606  
607 607 static int __init joydev_init(void)
608 608 {
609   - input_register_handler(&joydev_handler);
610   - return 0;
  609 + return input_register_handler(&joydev_handler);
611 610 }
612 611  
613 612 static void __exit joydev_exit(void)
drivers/input/mousedev.c
... ... @@ -738,8 +738,13 @@
738 738  
739 739 static int __init mousedev_init(void)
740 740 {
741   - input_register_handler(&mousedev_handler);
  741 + struct class_device *cdev;
  742 + int error;
742 743  
  744 + error = input_register_handler(&mousedev_handler);
  745 + if (error)
  746 + return error;
  747 +
743 748 memset(&mousedev_mix, 0, sizeof(struct mousedev));
744 749 INIT_LIST_HEAD(&mousedev_mix.list);
745 750 init_waitqueue_head(&mousedev_mix.wait);
746 751  
747 752  
... ... @@ -747,12 +752,20 @@
747 752 mousedev_mix.exist = 1;
748 753 mousedev_mix.minor = MOUSEDEV_MIX;
749 754  
750   - class_device_create(&input_class, NULL,
  755 + cdev = class_device_create(&input_class, NULL,
751 756 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");
  757 + if (IS_ERR(cdev)) {
  758 + input_unregister_handler(&mousedev_handler);
  759 + return PTR_ERR(cdev);
  760 + }
752 761  
753 762 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
754   - if (!(psaux_registered = !misc_register(&psaux_mouse)))
755   - printk(KERN_WARNING "mice: could not misc_register the device\n");
  763 + error = misc_register(&psaux_mouse);
  764 + if (error)
  765 + printk(KERN_WARNING "mice: could not register psaux device, "
  766 + "error: %d\n", error);
  767 + else
  768 + psaux_registered = 1;
756 769 #endif
757 770  
758 771 printk(KERN_INFO "mice: PS/2 mouse device common for all mice\n");
drivers/input/power.c
... ... @@ -150,8 +150,7 @@
150 150  
151 151 static int __init power_init(void)
152 152 {
153   - input_register_handler(&power_handler);
154   - return 0;
  153 + return input_register_handler(&power_handler);
155 154 }
156 155  
157 156 static void __exit power_exit(void)
drivers/input/tsdev.c
... ... @@ -479,9 +479,7 @@
479 479  
480 480 static int __init tsdev_init(void)
481 481 {
482   - input_register_handler(&tsdev_handler);
483   - printk(KERN_INFO "ts: Compaq touchscreen protocol output\n");
484   - return 0;
  482 + return input_register_handler(&tsdev_handler);
485 483 }
486 484  
487 485 static void __exit tsdev_exit(void)
include/linux/input.h
... ... @@ -1106,7 +1106,7 @@
1106 1106 int input_register_device(struct input_dev *);
1107 1107 void input_unregister_device(struct input_dev *);
1108 1108  
1109   -void input_register_handler(struct input_handler *);
  1109 +int input_register_handler(struct input_handler *);
1110 1110 void input_unregister_handler(struct input_handler *);
1111 1111  
1112 1112 int input_grab_device(struct input_handle *);