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.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 9cb4b9a54f01..1c8c8a5bc4a9 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -176,6 +176,10 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
176 break; 176 break;
177 177
178 case EV_FF: 178 case EV_FF:
179
180 if (value < 0)
181 return;
182
179 if (dev->event) 183 if (dev->event)
180 dev->event(dev, type, code, value); 184 dev->event(dev, type, code, value);
181 break; 185 break;
@@ -309,7 +313,8 @@ static void input_link_handle(struct input_handle *handle)
309 if (i != NBITS(max)) \ 313 if (i != NBITS(max)) \
310 continue; 314 continue;
311 315
312static struct input_device_id *input_match_device(struct input_device_id *id, struct input_dev *dev) 316static const struct input_device_id *input_match_device(const struct input_device_id *id,
317 struct input_dev *dev)
313{ 318{
314 int i; 319 int i;
315 320
@@ -762,7 +767,9 @@ static void input_dev_release(struct class_device *class_dev)
762{ 767{
763 struct input_dev *dev = to_input_dev(class_dev); 768 struct input_dev *dev = to_input_dev(class_dev);
764 769
770 input_ff_destroy(dev);
765 kfree(dev); 771 kfree(dev);
772
766 module_put(THIS_MODULE); 773 module_put(THIS_MODULE);
767} 774}
768 775
@@ -899,12 +906,13 @@ struct input_dev *input_allocate_device(void)
899 906
900 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); 907 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
901 if (dev) { 908 if (dev) {
902 dev->dynalloc = 1;
903 dev->cdev.class = &input_class; 909 dev->cdev.class = &input_class;
904 class_device_initialize(&dev->cdev); 910 class_device_initialize(&dev->cdev);
905 mutex_init(&dev->mutex); 911 mutex_init(&dev->mutex);
906 INIT_LIST_HEAD(&dev->h_list); 912 INIT_LIST_HEAD(&dev->h_list);
907 INIT_LIST_HEAD(&dev->node); 913 INIT_LIST_HEAD(&dev->node);
914
915 __module_get(THIS_MODULE);
908 } 916 }
909 917
910 return dev; 918 return dev;
@@ -929,17 +937,10 @@ int input_register_device(struct input_dev *dev)
929 static atomic_t input_no = ATOMIC_INIT(0); 937 static atomic_t input_no = ATOMIC_INIT(0);
930 struct input_handle *handle; 938 struct input_handle *handle;
931 struct input_handler *handler; 939 struct input_handler *handler;
932 struct input_device_id *id; 940 const struct input_device_id *id;
933 const char *path; 941 const char *path;
934 int error; 942 int error;
935 943
936 if (!dev->dynalloc) {
937 printk(KERN_WARNING "input: device %s is statically allocated, will not register\n"
938 "Please convert to input_allocate_device() or contact dtor_core@ameritech.net\n",
939 dev->name ? dev->name : "<Unknown>");
940 return -EINVAL;
941 }
942
943 set_bit(EV_SYN, dev->evbit); 944 set_bit(EV_SYN, dev->evbit);
944 945
945 /* 946 /*
@@ -955,10 +956,8 @@ int input_register_device(struct input_dev *dev)
955 dev->rep[REP_PERIOD] = 33; 956 dev->rep[REP_PERIOD] = 33;
956 } 957 }
957 958
958 INIT_LIST_HEAD(&dev->h_list);
959 list_add_tail(&dev->node, &input_dev_list); 959 list_add_tail(&dev->node, &input_dev_list);
960 960
961 dev->cdev.class = &input_class;
962 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id), 961 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
963 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); 962 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
964 963
@@ -978,8 +977,6 @@ int input_register_device(struct input_dev *dev)
978 if (error) 977 if (error)
979 goto fail3; 978 goto fail3;
980 979
981 __module_get(THIS_MODULE);
982
983 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); 980 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
984 printk(KERN_INFO "input: %s as %s\n", 981 printk(KERN_INFO "input: %s as %s\n",
985 dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); 982 dev->name ? dev->name : "Unspecified device", path ? path : "N/A");
@@ -1008,9 +1005,12 @@ EXPORT_SYMBOL(input_register_device);
1008void input_unregister_device(struct input_dev *dev) 1005void input_unregister_device(struct input_dev *dev)
1009{ 1006{
1010 struct list_head *node, *next; 1007 struct list_head *node, *next;
1008 int code;
1011 1009
1012 if (!dev) 1010 for (code = 0; code <= KEY_MAX; code++)
1013 return; 1011 if (test_bit(code, dev->key))
1012 input_report_key(dev, code, 0);
1013 input_sync(dev);
1014 1014
1015 del_timer_sync(&dev->timer); 1015 del_timer_sync(&dev->timer);
1016 1016
@@ -1037,19 +1037,20 @@ void input_unregister_device(struct input_dev *dev)
1037} 1037}
1038EXPORT_SYMBOL(input_unregister_device); 1038EXPORT_SYMBOL(input_unregister_device);
1039 1039
1040void input_register_handler(struct input_handler *handler) 1040int input_register_handler(struct input_handler *handler)
1041{ 1041{
1042 struct input_dev *dev; 1042 struct input_dev *dev;
1043 struct input_handle *handle; 1043 struct input_handle *handle;
1044 struct input_device_id *id; 1044 const struct input_device_id *id;
1045
1046 if (!handler)
1047 return;
1048 1045
1049 INIT_LIST_HEAD(&handler->h_list); 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 input_table[handler->minor >> 5] = handler; 1052 input_table[handler->minor >> 5] = handler;
1053 }
1053 1054
1054 list_add_tail(&handler->node, &input_handler_list); 1055 list_add_tail(&handler->node, &input_handler_list);
1055 1056
@@ -1063,6 +1064,7 @@ void input_register_handler(struct input_handler *handler)
1063 } 1064 }
1064 1065
1065 input_wakeup_procfs_readers(); 1066 input_wakeup_procfs_readers();
1067 return 0;
1066} 1068}
1067EXPORT_SYMBOL(input_register_handler); 1069EXPORT_SYMBOL(input_register_handler);
1068 1070