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.c85
1 files changed, 57 insertions, 28 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 3038c268917d..de2e7546b491 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -28,20 +28,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
28MODULE_DESCRIPTION("Input core"); 28MODULE_DESCRIPTION("Input core");
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
31EXPORT_SYMBOL(input_allocate_device);
32EXPORT_SYMBOL(input_register_device);
33EXPORT_SYMBOL(input_unregister_device);
34EXPORT_SYMBOL(input_register_handler);
35EXPORT_SYMBOL(input_unregister_handler);
36EXPORT_SYMBOL(input_grab_device);
37EXPORT_SYMBOL(input_release_device);
38EXPORT_SYMBOL(input_open_device);
39EXPORT_SYMBOL(input_close_device);
40EXPORT_SYMBOL(input_accept_process);
41EXPORT_SYMBOL(input_flush_device);
42EXPORT_SYMBOL(input_event);
43EXPORT_SYMBOL_GPL(input_class);
44
45#define INPUT_DEVICES 256 31#define INPUT_DEVICES 256
46 32
47static LIST_HEAD(input_dev_list); 33static LIST_HEAD(input_dev_list);
@@ -63,11 +49,13 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
63 case EV_SYN: 49 case EV_SYN:
64 switch (code) { 50 switch (code) {
65 case SYN_CONFIG: 51 case SYN_CONFIG:
66 if (dev->event) dev->event(dev, type, code, value); 52 if (dev->event)
53 dev->event(dev, type, code, value);
67 break; 54 break;
68 55
69 case SYN_REPORT: 56 case SYN_REPORT:
70 if (dev->sync) return; 57 if (dev->sync)
58 return;
71 dev->sync = 1; 59 dev->sync = 1;
72 break; 60 break;
73 } 61 }
@@ -136,7 +124,8 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
136 if (code > MSC_MAX || !test_bit(code, dev->mscbit)) 124 if (code > MSC_MAX || !test_bit(code, dev->mscbit))
137 return; 125 return;
138 126
139 if (dev->event) dev->event(dev, type, code, value); 127 if (dev->event)
128 dev->event(dev, type, code, value);
140 129
141 break; 130 break;
142 131
@@ -146,7 +135,9 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
146 return; 135 return;
147 136
148 change_bit(code, dev->led); 137 change_bit(code, dev->led);
149 if (dev->event) dev->event(dev, type, code, value); 138
139 if (dev->event)
140 dev->event(dev, type, code, value);
150 141
151 break; 142 break;
152 143
@@ -158,21 +149,25 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
158 if (!!test_bit(code, dev->snd) != !!value) 149 if (!!test_bit(code, dev->snd) != !!value)
159 change_bit(code, dev->snd); 150 change_bit(code, dev->snd);
160 151
161 if (dev->event) dev->event(dev, type, code, value); 152 if (dev->event)
153 dev->event(dev, type, code, value);
162 154
163 break; 155 break;
164 156
165 case EV_REP: 157 case EV_REP:
166 158
167 if (code > REP_MAX || value < 0 || dev->rep[code] == value) return; 159 if (code > REP_MAX || value < 0 || dev->rep[code] == value)
160 return;
168 161
169 dev->rep[code] = value; 162 dev->rep[code] = value;
170 if (dev->event) dev->event(dev, type, code, value); 163 if (dev->event)
164 dev->event(dev, type, code, value);
171 165
172 break; 166 break;
173 167
174 case EV_FF: 168 case EV_FF:
175 if (dev->event) dev->event(dev, type, code, value); 169 if (dev->event)
170 dev->event(dev, type, code, value);
176 break; 171 break;
177 } 172 }
178 173
@@ -186,6 +181,7 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
186 if (handle->open) 181 if (handle->open)
187 handle->handler->event(handle, type, code, value); 182 handle->handler->event(handle, type, code, value);
188} 183}
184EXPORT_SYMBOL(input_event);
189 185
190static void input_repeat_key(unsigned long data) 186static void input_repeat_key(unsigned long data)
191{ 187{
@@ -208,6 +204,7 @@ int input_accept_process(struct input_handle *handle, struct file *file)
208 204
209 return 0; 205 return 0;
210} 206}
207EXPORT_SYMBOL(input_accept_process);
211 208
212int input_grab_device(struct input_handle *handle) 209int input_grab_device(struct input_handle *handle)
213{ 210{
@@ -217,12 +214,14 @@ int input_grab_device(struct input_handle *handle)
217 handle->dev->grab = handle; 214 handle->dev->grab = handle;
218 return 0; 215 return 0;
219} 216}
217EXPORT_SYMBOL(input_grab_device);
220 218
221void input_release_device(struct input_handle *handle) 219void input_release_device(struct input_handle *handle)
222{ 220{
223 if (handle->dev->grab == handle) 221 if (handle->dev->grab == handle)
224 handle->dev->grab = NULL; 222 handle->dev->grab = NULL;
225} 223}
224EXPORT_SYMBOL(input_release_device);
226 225
227int input_open_device(struct input_handle *handle) 226int input_open_device(struct input_handle *handle)
228{ 227{
@@ -245,6 +244,7 @@ int input_open_device(struct input_handle *handle)
245 244
246 return err; 245 return err;
247} 246}
247EXPORT_SYMBOL(input_open_device);
248 248
249int input_flush_device(struct input_handle* handle, struct file* file) 249int input_flush_device(struct input_handle* handle, struct file* file)
250{ 250{
@@ -253,6 +253,7 @@ int input_flush_device(struct input_handle* handle, struct file* file)
253 253
254 return 0; 254 return 0;
255} 255}
256EXPORT_SYMBOL(input_flush_device);
256 257
257void input_close_device(struct input_handle *handle) 258void input_close_device(struct input_handle *handle)
258{ 259{
@@ -268,6 +269,7 @@ void input_close_device(struct input_handle *handle)
268 269
269 mutex_unlock(&dev->mutex); 270 mutex_unlock(&dev->mutex);
270} 271}
272EXPORT_SYMBOL(input_close_device);
271 273
272static void input_link_handle(struct input_handle *handle) 274static void input_link_handle(struct input_handle *handle)
273{ 275{
@@ -335,9 +337,11 @@ static inline void input_wakeup_procfs_readers(void)
335static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) 337static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
336{ 338{
337 int state = input_devices_state; 339 int state = input_devices_state;
340
338 poll_wait(file, &input_devices_poll_wait, wait); 341 poll_wait(file, &input_devices_poll_wait, wait);
339 if (state != input_devices_state) 342 if (state != input_devices_state)
340 return POLLIN | POLLRDNORM; 343 return POLLIN | POLLRDNORM;
344
341 return 0; 345 return 0;
342} 346}
343 347
@@ -629,7 +633,7 @@ static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
629 633
630 len = input_print_modalias(buf, PAGE_SIZE, id, 1); 634 len = input_print_modalias(buf, PAGE_SIZE, id, 1);
631 635
632 return max_t(int, len, PAGE_SIZE); 636 return min_t(int, len, PAGE_SIZE);
633} 637}
634static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); 638static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
635 639
@@ -862,6 +866,7 @@ struct class input_class = {
862 .release = input_dev_release, 866 .release = input_dev_release,
863 .uevent = input_dev_uevent, 867 .uevent = input_dev_uevent,
864}; 868};
869EXPORT_SYMBOL_GPL(input_class);
865 870
866struct input_dev *input_allocate_device(void) 871struct input_dev *input_allocate_device(void)
867{ 872{
@@ -872,12 +877,27 @@ struct input_dev *input_allocate_device(void)
872 dev->dynalloc = 1; 877 dev->dynalloc = 1;
873 dev->cdev.class = &input_class; 878 dev->cdev.class = &input_class;
874 class_device_initialize(&dev->cdev); 879 class_device_initialize(&dev->cdev);
880 mutex_init(&dev->mutex);
875 INIT_LIST_HEAD(&dev->h_list); 881 INIT_LIST_HEAD(&dev->h_list);
876 INIT_LIST_HEAD(&dev->node); 882 INIT_LIST_HEAD(&dev->node);
877 } 883 }
878 884
879 return dev; 885 return dev;
880} 886}
887EXPORT_SYMBOL(input_allocate_device);
888
889void input_free_device(struct input_dev *dev)
890{
891 if (dev) {
892
893 mutex_lock(&dev->mutex);
894 dev->name = dev->phys = dev->uniq = NULL;
895 mutex_unlock(&dev->mutex);
896
897 input_put_device(dev);
898 }
899}
900EXPORT_SYMBOL(input_free_device);
881 901
882int input_register_device(struct input_dev *dev) 902int input_register_device(struct input_dev *dev)
883{ 903{
@@ -895,7 +915,6 @@ int input_register_device(struct input_dev *dev)
895 return -EINVAL; 915 return -EINVAL;
896 } 916 }
897 917
898 mutex_init(&dev->mutex);
899 set_bit(EV_SYN, dev->evbit); 918 set_bit(EV_SYN, dev->evbit);
900 919
901 /* 920 /*
@@ -956,12 +975,14 @@ int input_register_device(struct input_dev *dev)
956 fail1: class_device_del(&dev->cdev); 975 fail1: class_device_del(&dev->cdev);
957 return error; 976 return error;
958} 977}
978EXPORT_SYMBOL(input_register_device);
959 979
960void input_unregister_device(struct input_dev *dev) 980void input_unregister_device(struct input_dev *dev)
961{ 981{
962 struct list_head * node, * next; 982 struct list_head *node, *next;
963 983
964 if (!dev) return; 984 if (!dev)
985 return;
965 986
966 del_timer_sync(&dev->timer); 987 del_timer_sync(&dev->timer);
967 988
@@ -979,8 +1000,13 @@ void input_unregister_device(struct input_dev *dev)
979 sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); 1000 sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
980 class_device_unregister(&dev->cdev); 1001 class_device_unregister(&dev->cdev);
981 1002
1003 mutex_lock(&dev->mutex);
1004 dev->name = dev->phys = dev->uniq = NULL;
1005 mutex_unlock(&dev->mutex);
1006
982 input_wakeup_procfs_readers(); 1007 input_wakeup_procfs_readers();
983} 1008}
1009EXPORT_SYMBOL(input_unregister_device);
984 1010
985void input_register_handler(struct input_handler *handler) 1011void input_register_handler(struct input_handler *handler)
986{ 1012{
@@ -988,7 +1014,8 @@ void input_register_handler(struct input_handler *handler)
988 struct input_handle *handle; 1014 struct input_handle *handle;
989 struct input_device_id *id; 1015 struct input_device_id *id;
990 1016
991 if (!handler) return; 1017 if (!handler)
1018 return;
992 1019
993 INIT_LIST_HEAD(&handler->h_list); 1020 INIT_LIST_HEAD(&handler->h_list);
994 1021
@@ -1005,10 +1032,11 @@ void input_register_handler(struct input_handler *handler)
1005 1032
1006 input_wakeup_procfs_readers(); 1033 input_wakeup_procfs_readers();
1007} 1034}
1035EXPORT_SYMBOL(input_register_handler);
1008 1036
1009void input_unregister_handler(struct input_handler *handler) 1037void input_unregister_handler(struct input_handler *handler)
1010{ 1038{
1011 struct list_head * node, * next; 1039 struct list_head *node, *next;
1012 1040
1013 list_for_each_safe(node, next, &handler->h_list) { 1041 list_for_each_safe(node, next, &handler->h_list) {
1014 struct input_handle * handle = to_handle_h(node); 1042 struct input_handle * handle = to_handle_h(node);
@@ -1024,6 +1052,7 @@ void input_unregister_handler(struct input_handler *handler)
1024 1052
1025 input_wakeup_procfs_readers(); 1053 input_wakeup_procfs_readers();
1026} 1054}
1055EXPORT_SYMBOL(input_unregister_handler);
1027 1056
1028static int input_open_file(struct inode *inode, struct file *file) 1057static int input_open_file(struct inode *inode, struct file *file)
1029{ 1058{