diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:48:47 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:48:47 -0400 |
commit | 1e0afb288e56d469ca1c583342bb9782d49333c6 (patch) | |
tree | 5d2f5d4ebc029a5361d66acebec3a8023ea05ad4 /drivers/input | |
parent | f60d2b111cd55c335c2b70e50d66a612d2b10856 (diff) |
Input: fix formatting to better follow CodingStyle
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/evdev.c | 10 | ||||
-rw-r--r-- | drivers/input/input.c | 37 | ||||
-rw-r--r-- | drivers/input/joydev.c | 69 | ||||
-rw-r--r-- | drivers/input/mousedev.c | 42 | ||||
-rw-r--r-- | drivers/input/tsdev.c | 22 |
5 files changed, 119 insertions, 61 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 d3cdb139e962..7570a3f52f18 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -64,11 +64,13 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in | |||
64 | case EV_SYN: | 64 | case EV_SYN: |
65 | switch (code) { | 65 | switch (code) { |
66 | case SYN_CONFIG: | 66 | case SYN_CONFIG: |
67 | if (dev->event) dev->event(dev, type, code, value); | 67 | if (dev->event) |
68 | dev->event(dev, type, code, value); | ||
68 | break; | 69 | break; |
69 | 70 | ||
70 | case SYN_REPORT: | 71 | case SYN_REPORT: |
71 | if (dev->sync) return; | 72 | if (dev->sync) |
73 | return; | ||
72 | dev->sync = 1; | 74 | dev->sync = 1; |
73 | break; | 75 | break; |
74 | } | 76 | } |
@@ -137,7 +139,8 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in | |||
137 | if (code > MSC_MAX || !test_bit(code, dev->mscbit)) | 139 | if (code > MSC_MAX || !test_bit(code, dev->mscbit)) |
138 | return; | 140 | return; |
139 | 141 | ||
140 | if (dev->event) dev->event(dev, type, code, value); | 142 | if (dev->event) |
143 | dev->event(dev, type, code, value); | ||
141 | 144 | ||
142 | break; | 145 | break; |
143 | 146 | ||
@@ -147,7 +150,9 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in | |||
147 | return; | 150 | return; |
148 | 151 | ||
149 | change_bit(code, dev->led); | 152 | change_bit(code, dev->led); |
150 | if (dev->event) dev->event(dev, type, code, value); | 153 | |
154 | if (dev->event) | ||
155 | dev->event(dev, type, code, value); | ||
151 | 156 | ||
152 | break; | 157 | break; |
153 | 158 | ||
@@ -159,21 +164,25 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in | |||
159 | if (!!test_bit(code, dev->snd) != !!value) | 164 | if (!!test_bit(code, dev->snd) != !!value) |
160 | change_bit(code, dev->snd); | 165 | change_bit(code, dev->snd); |
161 | 166 | ||
162 | if (dev->event) dev->event(dev, type, code, value); | 167 | if (dev->event) |
168 | dev->event(dev, type, code, value); | ||
163 | 169 | ||
164 | break; | 170 | break; |
165 | 171 | ||
166 | case EV_REP: | 172 | case EV_REP: |
167 | 173 | ||
168 | if (code > REP_MAX || value < 0 || dev->rep[code] == value) return; | 174 | if (code > REP_MAX || value < 0 || dev->rep[code] == value) |
175 | return; | ||
169 | 176 | ||
170 | dev->rep[code] = value; | 177 | dev->rep[code] = value; |
171 | if (dev->event) dev->event(dev, type, code, value); | 178 | if (dev->event) |
179 | dev->event(dev, type, code, value); | ||
172 | 180 | ||
173 | break; | 181 | break; |
174 | 182 | ||
175 | case EV_FF: | 183 | case EV_FF: |
176 | if (dev->event) dev->event(dev, type, code, value); | 184 | if (dev->event) |
185 | dev->event(dev, type, code, value); | ||
177 | break; | 186 | break; |
178 | } | 187 | } |
179 | 188 | ||
@@ -336,9 +345,11 @@ static inline void input_wakeup_procfs_readers(void) | |||
336 | static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) | 345 | static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) |
337 | { | 346 | { |
338 | int state = input_devices_state; | 347 | int state = input_devices_state; |
348 | |||
339 | poll_wait(file, &input_devices_poll_wait, wait); | 349 | poll_wait(file, &input_devices_poll_wait, wait); |
340 | if (state != input_devices_state) | 350 | if (state != input_devices_state) |
341 | return POLLIN | POLLRDNORM; | 351 | return POLLIN | POLLRDNORM; |
352 | |||
342 | return 0; | 353 | return 0; |
343 | } | 354 | } |
344 | 355 | ||
@@ -972,9 +983,10 @@ int input_register_device(struct input_dev *dev) | |||
972 | 983 | ||
973 | void input_unregister_device(struct input_dev *dev) | 984 | void input_unregister_device(struct input_dev *dev) |
974 | { | 985 | { |
975 | struct list_head * node, * next; | 986 | struct list_head *node, *next; |
976 | 987 | ||
977 | if (!dev) return; | 988 | if (!dev) |
989 | return; | ||
978 | 990 | ||
979 | del_timer_sync(&dev->timer); | 991 | del_timer_sync(&dev->timer); |
980 | 992 | ||
@@ -1005,7 +1017,8 @@ void input_register_handler(struct input_handler *handler) | |||
1005 | struct input_handle *handle; | 1017 | struct input_handle *handle; |
1006 | struct input_device_id *id; | 1018 | struct input_device_id *id; |
1007 | 1019 | ||
1008 | if (!handler) return; | 1020 | if (!handler) |
1021 | return; | ||
1009 | 1022 | ||
1010 | INIT_LIST_HEAD(&handler->h_list); | 1023 | INIT_LIST_HEAD(&handler->h_list); |
1011 | 1024 | ||
@@ -1025,7 +1038,7 @@ void input_register_handler(struct input_handler *handler) | |||
1025 | 1038 | ||
1026 | void input_unregister_handler(struct input_handler *handler) | 1039 | void input_unregister_handler(struct input_handler *handler) |
1027 | { | 1040 | { |
1028 | struct list_head * node, * next; | 1041 | struct list_head *node, *next; |
1029 | 1042 | ||
1030 | list_for_each_safe(node, next, &handler->h_list) { | 1043 | list_for_each_safe(node, next, &handler->h_list) { |
1031 | struct input_handle * handle = to_handle_h(node); | 1044 | struct input_handle * handle = to_handle_h(node); |
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/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/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); |