diff options
Diffstat (limited to 'drivers/input')
35 files changed, 396 insertions, 221 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 5f561fce32d8..a29d5ceb00cf 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -78,14 +78,19 @@ static int evdev_fasync(int fd, struct file *file, int on) | |||
78 | { | 78 | { |
79 | int retval; | 79 | int retval; |
80 | struct evdev_list *list = file->private_data; | 80 | struct evdev_list *list = file->private_data; |
81 | |||
81 | retval = fasync_helper(fd, file, on, &list->fasync); | 82 | retval = fasync_helper(fd, file, on, &list->fasync); |
83 | |||
82 | return retval < 0 ? retval : 0; | 84 | return retval < 0 ? retval : 0; |
83 | } | 85 | } |
84 | 86 | ||
85 | static int evdev_flush(struct file * file, fl_owner_t id) | 87 | static int evdev_flush(struct file *file, fl_owner_t id) |
86 | { | 88 | { |
87 | struct evdev_list *list = file->private_data; | 89 | struct evdev_list *list = file->private_data; |
88 | if (!list->evdev->exist) return -ENODEV; | 90 | |
91 | if (!list->evdev->exist) | ||
92 | return -ENODEV; | ||
93 | |||
89 | return input_flush_device(&list->evdev->handle, file); | 94 | return input_flush_device(&list->evdev->handle, file); |
90 | } | 95 | } |
91 | 96 | ||
@@ -300,6 +305,7 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count | |||
300 | static unsigned int evdev_poll(struct file *file, poll_table *wait) | 305 | static unsigned int evdev_poll(struct file *file, poll_table *wait) |
301 | { | 306 | { |
302 | struct evdev_list *list = file->private_data; | 307 | struct evdev_list *list = file->private_data; |
308 | |||
303 | poll_wait(file, &list->evdev->wait, wait); | 309 | poll_wait(file, &list->evdev->wait, wait); |
304 | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | | 310 | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | |
305 | (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); | 311 | (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); |
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>"); | |||
28 | MODULE_DESCRIPTION("Input core"); | 28 | MODULE_DESCRIPTION("Input core"); |
29 | MODULE_LICENSE("GPL"); | 29 | MODULE_LICENSE("GPL"); |
30 | 30 | ||
31 | EXPORT_SYMBOL(input_allocate_device); | ||
32 | EXPORT_SYMBOL(input_register_device); | ||
33 | EXPORT_SYMBOL(input_unregister_device); | ||
34 | EXPORT_SYMBOL(input_register_handler); | ||
35 | EXPORT_SYMBOL(input_unregister_handler); | ||
36 | EXPORT_SYMBOL(input_grab_device); | ||
37 | EXPORT_SYMBOL(input_release_device); | ||
38 | EXPORT_SYMBOL(input_open_device); | ||
39 | EXPORT_SYMBOL(input_close_device); | ||
40 | EXPORT_SYMBOL(input_accept_process); | ||
41 | EXPORT_SYMBOL(input_flush_device); | ||
42 | EXPORT_SYMBOL(input_event); | ||
43 | EXPORT_SYMBOL_GPL(input_class); | ||
44 | |||
45 | #define INPUT_DEVICES 256 | 31 | #define INPUT_DEVICES 256 |
46 | 32 | ||
47 | static LIST_HEAD(input_dev_list); | 33 | static 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 | } |
184 | EXPORT_SYMBOL(input_event); | ||
189 | 185 | ||
190 | static void input_repeat_key(unsigned long data) | 186 | static 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 | } |
207 | EXPORT_SYMBOL(input_accept_process); | ||
211 | 208 | ||
212 | int input_grab_device(struct input_handle *handle) | 209 | int 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 | } |
217 | EXPORT_SYMBOL(input_grab_device); | ||
220 | 218 | ||
221 | void input_release_device(struct input_handle *handle) | 219 | void 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 | } |
224 | EXPORT_SYMBOL(input_release_device); | ||
226 | 225 | ||
227 | int input_open_device(struct input_handle *handle) | 226 | int 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 | } |
247 | EXPORT_SYMBOL(input_open_device); | ||
248 | 248 | ||
249 | int input_flush_device(struct input_handle* handle, struct file* file) | 249 | int 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 | } |
256 | EXPORT_SYMBOL(input_flush_device); | ||
256 | 257 | ||
257 | void input_close_device(struct input_handle *handle) | 258 | void 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 | } |
272 | EXPORT_SYMBOL(input_close_device); | ||
271 | 273 | ||
272 | static void input_link_handle(struct input_handle *handle) | 274 | static void input_link_handle(struct input_handle *handle) |
273 | { | 275 | { |
@@ -335,9 +337,11 @@ static inline void input_wakeup_procfs_readers(void) | |||
335 | static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) | 337 | static 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 | } |
634 | static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); | 638 | static 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 | }; |
869 | EXPORT_SYMBOL_GPL(input_class); | ||
865 | 870 | ||
866 | struct input_dev *input_allocate_device(void) | 871 | struct 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 | } |
887 | EXPORT_SYMBOL(input_allocate_device); | ||
888 | |||
889 | void 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 | } | ||
900 | EXPORT_SYMBOL(input_free_device); | ||
881 | 901 | ||
882 | int input_register_device(struct input_dev *dev) | 902 | int 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 | } |
978 | EXPORT_SYMBOL(input_register_device); | ||
959 | 979 | ||
960 | void input_unregister_device(struct input_dev *dev) | 980 | void 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 | } |
1009 | EXPORT_SYMBOL(input_unregister_device); | ||
984 | 1010 | ||
985 | void input_register_handler(struct input_handler *handler) | 1011 | void 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 | } |
1035 | EXPORT_SYMBOL(input_register_handler); | ||
1008 | 1036 | ||
1009 | void input_unregister_handler(struct input_handler *handler) | 1037 | void 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 | } |
1055 | EXPORT_SYMBOL(input_unregister_handler); | ||
1027 | 1056 | ||
1028 | static int input_open_file(struct inode *inode, struct file *file) | 1057 | static int input_open_file(struct inode *inode, struct file *file) |
1029 | { | 1058 | { |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 949bdcef8c2b..d67157513bf7 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -81,10 +81,7 @@ static int joydev_correct(int value, struct js_corr *corr) | |||
81 | return 0; | 81 | return 0; |
82 | } | 82 | } |
83 | 83 | ||
84 | if (value < -32767) return -32767; | 84 | return value < -32767 ? -32767 : (value > 32767 ? 32767 : value); |
85 | if (value > 32767) return 32767; | ||
86 | |||
87 | return value; | ||
88 | } | 85 | } |
89 | 86 | ||
90 | static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) | 87 | static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
@@ -96,7 +93,8 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne | |||
96 | switch (type) { | 93 | switch (type) { |
97 | 94 | ||
98 | case EV_KEY: | 95 | case EV_KEY: |
99 | if (code < BTN_MISC || value == 2) return; | 96 | if (code < BTN_MISC || value == 2) |
97 | return; | ||
100 | event.type = JS_EVENT_BUTTON; | 98 | event.type = JS_EVENT_BUTTON; |
101 | event.number = joydev->keymap[code - BTN_MISC]; | 99 | event.number = joydev->keymap[code - BTN_MISC]; |
102 | event.value = value; | 100 | event.value = value; |
@@ -106,7 +104,8 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne | |||
106 | event.type = JS_EVENT_AXIS; | 104 | event.type = JS_EVENT_AXIS; |
107 | event.number = joydev->absmap[code]; | 105 | event.number = joydev->absmap[code]; |
108 | event.value = joydev_correct(value, joydev->corr + event.number); | 106 | event.value = joydev_correct(value, joydev->corr + event.number); |
109 | if (event.value == joydev->abs[event.number]) return; | 107 | if (event.value == joydev->abs[event.number]) |
108 | return; | ||
110 | joydev->abs[event.number] = event.value; | 109 | joydev->abs[event.number] = event.value; |
111 | break; | 110 | break; |
112 | 111 | ||
@@ -134,7 +133,9 @@ static int joydev_fasync(int fd, struct file *file, int on) | |||
134 | { | 133 | { |
135 | int retval; | 134 | int retval; |
136 | struct joydev_list *list = file->private_data; | 135 | struct joydev_list *list = file->private_data; |
136 | |||
137 | retval = fasync_helper(fd, file, on, &list->fasync); | 137 | retval = fasync_helper(fd, file, on, &list->fasync); |
138 | |||
138 | return retval < 0 ? retval : 0; | 139 | return retval < 0 ? retval : 0; |
139 | } | 140 | } |
140 | 141 | ||
@@ -222,12 +223,12 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo | |||
222 | return sizeof(struct JS_DATA_TYPE); | 223 | return sizeof(struct JS_DATA_TYPE); |
223 | } | 224 | } |
224 | 225 | ||
225 | if (list->startup == joydev->nabs + joydev->nkey | 226 | if (list->startup == joydev->nabs + joydev->nkey && |
226 | && list->head == list->tail && (file->f_flags & O_NONBLOCK)) | 227 | list->head == list->tail && (file->f_flags & O_NONBLOCK)) |
227 | return -EAGAIN; | 228 | return -EAGAIN; |
228 | 229 | ||
229 | retval = wait_event_interruptible(list->joydev->wait, | 230 | retval = wait_event_interruptible(list->joydev->wait, |
230 | !list->joydev->exist || | 231 | !list->joydev->exist || |
231 | list->startup < joydev->nabs + joydev->nkey || | 232 | list->startup < joydev->nabs + joydev->nkey || |
232 | list->head != list->tail); | 233 | list->head != list->tail); |
233 | 234 | ||
@@ -276,8 +277,9 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo | |||
276 | static unsigned int joydev_poll(struct file *file, poll_table *wait) | 277 | static unsigned int joydev_poll(struct file *file, poll_table *wait) |
277 | { | 278 | { |
278 | struct joydev_list *list = file->private_data; | 279 | struct joydev_list *list = file->private_data; |
280 | |||
279 | poll_wait(file, &list->joydev->wait, wait); | 281 | poll_wait(file, &list->joydev->wait, wait); |
280 | return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ? | 282 | return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ? |
281 | (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); | 283 | (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); |
282 | } | 284 | } |
283 | 285 | ||
@@ -291,20 +293,26 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u | |||
291 | case JS_SET_CAL: | 293 | case JS_SET_CAL: |
292 | return copy_from_user(&joydev->glue.JS_CORR, argp, | 294 | return copy_from_user(&joydev->glue.JS_CORR, argp, |
293 | sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; | 295 | sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; |
296 | |||
294 | case JS_GET_CAL: | 297 | case JS_GET_CAL: |
295 | return copy_to_user(argp, &joydev->glue.JS_CORR, | 298 | return copy_to_user(argp, &joydev->glue.JS_CORR, |
296 | sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; | 299 | sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; |
300 | |||
297 | case JS_SET_TIMEOUT: | 301 | case JS_SET_TIMEOUT: |
298 | return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); | 302 | return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); |
303 | |||
299 | case JS_GET_TIMEOUT: | 304 | case JS_GET_TIMEOUT: |
300 | return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); | 305 | return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); |
301 | 306 | ||
302 | case JSIOCGVERSION: | 307 | case JSIOCGVERSION: |
303 | return put_user(JS_VERSION, (__u32 __user *) argp); | 308 | return put_user(JS_VERSION, (__u32 __user *) argp); |
309 | |||
304 | case JSIOCGAXES: | 310 | case JSIOCGAXES: |
305 | return put_user(joydev->nabs, (__u8 __user *) argp); | 311 | return put_user(joydev->nabs, (__u8 __user *) argp); |
312 | |||
306 | case JSIOCGBUTTONS: | 313 | case JSIOCGBUTTONS: |
307 | return put_user(joydev->nkey, (__u8 __user *) argp); | 314 | return put_user(joydev->nkey, (__u8 __user *) argp); |
315 | |||
308 | case JSIOCSCORR: | 316 | case JSIOCSCORR: |
309 | if (copy_from_user(joydev->corr, argp, | 317 | if (copy_from_user(joydev->corr, argp, |
310 | sizeof(joydev->corr[0]) * joydev->nabs)) | 318 | sizeof(joydev->corr[0]) * joydev->nabs)) |
@@ -314,38 +322,49 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u | |||
314 | joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i); | 322 | joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i); |
315 | } | 323 | } |
316 | return 0; | 324 | return 0; |
325 | |||
317 | case JSIOCGCORR: | 326 | case JSIOCGCORR: |
318 | return copy_to_user(argp, joydev->corr, | 327 | return copy_to_user(argp, joydev->corr, |
319 | sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; | 328 | sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; |
329 | |||
320 | case JSIOCSAXMAP: | 330 | case JSIOCSAXMAP: |
321 | if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1))) | 331 | if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1))) |
322 | return -EFAULT; | 332 | return -EFAULT; |
323 | for (i = 0; i < joydev->nabs; i++) { | 333 | for (i = 0; i < joydev->nabs; i++) { |
324 | if (joydev->abspam[i] > ABS_MAX) return -EINVAL; | 334 | if (joydev->abspam[i] > ABS_MAX) |
335 | return -EINVAL; | ||
325 | joydev->absmap[joydev->abspam[i]] = i; | 336 | joydev->absmap[joydev->abspam[i]] = i; |
326 | } | 337 | } |
327 | return 0; | 338 | return 0; |
339 | |||
328 | case JSIOCGAXMAP: | 340 | case JSIOCGAXMAP: |
329 | return copy_to_user(argp, joydev->abspam, | 341 | return copy_to_user(argp, joydev->abspam, |
330 | sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0; | 342 | sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0; |
343 | |||
331 | case JSIOCSBTNMAP: | 344 | case JSIOCSBTNMAP: |
332 | if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1))) | 345 | if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1))) |
333 | return -EFAULT; | 346 | return -EFAULT; |
334 | for (i = 0; i < joydev->nkey; i++) { | 347 | for (i = 0; i < joydev->nkey; i++) { |
335 | if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC) return -EINVAL; | 348 | if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC) |
349 | return -EINVAL; | ||
336 | joydev->keymap[joydev->keypam[i] - BTN_MISC] = i; | 350 | joydev->keymap[joydev->keypam[i] - BTN_MISC] = i; |
337 | } | 351 | } |
338 | return 0; | 352 | return 0; |
353 | |||
339 | case JSIOCGBTNMAP: | 354 | case JSIOCGBTNMAP: |
340 | return copy_to_user(argp, joydev->keypam, | 355 | return copy_to_user(argp, joydev->keypam, |
341 | sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0; | 356 | sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0; |
357 | |||
342 | default: | 358 | default: |
343 | if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) { | 359 | if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) { |
344 | int len; | 360 | int len; |
345 | if (!dev->name) return 0; | 361 | if (!dev->name) |
362 | return 0; | ||
346 | len = strlen(dev->name) + 1; | 363 | len = strlen(dev->name) + 1; |
347 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | 364 | if (len > _IOC_SIZE(cmd)) |
348 | if (copy_to_user(argp, dev->name, len)) return -EFAULT; | 365 | len = _IOC_SIZE(cmd); |
366 | if (copy_to_user(argp, dev->name, len)) | ||
367 | return -EFAULT; | ||
349 | return len; | 368 | return len; |
350 | } | 369 | } |
351 | } | 370 | } |
@@ -362,7 +381,9 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo | |||
362 | struct JS_DATA_SAVE_TYPE_32 ds32; | 381 | struct JS_DATA_SAVE_TYPE_32 ds32; |
363 | int err; | 382 | int err; |
364 | 383 | ||
365 | if (!joydev->exist) return -ENODEV; | 384 | if (!joydev->exist) |
385 | return -ENODEV; | ||
386 | |||
366 | switch(cmd) { | 387 | switch(cmd) { |
367 | case JS_SET_TIMELIMIT: | 388 | case JS_SET_TIMELIMIT: |
368 | err = get_user(tmp32, (s32 __user *) arg); | 389 | err = get_user(tmp32, (s32 __user *) arg); |
@@ -395,8 +416,7 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo | |||
395 | ds32.JS_SAVE = joydev->glue.JS_SAVE; | 416 | ds32.JS_SAVE = joydev->glue.JS_SAVE; |
396 | ds32.JS_CORR = joydev->glue.JS_CORR; | 417 | ds32.JS_CORR = joydev->glue.JS_CORR; |
397 | 418 | ||
398 | err = copy_to_user(argp, &ds32, | 419 | err = copy_to_user(argp, &ds32, sizeof(ds32)) ? -EFAULT : 0; |
399 | sizeof(ds32)) ? -EFAULT : 0; | ||
400 | break; | 420 | break; |
401 | 421 | ||
402 | default: | 422 | default: |
@@ -412,7 +432,8 @@ static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
412 | struct joydev *joydev = list->joydev; | 432 | struct joydev *joydev = list->joydev; |
413 | void __user *argp = (void __user *)arg; | 433 | void __user *argp = (void __user *)arg; |
414 | 434 | ||
415 | if (!joydev->exist) return -ENODEV; | 435 | if (!joydev->exist) |
436 | return -ENODEV; | ||
416 | 437 | ||
417 | switch(cmd) { | 438 | switch(cmd) { |
418 | case JS_SET_TIMELIMIT: | 439 | case JS_SET_TIMELIMIT: |
@@ -546,8 +567,8 @@ static struct input_device_id joydev_blacklist[] = { | |||
546 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT, | 567 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT, |
547 | .evbit = { BIT(EV_KEY) }, | 568 | .evbit = { BIT(EV_KEY) }, |
548 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, | 569 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, |
549 | }, /* Avoid itouchpads, touchscreens and tablets */ | 570 | }, /* Avoid itouchpads, touchscreens and tablets */ |
550 | { }, /* Terminating entry */ | 571 | { } /* Terminating entry */ |
551 | }; | 572 | }; |
552 | 573 | ||
553 | static struct input_device_id joydev_ids[] = { | 574 | static struct input_device_id joydev_ids[] = { |
@@ -566,7 +587,7 @@ static struct input_device_id joydev_ids[] = { | |||
566 | .evbit = { BIT(EV_ABS) }, | 587 | .evbit = { BIT(EV_ABS) }, |
567 | .absbit = { BIT(ABS_THROTTLE) }, | 588 | .absbit = { BIT(ABS_THROTTLE) }, |
568 | }, | 589 | }, |
569 | { }, /* Terminating entry */ | 590 | { } /* Terminating entry */ |
570 | }; | 591 | }; |
571 | 592 | ||
572 | MODULE_DEVICE_TABLE(input, joydev_ids); | 593 | MODULE_DEVICE_TABLE(input, joydev_ids); |
@@ -579,7 +600,7 @@ static struct input_handler joydev_handler = { | |||
579 | .minor = JOYDEV_MINOR_BASE, | 600 | .minor = JOYDEV_MINOR_BASE, |
580 | .name = "joydev", | 601 | .name = "joydev", |
581 | .id_table = joydev_ids, | 602 | .id_table = joydev_ids, |
582 | .blacklist = joydev_blacklist, | 603 | .blacklist = joydev_blacklist, |
583 | }; | 604 | }; |
584 | 605 | ||
585 | static int __init joydev_init(void) | 606 | static int __init joydev_init(void) |
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index 4612d13ea756..b11a4bbc84c4 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c | |||
@@ -306,7 +306,7 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
306 | gameport_set_poll_handler(gameport, a3d_poll); | 306 | gameport_set_poll_handler(gameport, a3d_poll); |
307 | gameport_set_poll_interval(gameport, 20); | 307 | gameport_set_poll_interval(gameport, 20); |
308 | 308 | ||
309 | sprintf(a3d->phys, "%s/input0", gameport->phys); | 309 | snprintf(a3d->phys, sizeof(a3d->phys), "%s/input0", gameport->phys); |
310 | 310 | ||
311 | input_dev->name = a3d_names[a3d->mode]; | 311 | input_dev->name = a3d_names[a3d->mode]; |
312 | input_dev->phys = a3d->phys; | 312 | input_dev->phys = a3d->phys; |
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index 3121961e3e7c..01dc0b195d59 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c | |||
@@ -408,21 +408,23 @@ static void analog_calibrate_timer(struct analog_port *port) | |||
408 | 408 | ||
409 | static void analog_name(struct analog *analog) | 409 | static void analog_name(struct analog *analog) |
410 | { | 410 | { |
411 | sprintf(analog->name, "Analog %d-axis %d-button", | 411 | snprintf(analog->name, sizeof(analog->name), "Analog %d-axis %d-button", |
412 | hweight8(analog->mask & ANALOG_AXES_STD), | 412 | hweight8(analog->mask & ANALOG_AXES_STD), |
413 | hweight8(analog->mask & ANALOG_BTNS_STD) + !!(analog->mask & ANALOG_BTNS_CHF) * 2 + | 413 | hweight8(analog->mask & ANALOG_BTNS_STD) + !!(analog->mask & ANALOG_BTNS_CHF) * 2 + |
414 | hweight16(analog->mask & ANALOG_BTNS_GAMEPAD) + !!(analog->mask & ANALOG_HBTN_CHF) * 4); | 414 | hweight16(analog->mask & ANALOG_BTNS_GAMEPAD) + !!(analog->mask & ANALOG_HBTN_CHF) * 4); |
415 | 415 | ||
416 | if (analog->mask & ANALOG_HATS_ALL) | 416 | if (analog->mask & ANALOG_HATS_ALL) |
417 | sprintf(analog->name, "%s %d-hat", | 417 | snprintf(analog->name, sizeof(analog->name), "%s %d-hat", |
418 | analog->name, hweight16(analog->mask & ANALOG_HATS_ALL)); | 418 | analog->name, hweight16(analog->mask & ANALOG_HATS_ALL)); |
419 | 419 | ||
420 | if (analog->mask & ANALOG_HAT_FCS) | 420 | if (analog->mask & ANALOG_HAT_FCS) |
421 | strcat(analog->name, " FCS"); | 421 | strlcat(analog->name, " FCS", sizeof(analog->name)); |
422 | if (analog->mask & ANALOG_ANY_CHF) | 422 | if (analog->mask & ANALOG_ANY_CHF) |
423 | strcat(analog->name, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF"); | 423 | strlcat(analog->name, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF", |
424 | sizeof(analog->name)); | ||
424 | 425 | ||
425 | strcat(analog->name, (analog->mask & ANALOG_GAMEPAD) ? " gamepad": " joystick"); | 426 | strlcat(analog->name, (analog->mask & ANALOG_GAMEPAD) ? " gamepad": " joystick", |
427 | sizeof(analog->name)); | ||
426 | } | 428 | } |
427 | 429 | ||
428 | /* | 430 | /* |
@@ -435,7 +437,8 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i | |||
435 | int i, j, t, v, w, x, y, z; | 437 | int i, j, t, v, w, x, y, z; |
436 | 438 | ||
437 | analog_name(analog); | 439 | analog_name(analog); |
438 | sprintf(analog->phys, "%s/input%d", port->gameport->phys, index); | 440 | snprintf(analog->phys, sizeof(analog->phys), |
441 | "%s/input%d", port->gameport->phys, index); | ||
439 | analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; | 442 | analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; |
440 | 443 | ||
441 | analog->dev = input_dev = input_allocate_device(); | 444 | analog->dev = input_dev = input_allocate_device(); |
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c index 1909f7ef340c..d5e42eb88a20 100644 --- a/drivers/input/joystick/cobra.c +++ b/drivers/input/joystick/cobra.c | |||
@@ -202,7 +202,8 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
202 | goto fail3; | 202 | goto fail3; |
203 | } | 203 | } |
204 | 204 | ||
205 | sprintf(cobra->phys[i], "%s/input%d", gameport->phys, i); | 205 | snprintf(cobra->phys[i], sizeof(cobra->phys[i]), |
206 | "%s/input%d", gameport->phys, i); | ||
206 | 207 | ||
207 | input_dev->name = "Creative Labs Blaster GamePad Cobra"; | 208 | input_dev->name = "Creative Labs Blaster GamePad Cobra"; |
208 | input_dev->phys = cobra->phys[i]; | 209 | input_dev->phys = cobra->phys[i]; |
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index e61894685cb1..6f31f054d1bb 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c | |||
@@ -620,7 +620,8 @@ static struct db9 __init *db9_probe(int parport, int mode) | |||
620 | goto err_unreg_devs; | 620 | goto err_unreg_devs; |
621 | } | 621 | } |
622 | 622 | ||
623 | sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); | 623 | snprintf(db9->phys[i], sizeof(db9->phys[i]), |
624 | "%s/input%d", db9->pd->port->name, i); | ||
624 | 625 | ||
625 | input_dev->name = db9_mode->name; | 626 | input_dev->name = db9_mode->name; |
626 | input_dev->phys = db9->phys[i]; | 627 | input_dev->phys = db9->phys[i]; |
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index ecbdb6b9bbd6..fe12aa37393d 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -761,7 +761,8 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) | |||
761 | if (!pads[i]) | 761 | if (!pads[i]) |
762 | continue; | 762 | continue; |
763 | 763 | ||
764 | sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); | 764 | snprintf(gc->phys[i], sizeof(gc->phys[i]), |
765 | "%s/input%d", gc->pd->port->name, i); | ||
765 | err = gc_setup_pad(gc, i, pads[i]); | 766 | err = gc_setup_pad(gc, i, pads[i]); |
766 | if (err) | 767 | if (err) |
767 | goto err_unreg_devs; | 768 | goto err_unreg_devs; |
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c index 8a3ad455eb38..e4a699f6ec87 100644 --- a/drivers/input/joystick/gf2k.c +++ b/drivers/input/joystick/gf2k.c | |||
@@ -298,7 +298,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
298 | gameport_set_poll_handler(gameport, gf2k_poll); | 298 | gameport_set_poll_handler(gameport, gf2k_poll); |
299 | gameport_set_poll_interval(gameport, 20); | 299 | gameport_set_poll_interval(gameport, 20); |
300 | 300 | ||
301 | sprintf(gf2k->phys, "%s/input0", gameport->phys); | 301 | snprintf(gf2k->phys, sizeof(gf2k->phys), "%s/input0", gameport->phys); |
302 | 302 | ||
303 | gf2k->length = gf2k_lens[gf2k->id]; | 303 | gf2k->length = gf2k_lens[gf2k->id]; |
304 | 304 | ||
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index 20cb98ac2d79..17a90c436de8 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c | |||
@@ -354,7 +354,8 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
354 | goto fail3; | 354 | goto fail3; |
355 | } | 355 | } |
356 | 356 | ||
357 | sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); | 357 | snprintf(grip->phys[i], sizeof(grip->phys[i]), |
358 | "%s/input%d", gameport->phys, i); | ||
358 | 359 | ||
359 | input_dev->name = grip_name[grip->mode[i]]; | 360 | input_dev->name = grip_name[grip->mode[i]]; |
360 | input_dev->phys = grip->phys[i]; | 361 | input_dev->phys = grip->phys[i]; |
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c index 6e2c721c26ba..840ed9b512b2 100644 --- a/drivers/input/joystick/guillemot.c +++ b/drivers/input/joystick/guillemot.c | |||
@@ -222,7 +222,7 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver * | |||
222 | gameport_set_poll_handler(gameport, guillemot_poll); | 222 | gameport_set_poll_handler(gameport, guillemot_poll); |
223 | gameport_set_poll_interval(gameport, 20); | 223 | gameport_set_poll_interval(gameport, 20); |
224 | 224 | ||
225 | sprintf(guillemot->phys, "%s/input0", gameport->phys); | 225 | snprintf(guillemot->phys, sizeof(guillemot->phys), "%s/input0", gameport->phys); |
226 | guillemot->type = guillemot_type + i; | 226 | guillemot->type = guillemot_type + i; |
227 | 227 | ||
228 | input_dev->name = guillemot_type[i].name; | 228 | input_dev->name = guillemot_type[i].name; |
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c index 2b8e8456c9fa..50c90765aee1 100644 --- a/drivers/input/joystick/iforce/iforce-ff.c +++ b/drivers/input/joystick/iforce/iforce-ff.c | |||
@@ -47,7 +47,7 @@ static int make_magnitude_modifier(struct iforce* iforce, | |||
47 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 47 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
48 | NULL, NULL)) { | 48 | NULL, NULL)) { |
49 | mutex_unlock(&iforce->mem_mutex); | 49 | mutex_unlock(&iforce->mem_mutex); |
50 | return -ENOMEM; | 50 | return -ENOSPC; |
51 | } | 51 | } |
52 | mutex_unlock(&iforce->mem_mutex); | 52 | mutex_unlock(&iforce->mem_mutex); |
53 | } | 53 | } |
@@ -80,7 +80,7 @@ static int make_period_modifier(struct iforce* iforce, | |||
80 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 80 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
81 | NULL, NULL)) { | 81 | NULL, NULL)) { |
82 | mutex_unlock(&iforce->mem_mutex); | 82 | mutex_unlock(&iforce->mem_mutex); |
83 | return -ENOMEM; | 83 | return -ENOSPC; |
84 | } | 84 | } |
85 | mutex_unlock(&iforce->mem_mutex); | 85 | mutex_unlock(&iforce->mem_mutex); |
86 | } | 86 | } |
@@ -120,7 +120,7 @@ static int make_envelope_modifier(struct iforce* iforce, | |||
120 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 120 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
121 | NULL, NULL)) { | 121 | NULL, NULL)) { |
122 | mutex_unlock(&iforce->mem_mutex); | 122 | mutex_unlock(&iforce->mem_mutex); |
123 | return -ENOMEM; | 123 | return -ENOSPC; |
124 | } | 124 | } |
125 | mutex_unlock(&iforce->mem_mutex); | 125 | mutex_unlock(&iforce->mem_mutex); |
126 | } | 126 | } |
@@ -157,7 +157,7 @@ static int make_condition_modifier(struct iforce* iforce, | |||
157 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 157 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
158 | NULL, NULL)) { | 158 | NULL, NULL)) { |
159 | mutex_unlock(&iforce->mem_mutex); | 159 | mutex_unlock(&iforce->mem_mutex); |
160 | return -ENOMEM; | 160 | return -ENOSPC; |
161 | } | 161 | } |
162 | mutex_unlock(&iforce->mem_mutex); | 162 | mutex_unlock(&iforce->mem_mutex); |
163 | } | 163 | } |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index ab0a26b924ca..6d99e3c37884 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
@@ -86,7 +86,7 @@ static struct iforce_device iforce_device[] = { | |||
86 | 86 | ||
87 | static int iforce_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 87 | static int iforce_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
88 | { | 88 | { |
89 | struct iforce* iforce = (struct iforce*)(dev->private); | 89 | struct iforce* iforce = dev->private; |
90 | unsigned char data[3]; | 90 | unsigned char data[3]; |
91 | 91 | ||
92 | if (type != EV_FF) | 92 | if (type != EV_FF) |
@@ -138,7 +138,7 @@ static int iforce_input_event(struct input_dev *dev, unsigned int type, unsigned | |||
138 | */ | 138 | */ |
139 | static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect) | 139 | static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect) |
140 | { | 140 | { |
141 | struct iforce* iforce = (struct iforce*)(dev->private); | 141 | struct iforce* iforce = dev->private; |
142 | int id; | 142 | int id; |
143 | int ret; | 143 | int ret; |
144 | int is_update; | 144 | int is_update; |
@@ -218,7 +218,7 @@ static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect) | |||
218 | */ | 218 | */ |
219 | static int iforce_erase_effect(struct input_dev *dev, int effect_id) | 219 | static int iforce_erase_effect(struct input_dev *dev, int effect_id) |
220 | { | 220 | { |
221 | struct iforce* iforce = (struct iforce*)(dev->private); | 221 | struct iforce* iforce = dev->private; |
222 | int err = 0; | 222 | int err = 0; |
223 | struct iforce_core_effect* core_effect; | 223 | struct iforce_core_effect* core_effect; |
224 | 224 | ||
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c index c4ed01758226..bbfeb9c59b87 100644 --- a/drivers/input/joystick/interact.c +++ b/drivers/input/joystick/interact.c | |||
@@ -251,7 +251,7 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d | |||
251 | gameport_set_poll_handler(gameport, interact_poll); | 251 | gameport_set_poll_handler(gameport, interact_poll); |
252 | gameport_set_poll_interval(gameport, 20); | 252 | gameport_set_poll_interval(gameport, 20); |
253 | 253 | ||
254 | sprintf(interact->phys, "%s/input0", gameport->phys); | 254 | snprintf(interact->phys, sizeof(interact->phys), "%s/input0", gameport->phys); |
255 | 255 | ||
256 | interact->type = i; | 256 | interact->type = i; |
257 | interact->length = interact_type[i].length; | 257 | interact->length = interact_type[i].length; |
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c index ca3cc2319d6a..168b1061a03b 100644 --- a/drivers/input/joystick/magellan.c +++ b/drivers/input/joystick/magellan.c | |||
@@ -162,7 +162,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv) | |||
162 | goto fail; | 162 | goto fail; |
163 | 163 | ||
164 | magellan->dev = input_dev; | 164 | magellan->dev = input_dev; |
165 | sprintf(magellan->phys, "%s/input0", serio->phys); | 165 | snprintf(magellan->phys, sizeof(magellan->phys), "%s/input0", serio->phys); |
166 | 166 | ||
167 | input_dev->name = "LogiCad3D Magellan / SpaceMouse"; | 167 | input_dev->name = "LogiCad3D Magellan / SpaceMouse"; |
168 | input_dev->phys = magellan->phys; | 168 | input_dev->phys = magellan->phys; |
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 95c0de7964a0..e58b22c018e4 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c | |||
@@ -541,7 +541,7 @@ static void sw_print_packet(char *name, int length, unsigned char *buf, char bit | |||
541 | * Unfortunately I don't know how to do this for the other SW types. | 541 | * Unfortunately I don't know how to do this for the other SW types. |
542 | */ | 542 | */ |
543 | 543 | ||
544 | static void sw_3dp_id(unsigned char *buf, char *comment) | 544 | static void sw_3dp_id(unsigned char *buf, char *comment, size_t size) |
545 | { | 545 | { |
546 | int i; | 546 | int i; |
547 | char pnp[8], rev[9]; | 547 | char pnp[8], rev[9]; |
@@ -554,7 +554,7 @@ static void sw_3dp_id(unsigned char *buf, char *comment) | |||
554 | 554 | ||
555 | pnp[7] = rev[8] = 0; | 555 | pnp[7] = rev[8] = 0; |
556 | 556 | ||
557 | sprintf(comment, " [PnP %d.%02d id %s rev %s]", | 557 | snprintf(comment, size, " [PnP %d.%02d id %s rev %s]", |
558 | (int) ((sw_get_bits(buf, 8, 6, 1) << 6) | /* Two 6-bit values */ | 558 | (int) ((sw_get_bits(buf, 8, 6, 1) << 6) | /* Two 6-bit values */ |
559 | sw_get_bits(buf, 16, 6, 1)) / 100, | 559 | sw_get_bits(buf, 16, 6, 1)) / 100, |
560 | (int) ((sw_get_bits(buf, 8, 6, 1) << 6) | | 560 | (int) ((sw_get_bits(buf, 8, 6, 1) << 6) | |
@@ -695,7 +695,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
695 | sw->type = SW_ID_FFP; | 695 | sw->type = SW_ID_FFP; |
696 | sprintf(comment, " [AC %s]", sw_get_bits(idbuf,38,1,3) ? "off" : "on"); | 696 | sprintf(comment, " [AC %s]", sw_get_bits(idbuf,38,1,3) ? "off" : "on"); |
697 | } else | 697 | } else |
698 | sw->type = SW_ID_PP; | 698 | sw->type = SW_ID_PP; |
699 | break; | 699 | break; |
700 | case 66: | 700 | case 66: |
701 | sw->bits = 3; | 701 | sw->bits = 3; |
@@ -703,7 +703,8 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
703 | sw->length = 22; | 703 | sw->length = 22; |
704 | case 64: | 704 | case 64: |
705 | sw->type = SW_ID_3DP; | 705 | sw->type = SW_ID_3DP; |
706 | if (j == 160) sw_3dp_id(idbuf, comment); | 706 | if (j == 160) |
707 | sw_3dp_id(idbuf, comment, sizeof(comment)); | ||
707 | break; | 708 | break; |
708 | } | 709 | } |
709 | } | 710 | } |
@@ -733,8 +734,10 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
733 | for (i = 0; i < sw->number; i++) { | 734 | for (i = 0; i < sw->number; i++) { |
734 | int bits, code; | 735 | int bits, code; |
735 | 736 | ||
736 | sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); | 737 | snprintf(sw->name, sizeof(sw->name), |
737 | sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); | 738 | "Microsoft SideWinder %s", sw_name[sw->type]); |
739 | snprintf(sw->phys[i], sizeof(sw->phys[i]), | ||
740 | "%s/input%d", gameport->phys, i); | ||
738 | 741 | ||
739 | sw->dev[i] = input_dev = input_allocate_device(); | 742 | sw->dev[i] = input_dev = input_allocate_device(); |
740 | if (!input_dev) { | 743 | if (!input_dev) { |
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index d6f8db8ec3fd..75eb5ca59992 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c | |||
@@ -220,7 +220,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv) | |||
220 | goto fail; | 220 | goto fail; |
221 | 221 | ||
222 | spaceball->dev = input_dev; | 222 | spaceball->dev = input_dev; |
223 | sprintf(spaceball->phys, "%s/input0", serio->phys); | 223 | snprintf(spaceball->phys, sizeof(spaceball->phys), "%s/input0", serio->phys); |
224 | 224 | ||
225 | input_dev->name = spaceball_names[id]; | 225 | input_dev->name = spaceball_names[id]; |
226 | input_dev->phys = spaceball->phys; | 226 | input_dev->phys = spaceball->phys; |
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index 7c123a01c58e..3e2782e79834 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c | |||
@@ -177,7 +177,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv) | |||
177 | goto fail; | 177 | goto fail; |
178 | 178 | ||
179 | spaceorb->dev = input_dev; | 179 | spaceorb->dev = input_dev; |
180 | sprintf(spaceorb->phys, "%s/input0", serio->phys); | 180 | snprintf(spaceorb->phys, sizeof(spaceorb->phys), "%s/input0", serio->phys); |
181 | 181 | ||
182 | input_dev->name = "SpaceTec SpaceOrb 360 / Avenger"; | 182 | input_dev->name = "SpaceTec SpaceOrb 360 / Avenger"; |
183 | input_dev->phys = spaceorb->phys; | 183 | input_dev->phys = spaceorb->phys; |
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index 0a9ed1d30636..011ec4858e15 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c | |||
@@ -148,7 +148,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv) | |||
148 | goto fail; | 148 | goto fail; |
149 | 149 | ||
150 | stinger->dev = input_dev; | 150 | stinger->dev = input_dev; |
151 | sprintf(stinger->phys, "%s/serio0", serio->phys); | 151 | snprintf(stinger->phys, sizeof(stinger->phys), "%s/serio0", serio->phys); |
152 | 152 | ||
153 | input_dev->name = "Gravis Stinger"; | 153 | input_dev->name = "Gravis Stinger"; |
154 | input_dev->phys = stinger->phys; | 154 | input_dev->phys = stinger->phys; |
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index 7f8b0093c5bc..076f237d9654 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c | |||
@@ -199,7 +199,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv) | |||
199 | goto fail; | 199 | goto fail; |
200 | 200 | ||
201 | twidjoy->dev = input_dev; | 201 | twidjoy->dev = input_dev; |
202 | sprintf(twidjoy->phys, "%s/input0", serio->phys); | 202 | snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys); |
203 | 203 | ||
204 | input_dev->name = "Handykey Twiddler"; | 204 | input_dev->name = "Handykey Twiddler"; |
205 | input_dev->phys = twidjoy->phys; | 205 | input_dev->phys = twidjoy->phys; |
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 1849b176cf18..f9c1a03214eb 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c | |||
@@ -154,7 +154,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv) | |||
154 | goto fail; | 154 | goto fail; |
155 | 155 | ||
156 | warrior->dev = input_dev; | 156 | warrior->dev = input_dev; |
157 | sprintf(warrior->phys, "%s/input0", serio->phys); | 157 | snprintf(warrior->phys, sizeof(warrior->phys), "%s/input0", serio->phys); |
158 | 158 | ||
159 | input_dev->name = "Logitech WingMan Warrior"; | 159 | input_dev->name = "Logitech WingMan Warrior"; |
160 | input_dev->phys = warrior->phys; | 160 | input_dev->phys = warrior->phys; |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index fad04b66d268..ffde8f86e0fb 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -55,7 +55,7 @@ static int atkbd_softraw = 1; | |||
55 | module_param_named(softraw, atkbd_softraw, bool, 0); | 55 | module_param_named(softraw, atkbd_softraw, bool, 0); |
56 | MODULE_PARM_DESC(softraw, "Use software generated rawmode"); | 56 | MODULE_PARM_DESC(softraw, "Use software generated rawmode"); |
57 | 57 | ||
58 | static int atkbd_scroll = 0; | 58 | static int atkbd_scroll; |
59 | module_param_named(scroll, atkbd_scroll, bool, 0); | 59 | module_param_named(scroll, atkbd_scroll, bool, 0); |
60 | MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); | 60 | MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); |
61 | 61 | ||
@@ -150,8 +150,8 @@ static unsigned char atkbd_unxlate_table[128] = { | |||
150 | #define ATKBD_RET_EMUL0 0xe0 | 150 | #define ATKBD_RET_EMUL0 0xe0 |
151 | #define ATKBD_RET_EMUL1 0xe1 | 151 | #define ATKBD_RET_EMUL1 0xe1 |
152 | #define ATKBD_RET_RELEASE 0xf0 | 152 | #define ATKBD_RET_RELEASE 0xf0 |
153 | #define ATKBD_RET_HANGUEL 0xf1 | 153 | #define ATKBD_RET_HANJA 0xf1 |
154 | #define ATKBD_RET_HANJA 0xf2 | 154 | #define ATKBD_RET_HANGEUL 0xf2 |
155 | #define ATKBD_RET_ERR 0xff | 155 | #define ATKBD_RET_ERR 0xff |
156 | 156 | ||
157 | #define ATKBD_KEY_UNKNOWN 0 | 157 | #define ATKBD_KEY_UNKNOWN 0 |
@@ -170,6 +170,13 @@ static unsigned char atkbd_unxlate_table[128] = { | |||
170 | #define ATKBD_LED_EVENT_BIT 0 | 170 | #define ATKBD_LED_EVENT_BIT 0 |
171 | #define ATKBD_REP_EVENT_BIT 1 | 171 | #define ATKBD_REP_EVENT_BIT 1 |
172 | 172 | ||
173 | #define ATKBD_XL_ERR 0x01 | ||
174 | #define ATKBD_XL_BAT 0x02 | ||
175 | #define ATKBD_XL_ACK 0x04 | ||
176 | #define ATKBD_XL_NAK 0x08 | ||
177 | #define ATKBD_XL_HANGEUL 0x10 | ||
178 | #define ATKBD_XL_HANJA 0x20 | ||
179 | |||
173 | static struct { | 180 | static struct { |
174 | unsigned char keycode; | 181 | unsigned char keycode; |
175 | unsigned char set2; | 182 | unsigned char set2; |
@@ -211,8 +218,7 @@ struct atkbd { | |||
211 | unsigned char emul; | 218 | unsigned char emul; |
212 | unsigned char resend; | 219 | unsigned char resend; |
213 | unsigned char release; | 220 | unsigned char release; |
214 | unsigned char bat_xl; | 221 | unsigned long xl_bit; |
215 | unsigned char err_xl; | ||
216 | unsigned int last; | 222 | unsigned int last; |
217 | unsigned long time; | 223 | unsigned long time; |
218 | 224 | ||
@@ -245,17 +251,65 @@ ATKBD_DEFINE_ATTR(set); | |||
245 | ATKBD_DEFINE_ATTR(softrepeat); | 251 | ATKBD_DEFINE_ATTR(softrepeat); |
246 | ATKBD_DEFINE_ATTR(softraw); | 252 | ATKBD_DEFINE_ATTR(softraw); |
247 | 253 | ||
254 | static const unsigned int xl_table[] = { | ||
255 | ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK, | ||
256 | ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL, | ||
257 | }; | ||
248 | 258 | ||
249 | static void atkbd_report_key(struct input_dev *dev, struct pt_regs *regs, int code, int value) | 259 | /* |
260 | * Checks if we should mangle the scancode to extract 'release' bit | ||
261 | * in translated mode. | ||
262 | */ | ||
263 | static int atkbd_need_xlate(unsigned long xl_bit, unsigned char code) | ||
250 | { | 264 | { |
251 | input_regs(dev, regs); | 265 | int i; |
252 | if (value == 3) { | 266 | |
253 | input_report_key(dev, code, 1); | 267 | if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1) |
254 | input_sync(dev); | 268 | return 0; |
255 | input_report_key(dev, code, 0); | 269 | |
256 | } else | 270 | for (i = 0; i < ARRAY_SIZE(xl_table); i++) |
257 | input_event(dev, EV_KEY, code, value); | 271 | if (code == xl_table[i]) |
258 | input_sync(dev); | 272 | return test_bit(i, &xl_bit); |
273 | |||
274 | return 1; | ||
275 | } | ||
276 | |||
277 | /* | ||
278 | * Calculates new value of xl_bit so the driver can distinguish | ||
279 | * between make/break pair of scancodes for select keys and PS/2 | ||
280 | * protocol responses. | ||
281 | */ | ||
282 | static void atkbd_calculate_xl_bit(struct atkbd *atkbd, unsigned char code) | ||
283 | { | ||
284 | int i; | ||
285 | |||
286 | for (i = 0; i < ARRAY_SIZE(xl_table); i++) { | ||
287 | if (!((code ^ xl_table[i]) & 0x7f)) { | ||
288 | if (code & 0x80) | ||
289 | __clear_bit(i, &atkbd->xl_bit); | ||
290 | else | ||
291 | __set_bit(i, &atkbd->xl_bit); | ||
292 | break; | ||
293 | } | ||
294 | } | ||
295 | } | ||
296 | |||
297 | /* | ||
298 | * Encode the scancode, 0xe0 prefix, and high bit into a single integer, | ||
299 | * keeping kernel 2.4 compatibility for set 2 | ||
300 | */ | ||
301 | static unsigned int atkbd_compat_scancode(struct atkbd *atkbd, unsigned int code) | ||
302 | { | ||
303 | if (atkbd->set == 3) { | ||
304 | if (atkbd->emul == 1) | ||
305 | code |= 0x100; | ||
306 | } else { | ||
307 | code = (code & 0x7f) | ((code & 0x80) << 1); | ||
308 | if (atkbd->emul == 1) | ||
309 | code |= 0x80; | ||
310 | } | ||
311 | |||
312 | return code; | ||
259 | } | 313 | } |
260 | 314 | ||
261 | /* | 315 | /* |
@@ -267,9 +321,11 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
267 | unsigned int flags, struct pt_regs *regs) | 321 | unsigned int flags, struct pt_regs *regs) |
268 | { | 322 | { |
269 | struct atkbd *atkbd = serio_get_drvdata(serio); | 323 | struct atkbd *atkbd = serio_get_drvdata(serio); |
324 | struct input_dev *dev = atkbd->dev; | ||
270 | unsigned int code = data; | 325 | unsigned int code = data; |
271 | int scroll = 0, hscroll = 0, click = -1; | 326 | int scroll = 0, hscroll = 0, click = -1, add_release_event = 0; |
272 | int value; | 327 | int value; |
328 | unsigned char keycode; | ||
273 | 329 | ||
274 | #ifdef ATKBD_DEBUG | 330 | #ifdef ATKBD_DEBUG |
275 | printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags); | 331 | printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags); |
@@ -298,25 +354,17 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
298 | if (!atkbd->enabled) | 354 | if (!atkbd->enabled) |
299 | goto out; | 355 | goto out; |
300 | 356 | ||
301 | input_event(atkbd->dev, EV_MSC, MSC_RAW, code); | 357 | input_event(dev, EV_MSC, MSC_RAW, code); |
302 | 358 | ||
303 | if (atkbd->translated) { | 359 | if (atkbd->translated) { |
304 | 360 | ||
305 | if (atkbd->emul || | 361 | if (atkbd->emul || atkbd_need_xlate(atkbd->xl_bit, code)) { |
306 | (code != ATKBD_RET_EMUL0 && code != ATKBD_RET_EMUL1 && | ||
307 | code != ATKBD_RET_HANGUEL && code != ATKBD_RET_HANJA && | ||
308 | (code != ATKBD_RET_ERR || atkbd->err_xl) && | ||
309 | (code != ATKBD_RET_BAT || atkbd->bat_xl))) { | ||
310 | atkbd->release = code >> 7; | 362 | atkbd->release = code >> 7; |
311 | code &= 0x7f; | 363 | code &= 0x7f; |
312 | } | 364 | } |
313 | 365 | ||
314 | if (!atkbd->emul) { | 366 | if (!atkbd->emul) |
315 | if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) | 367 | atkbd_calculate_xl_bit(atkbd, data); |
316 | atkbd->bat_xl = !(data >> 7); | ||
317 | if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f)) | ||
318 | atkbd->err_xl = !(data >> 7); | ||
319 | } | ||
320 | } | 368 | } |
321 | 369 | ||
322 | switch (code) { | 370 | switch (code) { |
@@ -333,47 +381,48 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
333 | case ATKBD_RET_RELEASE: | 381 | case ATKBD_RET_RELEASE: |
334 | atkbd->release = 1; | 382 | atkbd->release = 1; |
335 | goto out; | 383 | goto out; |
336 | case ATKBD_RET_HANGUEL: | 384 | case ATKBD_RET_ACK: |
337 | atkbd_report_key(atkbd->dev, regs, KEY_HANGUEL, 3); | 385 | case ATKBD_RET_NAK: |
386 | printk(KERN_WARNING "atkbd.c: Spurious %s on %s. " | ||
387 | "Some program might be trying access hardware directly.\n", | ||
388 | data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); | ||
338 | goto out; | 389 | goto out; |
390 | case ATKBD_RET_HANGEUL: | ||
339 | case ATKBD_RET_HANJA: | 391 | case ATKBD_RET_HANJA: |
340 | atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3); | 392 | /* |
341 | goto out; | 393 | * These keys do not report release and thus need to be |
394 | * flagged properly | ||
395 | */ | ||
396 | add_release_event = 1; | ||
397 | break; | ||
342 | case ATKBD_RET_ERR: | 398 | case ATKBD_RET_ERR: |
343 | printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); | 399 | printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); |
344 | goto out; | 400 | goto out; |
345 | } | 401 | } |
346 | 402 | ||
347 | if (atkbd->set != 3) | 403 | code = atkbd_compat_scancode(atkbd, code); |
348 | code = (code & 0x7f) | ((code & 0x80) << 1); | 404 | |
349 | if (atkbd->emul) { | 405 | if (atkbd->emul && --atkbd->emul) |
350 | if (--atkbd->emul) | 406 | goto out; |
351 | goto out; | ||
352 | code |= (atkbd->set != 3) ? 0x80 : 0x100; | ||
353 | } | ||
354 | 407 | ||
355 | if (atkbd->keycode[code] != ATKBD_KEY_NULL) | 408 | keycode = atkbd->keycode[code]; |
356 | input_event(atkbd->dev, EV_MSC, MSC_SCAN, code); | ||
357 | 409 | ||
358 | switch (atkbd->keycode[code]) { | 410 | if (keycode != ATKBD_KEY_NULL) |
411 | input_event(dev, EV_MSC, MSC_SCAN, code); | ||
412 | |||
413 | switch (keycode) { | ||
359 | case ATKBD_KEY_NULL: | 414 | case ATKBD_KEY_NULL: |
360 | break; | 415 | break; |
361 | case ATKBD_KEY_UNKNOWN: | 416 | case ATKBD_KEY_UNKNOWN: |
362 | if (data == ATKBD_RET_ACK || data == ATKBD_RET_NAK) { | 417 | printk(KERN_WARNING |
363 | printk(KERN_WARNING "atkbd.c: Spurious %s on %s. Some program, " | 418 | "atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n", |
364 | "like XFree86, might be trying access hardware directly.\n", | 419 | atkbd->release ? "released" : "pressed", |
365 | data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); | 420 | atkbd->translated ? "translated" : "raw", |
366 | } else { | 421 | atkbd->set, code, serio->phys); |
367 | printk(KERN_WARNING "atkbd.c: Unknown key %s " | 422 | printk(KERN_WARNING |
368 | "(%s set %d, code %#x on %s).\n", | 423 | "atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n", |
369 | atkbd->release ? "released" : "pressed", | 424 | code & 0x80 ? "e0" : "", code & 0x7f); |
370 | atkbd->translated ? "translated" : "raw", | 425 | input_sync(dev); |
371 | atkbd->set, code, serio->phys); | ||
372 | printk(KERN_WARNING "atkbd.c: Use 'setkeycodes %s%02x <keycode>' " | ||
373 | "to make it known.\n", | ||
374 | code & 0x80 ? "e0" : "", code & 0x7f); | ||
375 | } | ||
376 | input_sync(atkbd->dev); | ||
377 | break; | 426 | break; |
378 | case ATKBD_SCR_1: | 427 | case ATKBD_SCR_1: |
379 | scroll = 1 - atkbd->release * 2; | 428 | scroll = 1 - atkbd->release * 2; |
@@ -397,33 +446,35 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
397 | hscroll = 1; | 446 | hscroll = 1; |
398 | break; | 447 | break; |
399 | default: | 448 | default: |
400 | value = atkbd->release ? 0 : | 449 | if (atkbd->release) { |
401 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev->key))); | 450 | value = 0; |
402 | 451 | atkbd->last = 0; | |
403 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ | 452 | } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) { |
404 | case 0: | 453 | /* Workaround Toshiba laptop multiple keypress */ |
405 | atkbd->last = 0; | 454 | value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2; |
406 | break; | 455 | } else { |
407 | case 1: | 456 | value = 1; |
408 | atkbd->last = code; | 457 | atkbd->last = code; |
409 | atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev->rep[REP_DELAY]) / 2; | 458 | atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; |
410 | break; | ||
411 | case 2: | ||
412 | if (!time_after(jiffies, atkbd->time) && atkbd->last == code) | ||
413 | value = 1; | ||
414 | break; | ||
415 | } | 459 | } |
416 | 460 | ||
417 | atkbd_report_key(atkbd->dev, regs, atkbd->keycode[code], value); | 461 | input_regs(dev, regs); |
462 | input_report_key(dev, keycode, value); | ||
463 | input_sync(dev); | ||
464 | |||
465 | if (value && add_release_event) { | ||
466 | input_report_key(dev, keycode, 0); | ||
467 | input_sync(dev); | ||
468 | } | ||
418 | } | 469 | } |
419 | 470 | ||
420 | if (atkbd->scroll) { | 471 | if (atkbd->scroll) { |
421 | input_regs(atkbd->dev, regs); | 472 | input_regs(dev, regs); |
422 | if (click != -1) | 473 | if (click != -1) |
423 | input_report_key(atkbd->dev, BTN_MIDDLE, click); | 474 | input_report_key(dev, BTN_MIDDLE, click); |
424 | input_report_rel(atkbd->dev, REL_WHEEL, scroll); | 475 | input_report_rel(dev, REL_WHEEL, scroll); |
425 | input_report_rel(atkbd->dev, REL_HWHEEL, hscroll); | 476 | input_report_rel(dev, REL_HWHEEL, hscroll); |
426 | input_sync(atkbd->dev); | 477 | input_sync(dev); |
427 | } | 478 | } |
428 | 479 | ||
429 | atkbd->release = 0; | 480 | atkbd->release = 0; |
@@ -764,6 +815,9 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd) | |||
764 | for (i = 0; i < ARRAY_SIZE(atkbd_scroll_keys); i++) | 815 | for (i = 0; i < ARRAY_SIZE(atkbd_scroll_keys); i++) |
765 | atkbd->keycode[atkbd_scroll_keys[i].set2] = atkbd_scroll_keys[i].keycode; | 816 | atkbd->keycode[atkbd_scroll_keys[i].set2] = atkbd_scroll_keys[i].keycode; |
766 | } | 817 | } |
818 | |||
819 | atkbd->keycode[atkbd_compat_scancode(atkbd, ATKBD_RET_HANGEUL)] = KEY_HANGUEL; | ||
820 | atkbd->keycode[atkbd_compat_scancode(atkbd, ATKBD_RET_HANJA)] = KEY_HANJA; | ||
767 | } | 821 | } |
768 | 822 | ||
769 | /* | 823 | /* |
@@ -776,12 +830,15 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd) | |||
776 | int i; | 830 | int i; |
777 | 831 | ||
778 | if (atkbd->extra) | 832 | if (atkbd->extra) |
779 | sprintf(atkbd->name, "AT Set 2 Extra keyboard"); | 833 | snprintf(atkbd->name, sizeof(atkbd->name), |
834 | "AT Set 2 Extra keyboard"); | ||
780 | else | 835 | else |
781 | sprintf(atkbd->name, "AT %s Set %d keyboard", | 836 | snprintf(atkbd->name, sizeof(atkbd->name), |
782 | atkbd->translated ? "Translated" : "Raw", atkbd->set); | 837 | "AT %s Set %d keyboard", |
838 | atkbd->translated ? "Translated" : "Raw", atkbd->set); | ||
783 | 839 | ||
784 | sprintf(atkbd->phys, "%s/input0", atkbd->ps2dev.serio->phys); | 840 | snprintf(atkbd->phys, sizeof(atkbd->phys), |
841 | "%s/input0", atkbd->ps2dev.serio->phys); | ||
785 | 842 | ||
786 | input_dev->name = atkbd->name; | 843 | input_dev->name = atkbd->name; |
787 | input_dev->phys = atkbd->phys; | 844 | input_dev->phys = atkbd->phys; |
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 77c4d9669ad0..5174224cadb4 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c | |||
@@ -384,18 +384,21 @@ lkkbd_detection_done (struct lkkbd *lk) | |||
384 | */ | 384 | */ |
385 | switch (lk->id[4]) { | 385 | switch (lk->id[4]) { |
386 | case 1: | 386 | case 1: |
387 | sprintf (lk->name, "DEC LK201 keyboard"); | 387 | strlcpy (lk->name, "DEC LK201 keyboard", |
388 | sizeof (lk->name)); | ||
388 | 389 | ||
389 | if (lk201_compose_is_alt) | 390 | if (lk201_compose_is_alt) |
390 | lk->keycode[0xb1] = KEY_LEFTALT; | 391 | lk->keycode[0xb1] = KEY_LEFTALT; |
391 | break; | 392 | break; |
392 | 393 | ||
393 | case 2: | 394 | case 2: |
394 | sprintf (lk->name, "DEC LK401 keyboard"); | 395 | strlcpy (lk->name, "DEC LK401 keyboard", |
396 | sizeof (lk->name)); | ||
395 | break; | 397 | break; |
396 | 398 | ||
397 | default: | 399 | default: |
398 | sprintf (lk->name, "Unknown DEC keyboard"); | 400 | strlcpy (lk->name, "Unknown DEC keyboard", |
401 | sizeof (lk->name)); | ||
399 | printk (KERN_ERR "lkkbd: keyboard on %s is unknown, " | 402 | printk (KERN_ERR "lkkbd: keyboard on %s is unknown, " |
400 | "please report to Jan-Benedict Glaw " | 403 | "please report to Jan-Benedict Glaw " |
401 | "<jbglaw@lug-owl.de>\n", lk->phys); | 404 | "<jbglaw@lug-owl.de>\n", lk->phys); |
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index d10983c521e6..40a3f551247e 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c | |||
@@ -96,7 +96,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
96 | 96 | ||
97 | nkbd->serio = serio; | 97 | nkbd->serio = serio; |
98 | nkbd->dev = input_dev; | 98 | nkbd->dev = input_dev; |
99 | sprintf(nkbd->phys, "%s/input0", serio->phys); | 99 | snprintf(nkbd->phys, sizeof(nkbd->phys), "%s/input0", serio->phys); |
100 | memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode)); | 100 | memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode)); |
101 | 101 | ||
102 | input_dev->name = "Newton Keyboard"; | 102 | input_dev->name = "Newton Keyboard"; |
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index b15b6d8d4f83..9dbd7b85686d 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -263,7 +263,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
263 | goto fail; | 263 | goto fail; |
264 | } | 264 | } |
265 | 265 | ||
266 | sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type); | 266 | snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); |
267 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); | 267 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); |
268 | 268 | ||
269 | input_dev->name = sunkbd->name; | 269 | input_dev->name = sunkbd->name; |
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 4135e3e16c51..0821d53cf0c1 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c | |||
@@ -100,7 +100,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
100 | 100 | ||
101 | xtkbd->serio = serio; | 101 | xtkbd->serio = serio; |
102 | xtkbd->dev = input_dev; | 102 | xtkbd->dev = input_dev; |
103 | sprintf(xtkbd->phys, "%s/input0", serio->phys); | 103 | snprintf(xtkbd->phys, sizeof(xtkbd->phys), "%s/input0", serio->phys); |
104 | memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode)); | 104 | memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode)); |
105 | 105 | ||
106 | input_dev->name = "XT Keyboard"; | 106 | input_dev->name = "XT Keyboard"; |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index a0e2e797c6d5..070d75330afd 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -470,7 +470,7 @@ int alps_init(struct psmouse *psmouse) | |||
470 | dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); | 470 | dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); |
471 | } | 471 | } |
472 | 472 | ||
473 | sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys); | 473 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys); |
474 | dev2->phys = priv->phys; | 474 | dev2->phys = priv->phys; |
475 | dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; | 475 | dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; |
476 | dev2->id.bustype = BUS_I8042; | 476 | dev2->id.bustype = BUS_I8042; |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 136321a2cfdb..8bc9f51ae6c2 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -150,9 +150,20 @@ static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_reg | |||
150 | */ | 150 | */ |
151 | 151 | ||
152 | if (psmouse->type == PSMOUSE_IMEX) { | 152 | if (psmouse->type == PSMOUSE_IMEX) { |
153 | input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7)); | 153 | switch (packet[3] & 0xC0) { |
154 | input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1); | 154 | case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */ |
155 | input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1); | 155 | input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31)); |
156 | break; | ||
157 | case 0x40: /* horizontal scroll on IntelliMouse Explorer 4.0 */ | ||
158 | input_report_rel(dev, REL_HWHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31)); | ||
159 | break; | ||
160 | case 0x00: | ||
161 | case 0xC0: | ||
162 | input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7)); | ||
163 | input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1); | ||
164 | input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1); | ||
165 | break; | ||
166 | } | ||
156 | } | 167 | } |
157 | 168 | ||
158 | /* | 169 | /* |
@@ -466,9 +477,25 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties) | |||
466 | if (param[0] != 4) | 477 | if (param[0] != 4) |
467 | return -1; | 478 | return -1; |
468 | 479 | ||
480 | /* Magic to enable horizontal scrolling on IntelliMouse 4.0 */ | ||
481 | param[0] = 200; | ||
482 | ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); | ||
483 | param[0] = 80; | ||
484 | ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); | ||
485 | param[0] = 40; | ||
486 | ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); | ||
487 | |||
488 | param[0] = 200; | ||
489 | ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); | ||
490 | param[0] = 200; | ||
491 | ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); | ||
492 | param[0] = 60; | ||
493 | ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); | ||
494 | |||
469 | if (set_properties) { | 495 | if (set_properties) { |
470 | set_bit(BTN_MIDDLE, psmouse->dev->keybit); | 496 | set_bit(BTN_MIDDLE, psmouse->dev->keybit); |
471 | set_bit(REL_WHEEL, psmouse->dev->relbit); | 497 | set_bit(REL_WHEEL, psmouse->dev->relbit); |
498 | set_bit(REL_HWHEEL, psmouse->dev->relbit); | ||
472 | set_bit(BTN_SIDE, psmouse->dev->keybit); | 499 | set_bit(BTN_SIDE, psmouse->dev->keybit); |
473 | set_bit(BTN_EXTRA, psmouse->dev->keybit); | 500 | set_bit(BTN_EXTRA, psmouse->dev->keybit); |
474 | 501 | ||
@@ -1057,8 +1084,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto | |||
1057 | if (psmouse->resync_time && psmouse->poll(psmouse)) | 1084 | if (psmouse->resync_time && psmouse->poll(psmouse)) |
1058 | psmouse->resync_time = 0; | 1085 | psmouse->resync_time = 0; |
1059 | 1086 | ||
1060 | sprintf(psmouse->devname, "%s %s %s", | 1087 | snprintf(psmouse->devname, sizeof(psmouse->devname), "%s %s %s", |
1061 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); | 1088 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); |
1062 | 1089 | ||
1063 | input_dev->name = psmouse->devname; | 1090 | input_dev->name = psmouse->devname; |
1064 | input_dev->phys = psmouse->phys; | 1091 | input_dev->phys = psmouse->phys; |
@@ -1099,7 +1126,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
1099 | ps2_init(&psmouse->ps2dev, serio); | 1126 | ps2_init(&psmouse->ps2dev, serio); |
1100 | INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); | 1127 | INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); |
1101 | psmouse->dev = input_dev; | 1128 | psmouse->dev = input_dev; |
1102 | sprintf(psmouse->phys, "%s/input0", serio->phys); | 1129 | snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); |
1103 | 1130 | ||
1104 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | 1131 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); |
1105 | 1132 | ||
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index 2f9a04ae725f..a89742431717 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c | |||
@@ -254,7 +254,7 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv) | |||
254 | goto fail; | 254 | goto fail; |
255 | 255 | ||
256 | sermouse->dev = input_dev; | 256 | sermouse->dev = input_dev; |
257 | sprintf(sermouse->phys, "%s/input0", serio->phys); | 257 | snprintf(sermouse->phys, sizeof(sermouse->phys), "%s/input0", serio->phys); |
258 | sermouse->type = serio->id.proto; | 258 | sermouse->type = serio->id.proto; |
259 | 259 | ||
260 | input_dev->name = sermouse_protocols[sermouse->type]; | 260 | input_dev->name = sermouse_protocols[sermouse->type]; |
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index 36e9442a16b2..7b85bc21ae4a 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c | |||
@@ -153,22 +153,25 @@ vsxxxaa_detection_done (struct vsxxxaa *mouse) | |||
153 | { | 153 | { |
154 | switch (mouse->type) { | 154 | switch (mouse->type) { |
155 | case 0x02: | 155 | case 0x02: |
156 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse"); | 156 | strlcpy (mouse->name, "DEC VSXXX-AA/-GA mouse", |
157 | sizeof (mouse->name)); | ||
157 | break; | 158 | break; |
158 | 159 | ||
159 | case 0x04: | 160 | case 0x04: |
160 | sprintf (mouse->name, "DEC VSXXX-AB digitizer"); | 161 | strlcpy (mouse->name, "DEC VSXXX-AB digitizer", |
162 | sizeof (mouse->name)); | ||
161 | break; | 163 | break; |
162 | 164 | ||
163 | default: | 165 | default: |
164 | sprintf (mouse->name, "unknown DEC pointer device " | 166 | snprintf (mouse->name, sizeof (mouse->name), |
165 | "(type = 0x%02x)", mouse->type); | 167 | "unknown DEC pointer device (type = 0x%02x)", |
168 | mouse->type); | ||
166 | break; | 169 | break; |
167 | } | 170 | } |
168 | 171 | ||
169 | printk (KERN_INFO "Found %s version 0x%02x from country 0x%02x " | 172 | printk (KERN_INFO |
170 | "on port %s\n", mouse->name, mouse->version, | 173 | "Found %s version 0x%02x from country 0x%02x on port %s\n", |
171 | mouse->country, mouse->phys); | 174 | mouse->name, mouse->version, mouse->country, mouse->phys); |
172 | } | 175 | } |
173 | 176 | ||
174 | /* | 177 | /* |
@@ -503,8 +506,9 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) | |||
503 | 506 | ||
504 | mouse->dev = input_dev; | 507 | mouse->dev = input_dev; |
505 | mouse->serio = serio; | 508 | mouse->serio = serio; |
506 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); | 509 | strlcat (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer", |
507 | sprintf (mouse->phys, "%s/input0", serio->phys); | 510 | sizeof (mouse->name)); |
511 | snprintf (mouse->phys, sizeof (mouse->phys), "%s/input0", serio->phys); | ||
508 | 512 | ||
509 | input_dev->name = mouse->name; | 513 | input_dev->name = mouse->name; |
510 | input_dev->phys = mouse->phys; | 514 | input_dev->phys = mouse->phys; |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index b685a507955d..eb721b11ff37 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -123,7 +123,9 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous | |||
123 | 123 | ||
124 | if (mousedev->touch) { | 124 | if (mousedev->touch) { |
125 | size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; | 125 | size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; |
126 | if (size == 0) size = 256 * 2; | 126 | if (size == 0) |
127 | size = 256 * 2; | ||
128 | |||
127 | switch (code) { | 129 | switch (code) { |
128 | case ABS_X: | 130 | case ABS_X: |
129 | fx(0) = value; | 131 | fx(0) = value; |
@@ -155,18 +157,24 @@ static void mousedev_abs_event(struct input_dev *dev, struct mousedev *mousedev, | |||
155 | switch (code) { | 157 | switch (code) { |
156 | case ABS_X: | 158 | case ABS_X: |
157 | size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; | 159 | size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; |
158 | if (size == 0) size = xres ? : 1; | 160 | if (size == 0) |
159 | if (value > dev->absmax[ABS_X]) value = dev->absmax[ABS_X]; | 161 | size = xres ? : 1; |
160 | if (value < dev->absmin[ABS_X]) value = dev->absmin[ABS_X]; | 162 | if (value > dev->absmax[ABS_X]) |
163 | value = dev->absmax[ABS_X]; | ||
164 | if (value < dev->absmin[ABS_X]) | ||
165 | value = dev->absmin[ABS_X]; | ||
161 | mousedev->packet.x = ((value - dev->absmin[ABS_X]) * xres) / size; | 166 | mousedev->packet.x = ((value - dev->absmin[ABS_X]) * xres) / size; |
162 | mousedev->packet.abs_event = 1; | 167 | mousedev->packet.abs_event = 1; |
163 | break; | 168 | break; |
164 | 169 | ||
165 | case ABS_Y: | 170 | case ABS_Y: |
166 | size = dev->absmax[ABS_Y] - dev->absmin[ABS_Y]; | 171 | size = dev->absmax[ABS_Y] - dev->absmin[ABS_Y]; |
167 | if (size == 0) size = yres ? : 1; | 172 | if (size == 0) |
168 | if (value > dev->absmax[ABS_Y]) value = dev->absmax[ABS_Y]; | 173 | size = yres ? : 1; |
169 | if (value < dev->absmin[ABS_Y]) value = dev->absmin[ABS_Y]; | 174 | if (value > dev->absmax[ABS_Y]) |
175 | value = dev->absmax[ABS_Y]; | ||
176 | if (value < dev->absmin[ABS_Y]) | ||
177 | value = dev->absmin[ABS_Y]; | ||
170 | mousedev->packet.y = yres - ((value - dev->absmin[ABS_Y]) * yres) / size; | 178 | mousedev->packet.y = yres - ((value - dev->absmin[ABS_Y]) * yres) / size; |
171 | mousedev->packet.abs_event = 1; | 179 | mousedev->packet.abs_event = 1; |
172 | break; | 180 | break; |
@@ -202,7 +210,7 @@ static void mousedev_key_event(struct mousedev *mousedev, unsigned int code, int | |||
202 | case BTN_SIDE: index = 3; break; | 210 | case BTN_SIDE: index = 3; break; |
203 | case BTN_4: | 211 | case BTN_4: |
204 | case BTN_EXTRA: index = 4; break; | 212 | case BTN_EXTRA: index = 4; break; |
205 | default: return; | 213 | default: return; |
206 | } | 214 | } |
207 | 215 | ||
208 | if (value) { | 216 | if (value) { |
@@ -285,10 +293,9 @@ static void mousedev_touchpad_touch(struct mousedev *mousedev, int value) | |||
285 | mousedev->touch = mousedev->pkt_count = 0; | 293 | mousedev->touch = mousedev->pkt_count = 0; |
286 | mousedev->frac_dx = 0; | 294 | mousedev->frac_dx = 0; |
287 | mousedev->frac_dy = 0; | 295 | mousedev->frac_dy = 0; |
288 | } | 296 | |
289 | else | 297 | } else if (!mousedev->touch) |
290 | if (!mousedev->touch) | 298 | mousedev->touch = jiffies; |
291 | mousedev->touch = jiffies; | ||
292 | } | 299 | } |
293 | 300 | ||
294 | static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) | 301 | static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
@@ -327,7 +334,7 @@ static void mousedev_event(struct input_handle *handle, unsigned int type, unsig | |||
327 | mousedev->pkt_count++; | 334 | mousedev->pkt_count++; |
328 | /* Input system eats duplicate events, but we need all of them | 335 | /* Input system eats duplicate events, but we need all of them |
329 | * to do correct averaging so apply present one forward | 336 | * to do correct averaging so apply present one forward |
330 | */ | 337 | */ |
331 | fx(0) = fx(1); | 338 | fx(0) = fx(1); |
332 | fy(0) = fy(1); | 339 | fy(0) = fy(1); |
333 | } | 340 | } |
@@ -346,7 +353,9 @@ static int mousedev_fasync(int fd, struct file *file, int on) | |||
346 | { | 353 | { |
347 | int retval; | 354 | int retval; |
348 | struct mousedev_list *list = file->private_data; | 355 | struct mousedev_list *list = file->private_data; |
356 | |||
349 | retval = fasync_helper(fd, file, on, &list->fasync); | 357 | retval = fasync_helper(fd, file, on, &list->fasync); |
358 | |||
350 | return retval < 0 ? retval : 0; | 359 | return retval < 0 ? retval : 0; |
351 | } | 360 | } |
352 | 361 | ||
@@ -507,14 +516,16 @@ static ssize_t mousedev_write(struct file * file, const char __user * buffer, si | |||
507 | list->imexseq = 0; | 516 | list->imexseq = 0; |
508 | list->mode = MOUSEDEV_EMUL_EXPS; | 517 | list->mode = MOUSEDEV_EMUL_EXPS; |
509 | } | 518 | } |
510 | } else list->imexseq = 0; | 519 | } else |
520 | list->imexseq = 0; | ||
511 | 521 | ||
512 | if (c == mousedev_imps_seq[list->impsseq]) { | 522 | if (c == mousedev_imps_seq[list->impsseq]) { |
513 | if (++list->impsseq == MOUSEDEV_SEQ_LEN) { | 523 | if (++list->impsseq == MOUSEDEV_SEQ_LEN) { |
514 | list->impsseq = 0; | 524 | list->impsseq = 0; |
515 | list->mode = MOUSEDEV_EMUL_IMPS; | 525 | list->mode = MOUSEDEV_EMUL_IMPS; |
516 | } | 526 | } |
517 | } else list->impsseq = 0; | 527 | } else |
528 | list->impsseq = 0; | ||
518 | 529 | ||
519 | list->ps2[0] = 0xfa; | 530 | list->ps2[0] = 0xfa; |
520 | 531 | ||
@@ -598,6 +609,7 @@ static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t co | |||
598 | static unsigned int mousedev_poll(struct file *file, poll_table *wait) | 609 | static unsigned int mousedev_poll(struct file *file, poll_table *wait) |
599 | { | 610 | { |
600 | struct mousedev_list *list = file->private_data; | 611 | struct mousedev_list *list = file->private_data; |
612 | |||
601 | poll_wait(file, &list->mousedev->wait, wait); | 613 | poll_wait(file, &list->mousedev->wait, wait); |
602 | return ((list->ready || list->buffer) ? (POLLIN | POLLRDNORM) : 0) | | 614 | return ((list->ready || list->buffer) ? (POLLIN | POLLRDNORM) : 0) | |
603 | (list->mousedev->exist ? 0 : (POLLHUP | POLLERR)); | 615 | (list->mousedev->exist ? 0 : (POLLHUP | POLLERR)); |
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 466da190ceec..b769b21973b7 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c | |||
@@ -129,7 +129,7 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv) | |||
129 | 129 | ||
130 | gunze->serio = serio; | 130 | gunze->serio = serio; |
131 | gunze->dev = input_dev; | 131 | gunze->dev = input_dev; |
132 | sprintf(gunze->phys, "%s/input0", serio->phys); | 132 | snprintf(gunze->phys, sizeof(serio->phys), "%s/input0", serio->phys); |
133 | 133 | ||
134 | input_dev->private = gunze; | 134 | input_dev->private = gunze; |
135 | input_dev->name = "Gunze AHL-51S TouchScreen"; | 135 | input_dev->name = "Gunze AHL-51S TouchScreen"; |
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index a595d386312f..2de2139f2fed 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c | |||
@@ -363,7 +363,7 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) | |||
363 | 363 | ||
364 | ts->serio = serio; | 364 | ts->serio = serio; |
365 | ts->dev = input_dev; | 365 | ts->dev = input_dev; |
366 | sprintf(ts->phys, "%s/input0", serio->phys); | 366 | snprintf(ts->phys, sizeof(ts->phys), "%s/input0", serio->phys); |
367 | 367 | ||
368 | input_dev->name = "H3600 TouchScreen"; | 368 | input_dev->name = "H3600 TouchScreen"; |
369 | input_dev->phys = ts->phys; | 369 | input_dev->phys = ts->phys; |
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index 1d0d37eeef6e..8647a905df80 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c | |||
@@ -143,7 +143,7 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv) | |||
143 | 143 | ||
144 | mtouch->serio = serio; | 144 | mtouch->serio = serio; |
145 | mtouch->dev = input_dev; | 145 | mtouch->dev = input_dev; |
146 | sprintf(mtouch->phys, "%s/input0", serio->phys); | 146 | snprintf(mtouch->phys, sizeof(mtouch->phys), "%s/input0", serio->phys); |
147 | 147 | ||
148 | input_dev->private = mtouch; | 148 | input_dev->private = mtouch; |
149 | input_dev->name = "MicroTouch Serial TouchScreen"; | 149 | input_dev->name = "MicroTouch Serial TouchScreen"; |
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c index d678d144bbf8..5f9ecad2ca75 100644 --- a/drivers/input/tsdev.c +++ b/drivers/input/tsdev.c | |||
@@ -35,7 +35,7 @@ | |||
35 | * e-mail - mail your message to <jsimmons@infradead.org>. | 35 | * e-mail - mail your message to <jsimmons@infradead.org>. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #define TSDEV_MINOR_BASE 128 | 38 | #define TSDEV_MINOR_BASE 128 |
39 | #define TSDEV_MINORS 32 | 39 | #define TSDEV_MINORS 32 |
40 | /* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */ | 40 | /* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */ |
41 | #define TSDEV_MINOR_MASK 15 | 41 | #define TSDEV_MINOR_MASK 15 |
@@ -230,6 +230,7 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, | |||
230 | static unsigned int tsdev_poll(struct file *file, poll_table * wait) | 230 | static unsigned int tsdev_poll(struct file *file, poll_table * wait) |
231 | { | 231 | { |
232 | struct tsdev_list *list = file->private_data; | 232 | struct tsdev_list *list = file->private_data; |
233 | |||
233 | poll_wait(file, &list->tsdev->wait, wait); | 234 | poll_wait(file, &list->tsdev->wait, wait); |
234 | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | | 235 | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | |
235 | (list->tsdev->exist ? 0 : (POLLHUP | POLLERR)); | 236 | (list->tsdev->exist ? 0 : (POLLHUP | POLLERR)); |
@@ -248,11 +249,13 @@ static int tsdev_ioctl(struct inode *inode, struct file *file, | |||
248 | sizeof (struct ts_calibration))) | 249 | sizeof (struct ts_calibration))) |
249 | retval = -EFAULT; | 250 | retval = -EFAULT; |
250 | break; | 251 | break; |
252 | |||
251 | case TS_SET_CAL: | 253 | case TS_SET_CAL: |
252 | if (copy_from_user (&tsdev->cal, (void __user *)arg, | 254 | if (copy_from_user (&tsdev->cal, (void __user *)arg, |
253 | sizeof (struct ts_calibration))) | 255 | sizeof (struct ts_calibration))) |
254 | retval = -EFAULT; | 256 | retval = -EFAULT; |
255 | break; | 257 | break; |
258 | |||
256 | default: | 259 | default: |
257 | retval = -EINVAL; | 260 | retval = -EINVAL; |
258 | break; | 261 | break; |
@@ -284,9 +287,11 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, | |||
284 | case ABS_X: | 287 | case ABS_X: |
285 | tsdev->x = value; | 288 | tsdev->x = value; |
286 | break; | 289 | break; |
290 | |||
287 | case ABS_Y: | 291 | case ABS_Y: |
288 | tsdev->y = value; | 292 | tsdev->y = value; |
289 | break; | 293 | break; |
294 | |||
290 | case ABS_PRESSURE: | 295 | case ABS_PRESSURE: |
291 | if (value > handle->dev->absmax[ABS_PRESSURE]) | 296 | if (value > handle->dev->absmax[ABS_PRESSURE]) |
292 | value = handle->dev->absmax[ABS_PRESSURE]; | 297 | value = handle->dev->absmax[ABS_PRESSURE]; |
@@ -307,6 +312,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, | |||
307 | else if (tsdev->x > xres) | 312 | else if (tsdev->x > xres) |
308 | tsdev->x = xres; | 313 | tsdev->x = xres; |
309 | break; | 314 | break; |
315 | |||
310 | case REL_Y: | 316 | case REL_Y: |
311 | tsdev->y += value; | 317 | tsdev->y += value; |
312 | if (tsdev->y < 0) | 318 | if (tsdev->y < 0) |
@@ -323,6 +329,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, | |||
323 | case 0: | 329 | case 0: |
324 | tsdev->pressure = 0; | 330 | tsdev->pressure = 0; |
325 | break; | 331 | break; |
332 | |||
326 | case 1: | 333 | case 1: |
327 | if (!tsdev->pressure) | 334 | if (!tsdev->pressure) |
328 | tsdev->pressure = 1; | 335 | tsdev->pressure = 1; |
@@ -370,9 +377,8 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, | |||
370 | struct class_device *cdev; | 377 | struct class_device *cdev; |
371 | int minor, delta; | 378 | int minor, delta; |
372 | 379 | ||
373 | for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor]; | 380 | for (minor = 0; minor < TSDEV_MINORS / 2 && tsdev_table[minor]; minor++); |
374 | minor++); | 381 | if (minor >= TSDEV_MINORS / 2) { |
375 | if (minor >= TSDEV_MINORS/2) { | ||
376 | printk(KERN_ERR | 382 | printk(KERN_ERR |
377 | "tsdev: You have way too many touchscreens\n"); | 383 | "tsdev: You have way too many touchscreens\n"); |
378 | return NULL; | 384 | return NULL; |
@@ -444,22 +450,22 @@ static struct input_device_id tsdev_ids[] = { | |||
444 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, | 450 | .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, |
445 | .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) }, | 451 | .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) }, |
446 | .relbit = { BIT(REL_X) | BIT(REL_Y) }, | 452 | .relbit = { BIT(REL_X) | BIT(REL_Y) }, |
447 | },/* A mouse like device, at least one button, two relative axes */ | 453 | }, /* A mouse like device, at least one button, two relative axes */ |
448 | 454 | ||
449 | { | 455 | { |
450 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, | 456 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, |
451 | .evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, | 457 | .evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, |
452 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, | 458 | .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, |
453 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) }, | 459 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) }, |
454 | },/* A tablet like device, at least touch detection, two absolute axes */ | 460 | }, /* A tablet like device, at least touch detection, two absolute axes */ |
455 | 461 | ||
456 | { | 462 | { |
457 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, | 463 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, |
458 | .evbit = { BIT(EV_ABS) }, | 464 | .evbit = { BIT(EV_ABS) }, |
459 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) }, | 465 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) }, |
460 | },/* A tablet like device with several gradations of pressure */ | 466 | }, /* A tablet like device with several gradations of pressure */ |
461 | 467 | ||
462 | {},/* Terminating entry */ | 468 | {} /* Terminating entry */ |
463 | }; | 469 | }; |
464 | 470 | ||
465 | MODULE_DEVICE_TABLE(input, tsdev_ids); | 471 | MODULE_DEVICE_TABLE(input, tsdev_ids); |