diff options
-rw-r--r-- | drivers/input/evdev.c | 150 | ||||
-rw-r--r-- | drivers/input/joydev.c | 130 | ||||
-rw-r--r-- | drivers/input/mousedev.c | 237 | ||||
-rw-r--r-- | drivers/input/tsdev.c | 110 |
4 files changed, 329 insertions, 298 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 840fa1986527..8a4cce5c7806 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -29,11 +29,11 @@ struct evdev { | |||
29 | char name[16]; | 29 | char name[16]; |
30 | struct input_handle handle; | 30 | struct input_handle handle; |
31 | wait_queue_head_t wait; | 31 | wait_queue_head_t wait; |
32 | struct evdev_list *grab; | 32 | struct evdev_client *grab; |
33 | struct list_head list; | 33 | struct list_head client_list; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | struct evdev_list { | 36 | struct evdev_client { |
37 | struct input_event buffer[EVDEV_BUFFER_SIZE]; | 37 | struct input_event buffer[EVDEV_BUFFER_SIZE]; |
38 | int head; | 38 | int head; |
39 | int tail; | 39 | int tail; |
@@ -47,28 +47,28 @@ static struct evdev *evdev_table[EVDEV_MINORS]; | |||
47 | static void evdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) | 47 | static void evdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
48 | { | 48 | { |
49 | struct evdev *evdev = handle->private; | 49 | struct evdev *evdev = handle->private; |
50 | struct evdev_list *list; | 50 | struct evdev_client *client; |
51 | 51 | ||
52 | if (evdev->grab) { | 52 | if (evdev->grab) { |
53 | list = evdev->grab; | 53 | client = evdev->grab; |
54 | 54 | ||
55 | do_gettimeofday(&list->buffer[list->head].time); | 55 | do_gettimeofday(&client->buffer[client->head].time); |
56 | list->buffer[list->head].type = type; | 56 | client->buffer[client->head].type = type; |
57 | list->buffer[list->head].code = code; | 57 | client->buffer[client->head].code = code; |
58 | list->buffer[list->head].value = value; | 58 | client->buffer[client->head].value = value; |
59 | list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1); | 59 | client->head = (client->head + 1) & (EVDEV_BUFFER_SIZE - 1); |
60 | 60 | ||
61 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 61 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
62 | } else | 62 | } else |
63 | list_for_each_entry(list, &evdev->list, node) { | 63 | list_for_each_entry(client, &evdev->client_list, node) { |
64 | 64 | ||
65 | do_gettimeofday(&list->buffer[list->head].time); | 65 | do_gettimeofday(&client->buffer[client->head].time); |
66 | list->buffer[list->head].type = type; | 66 | client->buffer[client->head].type = type; |
67 | list->buffer[list->head].code = code; | 67 | client->buffer[client->head].code = code; |
68 | list->buffer[list->head].value = value; | 68 | client->buffer[client->head].value = value; |
69 | list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1); | 69 | client->head = (client->head + 1) & (EVDEV_BUFFER_SIZE - 1); |
70 | 70 | ||
71 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 71 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
72 | } | 72 | } |
73 | 73 | ||
74 | wake_up_interruptible(&evdev->wait); | 74 | wake_up_interruptible(&evdev->wait); |
@@ -76,22 +76,23 @@ static void evdev_event(struct input_handle *handle, unsigned int type, unsigned | |||
76 | 76 | ||
77 | static int evdev_fasync(int fd, struct file *file, int on) | 77 | static int evdev_fasync(int fd, struct file *file, int on) |
78 | { | 78 | { |
79 | struct evdev_client *client = file->private_data; | ||
79 | int retval; | 80 | int retval; |
80 | struct evdev_list *list = file->private_data; | ||
81 | 81 | ||
82 | retval = fasync_helper(fd, file, on, &list->fasync); | 82 | retval = fasync_helper(fd, file, on, &client->fasync); |
83 | 83 | ||
84 | return retval < 0 ? retval : 0; | 84 | return retval < 0 ? retval : 0; |
85 | } | 85 | } |
86 | 86 | ||
87 | static int evdev_flush(struct file *file, fl_owner_t id) | 87 | static int evdev_flush(struct file *file, fl_owner_t id) |
88 | { | 88 | { |
89 | struct evdev_list *list = file->private_data; | 89 | struct evdev_client *client = file->private_data; |
90 | struct evdev *evdev = client->evdev; | ||
90 | 91 | ||
91 | if (!list->evdev->exist) | 92 | if (!evdev->exist) |
92 | return -ENODEV; | 93 | return -ENODEV; |
93 | 94 | ||
94 | return input_flush_device(&list->evdev->handle, file); | 95 | return input_flush_device(&evdev->handle, file); |
95 | } | 96 | } |
96 | 97 | ||
97 | static void evdev_free(struct evdev *evdev) | 98 | static void evdev_free(struct evdev *evdev) |
@@ -100,48 +101,55 @@ static void evdev_free(struct evdev *evdev) | |||
100 | kfree(evdev); | 101 | kfree(evdev); |
101 | } | 102 | } |
102 | 103 | ||
103 | static int evdev_release(struct inode * inode, struct file * file) | 104 | static int evdev_release(struct inode *inode, struct file *file) |
104 | { | 105 | { |
105 | struct evdev_list *list = file->private_data; | 106 | struct evdev_client *client = file->private_data; |
107 | struct evdev *evdev = client->evdev; | ||
106 | 108 | ||
107 | if (list->evdev->grab == list) { | 109 | if (evdev->grab == client) { |
108 | input_release_device(&list->evdev->handle); | 110 | input_release_device(&evdev->handle); |
109 | list->evdev->grab = NULL; | 111 | evdev->grab = NULL; |
110 | } | 112 | } |
111 | 113 | ||
112 | evdev_fasync(-1, file, 0); | 114 | evdev_fasync(-1, file, 0); |
113 | list_del(&list->node); | 115 | list_del(&client->node); |
116 | kfree(client); | ||
114 | 117 | ||
115 | if (!--list->evdev->open) { | 118 | if (!--evdev->open) { |
116 | if (list->evdev->exist) | 119 | if (evdev->exist) |
117 | input_close_device(&list->evdev->handle); | 120 | input_close_device(&evdev->handle); |
118 | else | 121 | else |
119 | evdev_free(list->evdev); | 122 | evdev_free(evdev); |
120 | } | 123 | } |
121 | 124 | ||
122 | kfree(list); | ||
123 | return 0; | 125 | return 0; |
124 | } | 126 | } |
125 | 127 | ||
126 | static int evdev_open(struct inode * inode, struct file * file) | 128 | static int evdev_open(struct inode *inode, struct file *file) |
127 | { | 129 | { |
128 | struct evdev_list *list; | 130 | struct evdev_client *client; |
131 | struct evdev *evdev; | ||
129 | int i = iminor(inode) - EVDEV_MINOR_BASE; | 132 | int i = iminor(inode) - EVDEV_MINOR_BASE; |
130 | 133 | ||
131 | if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist) | 134 | if (i >= EVDEV_MINORS) |
135 | return -ENODEV; | ||
136 | |||
137 | evdev = evdev_table[i]; | ||
138 | |||
139 | if (!evdev || !evdev->exist) | ||
132 | return -ENODEV; | 140 | return -ENODEV; |
133 | 141 | ||
134 | if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL))) | 142 | client = kzalloc(sizeof(struct evdev_client), GFP_KERNEL); |
143 | if (!client) | ||
135 | return -ENOMEM; | 144 | return -ENOMEM; |
136 | 145 | ||
137 | list->evdev = evdev_table[i]; | 146 | client->evdev = evdev; |
138 | list_add_tail(&list->node, &evdev_table[i]->list); | 147 | list_add_tail(&client->node, &evdev->client_list); |
139 | file->private_data = list; | ||
140 | 148 | ||
141 | if (!list->evdev->open++) | 149 | if (!evdev->open++ && evdev->exist) |
142 | if (list->evdev->exist) | 150 | input_open_device(&evdev->handle); |
143 | input_open_device(&list->evdev->handle); | ||
144 | 151 | ||
152 | file->private_data = client; | ||
145 | return 0; | 153 | return 0; |
146 | } | 154 | } |
147 | 155 | ||
@@ -243,54 +251,55 @@ static int evdev_event_to_user(char __user *buffer, const struct input_event *ev | |||
243 | 251 | ||
244 | #endif /* CONFIG_COMPAT */ | 252 | #endif /* CONFIG_COMPAT */ |
245 | 253 | ||
246 | static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) | 254 | static ssize_t evdev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
247 | { | 255 | { |
248 | struct evdev_list *list = file->private_data; | 256 | struct evdev_client *client = file->private_data; |
257 | struct evdev *evdev = client->evdev; | ||
249 | struct input_event event; | 258 | struct input_event event; |
250 | int retval = 0; | 259 | int retval = 0; |
251 | 260 | ||
252 | if (!list->evdev->exist) | 261 | if (!evdev->exist) |
253 | return -ENODEV; | 262 | return -ENODEV; |
254 | 263 | ||
255 | while (retval < count) { | 264 | while (retval < count) { |
256 | 265 | ||
257 | if (evdev_event_from_user(buffer + retval, &event)) | 266 | if (evdev_event_from_user(buffer + retval, &event)) |
258 | return -EFAULT; | 267 | return -EFAULT; |
259 | input_inject_event(&list->evdev->handle, event.type, event.code, event.value); | 268 | input_inject_event(&evdev->handle, event.type, event.code, event.value); |
260 | retval += evdev_event_size(); | 269 | retval += evdev_event_size(); |
261 | } | 270 | } |
262 | 271 | ||
263 | return retval; | 272 | return retval; |
264 | } | 273 | } |
265 | 274 | ||
266 | static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) | 275 | static ssize_t evdev_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
267 | { | 276 | { |
268 | struct evdev_list *list = file->private_data; | 277 | struct evdev_client *client = file->private_data; |
278 | struct evdev *evdev = client->evdev; | ||
269 | int retval; | 279 | int retval; |
270 | 280 | ||
271 | if (count < evdev_event_size()) | 281 | if (count < evdev_event_size()) |
272 | return -EINVAL; | 282 | return -EINVAL; |
273 | 283 | ||
274 | if (list->head == list->tail && list->evdev->exist && (file->f_flags & O_NONBLOCK)) | 284 | if (client->head == client->tail && evdev->exist && (file->f_flags & O_NONBLOCK)) |
275 | return -EAGAIN; | 285 | return -EAGAIN; |
276 | 286 | ||
277 | retval = wait_event_interruptible(list->evdev->wait, | 287 | retval = wait_event_interruptible(evdev->wait, |
278 | list->head != list->tail || (!list->evdev->exist)); | 288 | client->head != client->tail || !evdev->exist); |
279 | |||
280 | if (retval) | 289 | if (retval) |
281 | return retval; | 290 | return retval; |
282 | 291 | ||
283 | if (!list->evdev->exist) | 292 | if (!evdev->exist) |
284 | return -ENODEV; | 293 | return -ENODEV; |
285 | 294 | ||
286 | while (list->head != list->tail && retval + evdev_event_size() <= count) { | 295 | while (client->head != client->tail && retval + evdev_event_size() <= count) { |
287 | 296 | ||
288 | struct input_event *event = (struct input_event *) list->buffer + list->tail; | 297 | struct input_event *event = (struct input_event *) client->buffer + client->tail; |
289 | 298 | ||
290 | if (evdev_event_to_user(buffer + retval, event)) | 299 | if (evdev_event_to_user(buffer + retval, event)) |
291 | return -EFAULT; | 300 | return -EFAULT; |
292 | 301 | ||
293 | list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); | 302 | client->tail = (client->tail + 1) & (EVDEV_BUFFER_SIZE - 1); |
294 | retval += evdev_event_size(); | 303 | retval += evdev_event_size(); |
295 | } | 304 | } |
296 | 305 | ||
@@ -300,11 +309,12 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count | |||
300 | /* No kernel lock - fine */ | 309 | /* No kernel lock - fine */ |
301 | static unsigned int evdev_poll(struct file *file, poll_table *wait) | 310 | static unsigned int evdev_poll(struct file *file, poll_table *wait) |
302 | { | 311 | { |
303 | struct evdev_list *list = file->private_data; | 312 | struct evdev_client *client = file->private_data; |
313 | struct evdev *evdev = client->evdev; | ||
304 | 314 | ||
305 | poll_wait(file, &list->evdev->wait, wait); | 315 | poll_wait(file, &evdev->wait, wait); |
306 | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | | 316 | return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) | |
307 | (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); | 317 | (evdev->exist ? 0 : (POLLHUP | POLLERR)); |
308 | } | 318 | } |
309 | 319 | ||
310 | #ifdef CONFIG_COMPAT | 320 | #ifdef CONFIG_COMPAT |
@@ -387,8 +397,8 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p) | |||
387 | static long evdev_ioctl_handler(struct file *file, unsigned int cmd, | 397 | static long evdev_ioctl_handler(struct file *file, unsigned int cmd, |
388 | void __user *p, int compat_mode) | 398 | void __user *p, int compat_mode) |
389 | { | 399 | { |
390 | struct evdev_list *list = file->private_data; | 400 | struct evdev_client *client = file->private_data; |
391 | struct evdev *evdev = list->evdev; | 401 | struct evdev *evdev = client->evdev; |
392 | struct input_dev *dev = evdev->handle.dev; | 402 | struct input_dev *dev = evdev->handle.dev; |
393 | struct input_absinfo abs; | 403 | struct input_absinfo abs; |
394 | struct ff_effect effect; | 404 | struct ff_effect effect; |
@@ -476,10 +486,10 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd, | |||
476 | return -EBUSY; | 486 | return -EBUSY; |
477 | if (input_grab_device(&evdev->handle)) | 487 | if (input_grab_device(&evdev->handle)) |
478 | return -EBUSY; | 488 | return -EBUSY; |
479 | evdev->grab = list; | 489 | evdev->grab = client; |
480 | return 0; | 490 | return 0; |
481 | } else { | 491 | } else { |
482 | if (evdev->grab != list) | 492 | if (evdev->grab != client) |
483 | return -EINVAL; | 493 | return -EINVAL; |
484 | input_release_device(&evdev->handle); | 494 | input_release_device(&evdev->handle); |
485 | evdev->grab = NULL; | 495 | evdev->grab = NULL; |
@@ -624,7 +634,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, | |||
624 | if (!evdev) | 634 | if (!evdev) |
625 | return -ENOMEM; | 635 | return -ENOMEM; |
626 | 636 | ||
627 | INIT_LIST_HEAD(&evdev->list); | 637 | INIT_LIST_HEAD(&evdev->client_list); |
628 | init_waitqueue_head(&evdev->wait); | 638 | init_waitqueue_head(&evdev->wait); |
629 | 639 | ||
630 | evdev->exist = 1; | 640 | evdev->exist = 1; |
@@ -671,7 +681,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, | |||
671 | static void evdev_disconnect(struct input_handle *handle) | 681 | static void evdev_disconnect(struct input_handle *handle) |
672 | { | 682 | { |
673 | struct evdev *evdev = handle->private; | 683 | struct evdev *evdev = handle->private; |
674 | struct evdev_list *list; | 684 | struct evdev_client *client; |
675 | 685 | ||
676 | input_unregister_handle(handle); | 686 | input_unregister_handle(handle); |
677 | 687 | ||
@@ -684,8 +694,8 @@ static void evdev_disconnect(struct input_handle *handle) | |||
684 | input_flush_device(handle, NULL); | 694 | input_flush_device(handle, NULL); |
685 | input_close_device(handle); | 695 | input_close_device(handle); |
686 | wake_up_interruptible(&evdev->wait); | 696 | wake_up_interruptible(&evdev->wait); |
687 | list_for_each_entry(list, &evdev->list, node) | 697 | list_for_each_entry(client, &evdev->client_list, node) |
688 | kill_fasync(&list->fasync, SIGIO, POLL_HUP); | 698 | kill_fasync(&client->fasync, SIGIO, POLL_HUP); |
689 | } else | 699 | } else |
690 | evdev_free(evdev); | 700 | evdev_free(evdev); |
691 | } | 701 | } |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index cf24a5bde539..09b8223de5ec 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -43,7 +43,7 @@ struct joydev { | |||
43 | char name[16]; | 43 | char name[16]; |
44 | struct input_handle handle; | 44 | struct input_handle handle; |
45 | wait_queue_head_t wait; | 45 | wait_queue_head_t wait; |
46 | struct list_head list; | 46 | struct list_head client_list; |
47 | struct js_corr corr[ABS_MAX + 1]; | 47 | struct js_corr corr[ABS_MAX + 1]; |
48 | struct JS_DATA_SAVE_TYPE glue; | 48 | struct JS_DATA_SAVE_TYPE glue; |
49 | int nabs; | 49 | int nabs; |
@@ -55,7 +55,7 @@ struct joydev { | |||
55 | __s16 abs[ABS_MAX + 1]; | 55 | __s16 abs[ABS_MAX + 1]; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct joydev_list { | 58 | struct joydev_client { |
59 | struct js_event buffer[JOYDEV_BUFFER_SIZE]; | 59 | struct js_event buffer[JOYDEV_BUFFER_SIZE]; |
60 | int head; | 60 | int head; |
61 | int tail; | 61 | int tail; |
@@ -87,7 +87,7 @@ static int joydev_correct(int value, struct js_corr *corr) | |||
87 | 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) |
88 | { | 88 | { |
89 | struct joydev *joydev = handle->private; | 89 | struct joydev *joydev = handle->private; |
90 | struct joydev_list *list; | 90 | struct joydev_client *client; |
91 | struct js_event event; | 91 | struct js_event event; |
92 | 92 | ||
93 | switch (type) { | 93 | switch (type) { |
@@ -115,15 +115,15 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne | |||
115 | 115 | ||
116 | event.time = jiffies_to_msecs(jiffies); | 116 | event.time = jiffies_to_msecs(jiffies); |
117 | 117 | ||
118 | list_for_each_entry(list, &joydev->list, node) { | 118 | list_for_each_entry(client, &joydev->client_list, node) { |
119 | 119 | ||
120 | memcpy(list->buffer + list->head, &event, sizeof(struct js_event)); | 120 | memcpy(client->buffer + client->head, &event, sizeof(struct js_event)); |
121 | 121 | ||
122 | if (list->startup == joydev->nabs + joydev->nkey) | 122 | if (client->startup == joydev->nabs + joydev->nkey) |
123 | if (list->tail == (list->head = (list->head + 1) & (JOYDEV_BUFFER_SIZE - 1))) | 123 | if (client->tail == (client->head = (client->head + 1) & (JOYDEV_BUFFER_SIZE - 1))) |
124 | list->startup = 0; | 124 | client->startup = 0; |
125 | 125 | ||
126 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 126 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
127 | } | 127 | } |
128 | 128 | ||
129 | wake_up_interruptible(&joydev->wait); | 129 | wake_up_interruptible(&joydev->wait); |
@@ -132,9 +132,9 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne | |||
132 | static int joydev_fasync(int fd, struct file *file, int on) | 132 | static int joydev_fasync(int fd, struct file *file, int on) |
133 | { | 133 | { |
134 | int retval; | 134 | int retval; |
135 | struct joydev_list *list = file->private_data; | 135 | struct joydev_client *client = file->private_data; |
136 | 136 | ||
137 | retval = fasync_helper(fd, file, on, &list->fasync); | 137 | retval = fasync_helper(fd, file, on, &client->fasync); |
138 | 138 | ||
139 | return retval < 0 ? retval : 0; | 139 | return retval < 0 ? retval : 0; |
140 | } | 140 | } |
@@ -145,60 +145,66 @@ static void joydev_free(struct joydev *joydev) | |||
145 | kfree(joydev); | 145 | kfree(joydev); |
146 | } | 146 | } |
147 | 147 | ||
148 | static int joydev_release(struct inode * inode, struct file * file) | 148 | static int joydev_release(struct inode *inode, struct file *file) |
149 | { | 149 | { |
150 | struct joydev_list *list = file->private_data; | 150 | struct joydev_client *client = file->private_data; |
151 | struct joydev *joydev = client->joydev; | ||
151 | 152 | ||
152 | joydev_fasync(-1, file, 0); | 153 | joydev_fasync(-1, file, 0); |
153 | 154 | ||
154 | list_del(&list->node); | 155 | list_del(&client->node); |
156 | kfree(client); | ||
155 | 157 | ||
156 | if (!--list->joydev->open) { | 158 | if (!--joydev->open) { |
157 | if (list->joydev->exist) | 159 | if (joydev->exist) |
158 | input_close_device(&list->joydev->handle); | 160 | input_close_device(&joydev->handle); |
159 | else | 161 | else |
160 | joydev_free(list->joydev); | 162 | joydev_free(joydev); |
161 | } | 163 | } |
162 | 164 | ||
163 | kfree(list); | ||
164 | return 0; | 165 | return 0; |
165 | } | 166 | } |
166 | 167 | ||
167 | static int joydev_open(struct inode *inode, struct file *file) | 168 | static int joydev_open(struct inode *inode, struct file *file) |
168 | { | 169 | { |
169 | struct joydev_list *list; | 170 | struct joydev_client *client; |
171 | struct joydev *joydev; | ||
170 | int i = iminor(inode) - JOYDEV_MINOR_BASE; | 172 | int i = iminor(inode) - JOYDEV_MINOR_BASE; |
171 | 173 | ||
172 | if (i >= JOYDEV_MINORS || !joydev_table[i]) | 174 | if (i >= JOYDEV_MINORS) |
175 | return -ENODEV; | ||
176 | |||
177 | joydev = joydev_table[i]; | ||
178 | if (!joydev || !joydev->exist) | ||
173 | return -ENODEV; | 179 | return -ENODEV; |
174 | 180 | ||
175 | if (!(list = kzalloc(sizeof(struct joydev_list), GFP_KERNEL))) | 181 | client = kzalloc(sizeof(struct joydev_client), GFP_KERNEL); |
182 | if (!client) | ||
176 | return -ENOMEM; | 183 | return -ENOMEM; |
177 | 184 | ||
178 | list->joydev = joydev_table[i]; | 185 | client->joydev = joydev; |
179 | list_add_tail(&list->node, &joydev_table[i]->list); | 186 | list_add_tail(&client->node, &joydev->client_list); |
180 | file->private_data = list; | ||
181 | 187 | ||
182 | if (!list->joydev->open++) | 188 | if (!joydev->open++ && joydev->exist) |
183 | if (list->joydev->exist) | 189 | input_open_device(&joydev->handle); |
184 | input_open_device(&list->joydev->handle); | ||
185 | 190 | ||
191 | file->private_data = client; | ||
186 | return 0; | 192 | return 0; |
187 | } | 193 | } |
188 | 194 | ||
189 | static ssize_t joydev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) | 195 | static ssize_t joydev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
190 | { | 196 | { |
191 | return -EINVAL; | 197 | return -EINVAL; |
192 | } | 198 | } |
193 | 199 | ||
194 | static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | 200 | static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) |
195 | { | 201 | { |
196 | struct joydev_list *list = file->private_data; | 202 | struct joydev_client *client = file->private_data; |
197 | struct joydev *joydev = list->joydev; | 203 | struct joydev *joydev = client->joydev; |
198 | struct input_dev *input = joydev->handle.dev; | 204 | struct input_dev *input = joydev->handle.dev; |
199 | int retval = 0; | 205 | int retval = 0; |
200 | 206 | ||
201 | if (!list->joydev->exist) | 207 | if (!joydev->exist) |
202 | return -ENODEV; | 208 | return -ENODEV; |
203 | 209 | ||
204 | if (count < sizeof(struct js_event)) | 210 | if (count < sizeof(struct js_event)) |
@@ -217,56 +223,55 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo | |||
217 | if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE))) | 223 | if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE))) |
218 | return -EFAULT; | 224 | return -EFAULT; |
219 | 225 | ||
220 | list->startup = 0; | 226 | client->startup = 0; |
221 | list->tail = list->head; | 227 | client->tail = client->head; |
222 | 228 | ||
223 | return sizeof(struct JS_DATA_TYPE); | 229 | return sizeof(struct JS_DATA_TYPE); |
224 | } | 230 | } |
225 | 231 | ||
226 | if (list->startup == joydev->nabs + joydev->nkey && | 232 | if (client->startup == joydev->nabs + joydev->nkey && |
227 | list->head == list->tail && (file->f_flags & O_NONBLOCK)) | 233 | client->head == client->tail && (file->f_flags & O_NONBLOCK)) |
228 | return -EAGAIN; | 234 | return -EAGAIN; |
229 | 235 | ||
230 | retval = wait_event_interruptible(list->joydev->wait, | 236 | retval = wait_event_interruptible(joydev->wait, |
231 | !list->joydev->exist || | 237 | !joydev->exist || |
232 | list->startup < joydev->nabs + joydev->nkey || | 238 | client->startup < joydev->nabs + joydev->nkey || |
233 | list->head != list->tail); | 239 | client->head != client->tail); |
234 | |||
235 | if (retval) | 240 | if (retval) |
236 | return retval; | 241 | return retval; |
237 | 242 | ||
238 | if (!list->joydev->exist) | 243 | if (!joydev->exist) |
239 | return -ENODEV; | 244 | return -ENODEV; |
240 | 245 | ||
241 | while (list->startup < joydev->nabs + joydev->nkey && retval + sizeof(struct js_event) <= count) { | 246 | while (client->startup < joydev->nabs + joydev->nkey && retval + sizeof(struct js_event) <= count) { |
242 | 247 | ||
243 | struct js_event event; | 248 | struct js_event event; |
244 | 249 | ||
245 | event.time = jiffies_to_msecs(jiffies); | 250 | event.time = jiffies_to_msecs(jiffies); |
246 | 251 | ||
247 | if (list->startup < joydev->nkey) { | 252 | if (client->startup < joydev->nkey) { |
248 | event.type = JS_EVENT_BUTTON | JS_EVENT_INIT; | 253 | event.type = JS_EVENT_BUTTON | JS_EVENT_INIT; |
249 | event.number = list->startup; | 254 | event.number = client->startup; |
250 | event.value = !!test_bit(joydev->keypam[event.number], input->key); | 255 | event.value = !!test_bit(joydev->keypam[event.number], input->key); |
251 | } else { | 256 | } else { |
252 | event.type = JS_EVENT_AXIS | JS_EVENT_INIT; | 257 | event.type = JS_EVENT_AXIS | JS_EVENT_INIT; |
253 | event.number = list->startup - joydev->nkey; | 258 | event.number = client->startup - joydev->nkey; |
254 | event.value = joydev->abs[event.number]; | 259 | event.value = joydev->abs[event.number]; |
255 | } | 260 | } |
256 | 261 | ||
257 | if (copy_to_user(buf + retval, &event, sizeof(struct js_event))) | 262 | if (copy_to_user(buf + retval, &event, sizeof(struct js_event))) |
258 | return -EFAULT; | 263 | return -EFAULT; |
259 | 264 | ||
260 | list->startup++; | 265 | client->startup++; |
261 | retval += sizeof(struct js_event); | 266 | retval += sizeof(struct js_event); |
262 | } | 267 | } |
263 | 268 | ||
264 | while (list->head != list->tail && retval + sizeof(struct js_event) <= count) { | 269 | while (client->head != client->tail && retval + sizeof(struct js_event) <= count) { |
265 | 270 | ||
266 | if (copy_to_user(buf + retval, list->buffer + list->tail, sizeof(struct js_event))) | 271 | if (copy_to_user(buf + retval, client->buffer + client->tail, sizeof(struct js_event))) |
267 | return -EFAULT; | 272 | return -EFAULT; |
268 | 273 | ||
269 | list->tail = (list->tail + 1) & (JOYDEV_BUFFER_SIZE - 1); | 274 | client->tail = (client->tail + 1) & (JOYDEV_BUFFER_SIZE - 1); |
270 | retval += sizeof(struct js_event); | 275 | retval += sizeof(struct js_event); |
271 | } | 276 | } |
272 | 277 | ||
@@ -276,11 +281,12 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo | |||
276 | /* No kernel lock - fine */ | 281 | /* No kernel lock - fine */ |
277 | static unsigned int joydev_poll(struct file *file, poll_table *wait) | 282 | static unsigned int joydev_poll(struct file *file, poll_table *wait) |
278 | { | 283 | { |
279 | struct joydev_list *list = file->private_data; | 284 | struct joydev_client *client = file->private_data; |
285 | struct joydev *joydev = client->joydev; | ||
280 | 286 | ||
281 | poll_wait(file, &list->joydev->wait, wait); | 287 | poll_wait(file, &joydev->wait, wait); |
282 | return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ? | 288 | return ((client->head != client->tail || client->startup < joydev->nabs + joydev->nkey) ? |
283 | (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); | 289 | (POLLIN | POLLRDNORM) : 0) | (joydev->exist ? 0 : (POLLHUP | POLLERR)); |
284 | } | 290 | } |
285 | 291 | ||
286 | static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp) | 292 | static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp) |
@@ -374,8 +380,8 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u | |||
374 | #ifdef CONFIG_COMPAT | 380 | #ifdef CONFIG_COMPAT |
375 | static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 381 | static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
376 | { | 382 | { |
377 | struct joydev_list *list = file->private_data; | 383 | struct joydev_client *client = file->private_data; |
378 | struct joydev *joydev = list->joydev; | 384 | struct joydev *joydev = client->joydev; |
379 | void __user *argp = (void __user *)arg; | 385 | void __user *argp = (void __user *)arg; |
380 | s32 tmp32; | 386 | s32 tmp32; |
381 | struct JS_DATA_SAVE_TYPE_32 ds32; | 387 | struct JS_DATA_SAVE_TYPE_32 ds32; |
@@ -428,8 +434,8 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo | |||
428 | 434 | ||
429 | static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 435 | static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
430 | { | 436 | { |
431 | struct joydev_list *list = file->private_data; | 437 | struct joydev_client *client = file->private_data; |
432 | struct joydev *joydev = list->joydev; | 438 | struct joydev *joydev = client->joydev; |
433 | void __user *argp = (void __user *)arg; | 439 | void __user *argp = (void __user *)arg; |
434 | 440 | ||
435 | if (!joydev->exist) | 441 | if (!joydev->exist) |
@@ -484,7 +490,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
484 | if (!joydev) | 490 | if (!joydev) |
485 | return -ENOMEM; | 491 | return -ENOMEM; |
486 | 492 | ||
487 | INIT_LIST_HEAD(&joydev->list); | 493 | INIT_LIST_HEAD(&joydev->client_list); |
488 | init_waitqueue_head(&joydev->wait); | 494 | init_waitqueue_head(&joydev->wait); |
489 | 495 | ||
490 | joydev->minor = minor; | 496 | joydev->minor = minor; |
@@ -572,7 +578,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
572 | static void joydev_disconnect(struct input_handle *handle) | 578 | static void joydev_disconnect(struct input_handle *handle) |
573 | { | 579 | { |
574 | struct joydev *joydev = handle->private; | 580 | struct joydev *joydev = handle->private; |
575 | struct joydev_list *list; | 581 | struct joydev_client *client; |
576 | 582 | ||
577 | input_unregister_handle(handle); | 583 | input_unregister_handle(handle); |
578 | 584 | ||
@@ -583,8 +589,8 @@ static void joydev_disconnect(struct input_handle *handle) | |||
583 | if (joydev->open) { | 589 | if (joydev->open) { |
584 | input_close_device(handle); | 590 | input_close_device(handle); |
585 | wake_up_interruptible(&joydev->wait); | 591 | wake_up_interruptible(&joydev->wait); |
586 | list_for_each_entry(list, &joydev->list, node) | 592 | list_for_each_entry(client, &joydev->client_list, node) |
587 | kill_fasync(&list->fasync, SIGIO, POLL_HUP); | 593 | kill_fasync(&client->fasync, SIGIO, POLL_HUP); |
588 | } else | 594 | } else |
589 | joydev_free(joydev); | 595 | joydev_free(joydev); |
590 | } | 596 | } |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 007e72f80251..f6a62687d9e4 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -63,7 +63,7 @@ struct mousedev { | |||
63 | int minor; | 63 | int minor; |
64 | char name[16]; | 64 | char name[16]; |
65 | wait_queue_head_t wait; | 65 | wait_queue_head_t wait; |
66 | struct list_head list; | 66 | struct list_head client_list; |
67 | struct input_handle handle; | 67 | struct input_handle handle; |
68 | 68 | ||
69 | struct mousedev_hw_data packet; | 69 | struct mousedev_hw_data packet; |
@@ -85,7 +85,7 @@ struct mousedev_motion { | |||
85 | }; | 85 | }; |
86 | 86 | ||
87 | #define PACKET_QUEUE_LEN 16 | 87 | #define PACKET_QUEUE_LEN 16 |
88 | struct mousedev_list { | 88 | struct mousedev_client { |
89 | struct fasync_struct *fasync; | 89 | struct fasync_struct *fasync; |
90 | struct mousedev *mousedev; | 90 | struct mousedev *mousedev; |
91 | struct list_head node; | 91 | struct list_head node; |
@@ -223,47 +223,47 @@ static void mousedev_key_event(struct mousedev *mousedev, unsigned int code, int | |||
223 | 223 | ||
224 | static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_hw_data *packet) | 224 | static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_hw_data *packet) |
225 | { | 225 | { |
226 | struct mousedev_list *list; | 226 | struct mousedev_client *client; |
227 | struct mousedev_motion *p; | 227 | struct mousedev_motion *p; |
228 | unsigned long flags; | 228 | unsigned long flags; |
229 | int wake_readers = 0; | 229 | int wake_readers = 0; |
230 | 230 | ||
231 | list_for_each_entry(list, &mousedev->list, node) { | 231 | list_for_each_entry(client, &mousedev->client_list, node) { |
232 | spin_lock_irqsave(&list->packet_lock, flags); | 232 | spin_lock_irqsave(&client->packet_lock, flags); |
233 | 233 | ||
234 | p = &list->packets[list->head]; | 234 | p = &client->packets[client->head]; |
235 | if (list->ready && p->buttons != mousedev->packet.buttons) { | 235 | if (client->ready && p->buttons != mousedev->packet.buttons) { |
236 | unsigned int new_head = (list->head + 1) % PACKET_QUEUE_LEN; | 236 | unsigned int new_head = (client->head + 1) % PACKET_QUEUE_LEN; |
237 | if (new_head != list->tail) { | 237 | if (new_head != client->tail) { |
238 | p = &list->packets[list->head = new_head]; | 238 | p = &client->packets[client->head = new_head]; |
239 | memset(p, 0, sizeof(struct mousedev_motion)); | 239 | memset(p, 0, sizeof(struct mousedev_motion)); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | if (packet->abs_event) { | 243 | if (packet->abs_event) { |
244 | p->dx += packet->x - list->pos_x; | 244 | p->dx += packet->x - client->pos_x; |
245 | p->dy += packet->y - list->pos_y; | 245 | p->dy += packet->y - client->pos_y; |
246 | list->pos_x = packet->x; | 246 | client->pos_x = packet->x; |
247 | list->pos_y = packet->y; | 247 | client->pos_y = packet->y; |
248 | } | 248 | } |
249 | 249 | ||
250 | list->pos_x += packet->dx; | 250 | client->pos_x += packet->dx; |
251 | list->pos_x = list->pos_x < 0 ? 0 : (list->pos_x >= xres ? xres : list->pos_x); | 251 | client->pos_x = client->pos_x < 0 ? 0 : (client->pos_x >= xres ? xres : client->pos_x); |
252 | list->pos_y += packet->dy; | 252 | client->pos_y += packet->dy; |
253 | list->pos_y = list->pos_y < 0 ? 0 : (list->pos_y >= yres ? yres : list->pos_y); | 253 | client->pos_y = client->pos_y < 0 ? 0 : (client->pos_y >= yres ? yres : client->pos_y); |
254 | 254 | ||
255 | p->dx += packet->dx; | 255 | p->dx += packet->dx; |
256 | p->dy += packet->dy; | 256 | p->dy += packet->dy; |
257 | p->dz += packet->dz; | 257 | p->dz += packet->dz; |
258 | p->buttons = mousedev->packet.buttons; | 258 | p->buttons = mousedev->packet.buttons; |
259 | 259 | ||
260 | if (p->dx || p->dy || p->dz || p->buttons != list->last_buttons) | 260 | if (p->dx || p->dy || p->dz || p->buttons != client->last_buttons) |
261 | list->ready = 1; | 261 | client->ready = 1; |
262 | 262 | ||
263 | spin_unlock_irqrestore(&list->packet_lock, flags); | 263 | spin_unlock_irqrestore(&client->packet_lock, flags); |
264 | 264 | ||
265 | if (list->ready) { | 265 | if (client->ready) { |
266 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 266 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
267 | wake_readers = 1; | 267 | wake_readers = 1; |
268 | } | 268 | } |
269 | } | 269 | } |
@@ -351,9 +351,9 @@ static void mousedev_event(struct input_handle *handle, unsigned int type, unsig | |||
351 | static int mousedev_fasync(int fd, struct file *file, int on) | 351 | static int mousedev_fasync(int fd, struct file *file, int on) |
352 | { | 352 | { |
353 | int retval; | 353 | int retval; |
354 | struct mousedev_list *list = file->private_data; | 354 | struct mousedev_client *client = file->private_data; |
355 | 355 | ||
356 | retval = fasync_helper(fd, file, on, &list->fasync); | 356 | retval = fasync_helper(fd, file, on, &client->fasync); |
357 | 357 | ||
358 | return retval < 0 ? retval : 0; | 358 | return retval < 0 ? retval : 0; |
359 | } | 359 | } |
@@ -380,32 +380,33 @@ static void mixdev_release(void) | |||
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | static int mousedev_release(struct inode * inode, struct file * file) | 383 | static int mousedev_release(struct inode *inode, struct file *file) |
384 | { | 384 | { |
385 | struct mousedev_list *list = file->private_data; | 385 | struct mousedev_client *client = file->private_data; |
386 | struct mousedev *mousedev = client->mousedev; | ||
386 | 387 | ||
387 | mousedev_fasync(-1, file, 0); | 388 | mousedev_fasync(-1, file, 0); |
388 | 389 | ||
389 | list_del(&list->node); | 390 | list_del(&client->node); |
391 | kfree(client); | ||
390 | 392 | ||
391 | if (!--list->mousedev->open) { | 393 | if (!--mousedev->open) { |
392 | if (list->mousedev->minor == MOUSEDEV_MIX) | 394 | if (mousedev->minor == MOUSEDEV_MIX) |
393 | mixdev_release(); | 395 | mixdev_release(); |
394 | else if (!mousedev_mix.open) { | 396 | else if (!mousedev_mix.open) { |
395 | if (list->mousedev->exist) | 397 | if (mousedev->exist) |
396 | input_close_device(&list->mousedev->handle); | 398 | input_close_device(&mousedev->handle); |
397 | else | 399 | else |
398 | mousedev_free(list->mousedev); | 400 | mousedev_free(mousedev); |
399 | } | 401 | } |
400 | } | 402 | } |
401 | 403 | ||
402 | kfree(list); | ||
403 | return 0; | 404 | return 0; |
404 | } | 405 | } |
405 | 406 | ||
406 | static int mousedev_open(struct inode * inode, struct file * file) | 407 | static int mousedev_open(struct inode *inode, struct file *file) |
407 | { | 408 | { |
408 | struct mousedev_list *list; | 409 | struct mousedev_client *client; |
409 | struct input_handle *handle; | 410 | struct input_handle *handle; |
410 | struct mousedev *mousedev; | 411 | struct mousedev *mousedev; |
411 | int i; | 412 | int i; |
@@ -417,31 +418,36 @@ static int mousedev_open(struct inode * inode, struct file * file) | |||
417 | #endif | 418 | #endif |
418 | i = iminor(inode) - MOUSEDEV_MINOR_BASE; | 419 | i = iminor(inode) - MOUSEDEV_MINOR_BASE; |
419 | 420 | ||
420 | if (i >= MOUSEDEV_MINORS || !mousedev_table[i]) | 421 | if (i >= MOUSEDEV_MINORS) |
422 | return -ENODEV; | ||
423 | |||
424 | mousedev = mousedev_table[i]; | ||
425 | if (!mousedev) | ||
421 | return -ENODEV; | 426 | return -ENODEV; |
422 | 427 | ||
423 | if (!(list = kzalloc(sizeof(struct mousedev_list), GFP_KERNEL))) | 428 | client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL); |
429 | if (!client) | ||
424 | return -ENOMEM; | 430 | return -ENOMEM; |
425 | 431 | ||
426 | spin_lock_init(&list->packet_lock); | 432 | spin_lock_init(&client->packet_lock); |
427 | list->pos_x = xres / 2; | 433 | client->pos_x = xres / 2; |
428 | list->pos_y = yres / 2; | 434 | client->pos_y = yres / 2; |
429 | list->mousedev = mousedev_table[i]; | 435 | client->mousedev = mousedev; |
430 | list_add_tail(&list->node, &mousedev_table[i]->list); | 436 | list_add_tail(&client->node, &mousedev->client_list); |
431 | file->private_data = list; | ||
432 | 437 | ||
433 | if (!list->mousedev->open++) { | 438 | if (!mousedev->open++) { |
434 | if (list->mousedev->minor == MOUSEDEV_MIX) { | 439 | if (mousedev->minor == MOUSEDEV_MIX) { |
435 | list_for_each_entry(handle, &mousedev_handler.h_list, h_node) { | 440 | list_for_each_entry(handle, &mousedev_handler.h_list, h_node) { |
436 | mousedev = handle->private; | 441 | struct mousedev *md = handle->private; |
437 | if (!mousedev->open && mousedev->exist) | 442 | if (!md->open && md->exist) |
438 | input_open_device(handle); | 443 | input_open_device(handle); |
439 | } | 444 | } |
440 | } else | 445 | } else |
441 | if (!mousedev_mix.open && list->mousedev->exist) | 446 | if (!mousedev_mix.open && mousedev->exist) |
442 | input_open_device(&list->mousedev->handle); | 447 | input_open_device(&mousedev->handle); |
443 | } | 448 | } |
444 | 449 | ||
450 | file->private_data = client; | ||
445 | return 0; | 451 | return 0; |
446 | } | 452 | } |
447 | 453 | ||
@@ -450,13 +456,13 @@ static inline int mousedev_limit_delta(int delta, int limit) | |||
450 | return delta > limit ? limit : (delta < -limit ? -limit : delta); | 456 | return delta > limit ? limit : (delta < -limit ? -limit : delta); |
451 | } | 457 | } |
452 | 458 | ||
453 | static void mousedev_packet(struct mousedev_list *list, signed char *ps2_data) | 459 | static void mousedev_packet(struct mousedev_client *client, signed char *ps2_data) |
454 | { | 460 | { |
455 | struct mousedev_motion *p; | 461 | struct mousedev_motion *p; |
456 | unsigned long flags; | 462 | unsigned long flags; |
457 | 463 | ||
458 | spin_lock_irqsave(&list->packet_lock, flags); | 464 | spin_lock_irqsave(&client->packet_lock, flags); |
459 | p = &list->packets[list->tail]; | 465 | p = &client->packets[client->tail]; |
460 | 466 | ||
461 | ps2_data[0] = 0x08 | ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07); | 467 | ps2_data[0] = 0x08 | ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07); |
462 | ps2_data[1] = mousedev_limit_delta(p->dx, 127); | 468 | ps2_data[1] = mousedev_limit_delta(p->dx, 127); |
@@ -464,44 +470,44 @@ static void mousedev_packet(struct mousedev_list *list, signed char *ps2_data) | |||
464 | p->dx -= ps2_data[1]; | 470 | p->dx -= ps2_data[1]; |
465 | p->dy -= ps2_data[2]; | 471 | p->dy -= ps2_data[2]; |
466 | 472 | ||
467 | switch (list->mode) { | 473 | switch (client->mode) { |
468 | case MOUSEDEV_EMUL_EXPS: | 474 | case MOUSEDEV_EMUL_EXPS: |
469 | ps2_data[3] = mousedev_limit_delta(p->dz, 7); | 475 | ps2_data[3] = mousedev_limit_delta(p->dz, 7); |
470 | p->dz -= ps2_data[3]; | 476 | p->dz -= ps2_data[3]; |
471 | ps2_data[3] = (ps2_data[3] & 0x0f) | ((p->buttons & 0x18) << 1); | 477 | ps2_data[3] = (ps2_data[3] & 0x0f) | ((p->buttons & 0x18) << 1); |
472 | list->bufsiz = 4; | 478 | client->bufsiz = 4; |
473 | break; | 479 | break; |
474 | 480 | ||
475 | case MOUSEDEV_EMUL_IMPS: | 481 | case MOUSEDEV_EMUL_IMPS: |
476 | ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); | 482 | ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); |
477 | ps2_data[3] = mousedev_limit_delta(p->dz, 127); | 483 | ps2_data[3] = mousedev_limit_delta(p->dz, 127); |
478 | p->dz -= ps2_data[3]; | 484 | p->dz -= ps2_data[3]; |
479 | list->bufsiz = 4; | 485 | client->bufsiz = 4; |
480 | break; | 486 | break; |
481 | 487 | ||
482 | case MOUSEDEV_EMUL_PS2: | 488 | case MOUSEDEV_EMUL_PS2: |
483 | default: | 489 | default: |
484 | ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); | 490 | ps2_data[0] |= ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); |
485 | p->dz = 0; | 491 | p->dz = 0; |
486 | list->bufsiz = 3; | 492 | client->bufsiz = 3; |
487 | break; | 493 | break; |
488 | } | 494 | } |
489 | 495 | ||
490 | if (!p->dx && !p->dy && !p->dz) { | 496 | if (!p->dx && !p->dy && !p->dz) { |
491 | if (list->tail == list->head) { | 497 | if (client->tail == client->head) { |
492 | list->ready = 0; | 498 | client->ready = 0; |
493 | list->last_buttons = p->buttons; | 499 | client->last_buttons = p->buttons; |
494 | } else | 500 | } else |
495 | list->tail = (list->tail + 1) % PACKET_QUEUE_LEN; | 501 | client->tail = (client->tail + 1) % PACKET_QUEUE_LEN; |
496 | } | 502 | } |
497 | 503 | ||
498 | spin_unlock_irqrestore(&list->packet_lock, flags); | 504 | spin_unlock_irqrestore(&client->packet_lock, flags); |
499 | } | 505 | } |
500 | 506 | ||
501 | 507 | ||
502 | static ssize_t mousedev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) | 508 | static ssize_t mousedev_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
503 | { | 509 | { |
504 | struct mousedev_list *list = file->private_data; | 510 | struct mousedev_client *client = file->private_data; |
505 | unsigned char c; | 511 | unsigned char c; |
506 | unsigned int i; | 512 | unsigned int i; |
507 | 513 | ||
@@ -510,95 +516,95 @@ static ssize_t mousedev_write(struct file * file, const char __user * buffer, si | |||
510 | if (get_user(c, buffer + i)) | 516 | if (get_user(c, buffer + i)) |
511 | return -EFAULT; | 517 | return -EFAULT; |
512 | 518 | ||
513 | if (c == mousedev_imex_seq[list->imexseq]) { | 519 | if (c == mousedev_imex_seq[client->imexseq]) { |
514 | if (++list->imexseq == MOUSEDEV_SEQ_LEN) { | 520 | if (++client->imexseq == MOUSEDEV_SEQ_LEN) { |
515 | list->imexseq = 0; | 521 | client->imexseq = 0; |
516 | list->mode = MOUSEDEV_EMUL_EXPS; | 522 | client->mode = MOUSEDEV_EMUL_EXPS; |
517 | } | 523 | } |
518 | } else | 524 | } else |
519 | list->imexseq = 0; | 525 | client->imexseq = 0; |
520 | 526 | ||
521 | if (c == mousedev_imps_seq[list->impsseq]) { | 527 | if (c == mousedev_imps_seq[client->impsseq]) { |
522 | if (++list->impsseq == MOUSEDEV_SEQ_LEN) { | 528 | if (++client->impsseq == MOUSEDEV_SEQ_LEN) { |
523 | list->impsseq = 0; | 529 | client->impsseq = 0; |
524 | list->mode = MOUSEDEV_EMUL_IMPS; | 530 | client->mode = MOUSEDEV_EMUL_IMPS; |
525 | } | 531 | } |
526 | } else | 532 | } else |
527 | list->impsseq = 0; | 533 | client->impsseq = 0; |
528 | 534 | ||
529 | list->ps2[0] = 0xfa; | 535 | client->ps2[0] = 0xfa; |
530 | 536 | ||
531 | switch (c) { | 537 | switch (c) { |
532 | 538 | ||
533 | case 0xeb: /* Poll */ | 539 | case 0xeb: /* Poll */ |
534 | mousedev_packet(list, &list->ps2[1]); | 540 | mousedev_packet(client, &client->ps2[1]); |
535 | list->bufsiz++; /* account for leading ACK */ | 541 | client->bufsiz++; /* account for leading ACK */ |
536 | break; | 542 | break; |
537 | 543 | ||
538 | case 0xf2: /* Get ID */ | 544 | case 0xf2: /* Get ID */ |
539 | switch (list->mode) { | 545 | switch (client->mode) { |
540 | case MOUSEDEV_EMUL_PS2: list->ps2[1] = 0; break; | 546 | case MOUSEDEV_EMUL_PS2: client->ps2[1] = 0; break; |
541 | case MOUSEDEV_EMUL_IMPS: list->ps2[1] = 3; break; | 547 | case MOUSEDEV_EMUL_IMPS: client->ps2[1] = 3; break; |
542 | case MOUSEDEV_EMUL_EXPS: list->ps2[1] = 4; break; | 548 | case MOUSEDEV_EMUL_EXPS: client->ps2[1] = 4; break; |
543 | } | 549 | } |
544 | list->bufsiz = 2; | 550 | client->bufsiz = 2; |
545 | break; | 551 | break; |
546 | 552 | ||
547 | case 0xe9: /* Get info */ | 553 | case 0xe9: /* Get info */ |
548 | list->ps2[1] = 0x60; list->ps2[2] = 3; list->ps2[3] = 200; | 554 | client->ps2[1] = 0x60; client->ps2[2] = 3; client->ps2[3] = 200; |
549 | list->bufsiz = 4; | 555 | client->bufsiz = 4; |
550 | break; | 556 | break; |
551 | 557 | ||
552 | case 0xff: /* Reset */ | 558 | case 0xff: /* Reset */ |
553 | list->impsseq = list->imexseq = 0; | 559 | client->impsseq = client->imexseq = 0; |
554 | list->mode = MOUSEDEV_EMUL_PS2; | 560 | client->mode = MOUSEDEV_EMUL_PS2; |
555 | list->ps2[1] = 0xaa; list->ps2[2] = 0x00; | 561 | client->ps2[1] = 0xaa; client->ps2[2] = 0x00; |
556 | list->bufsiz = 3; | 562 | client->bufsiz = 3; |
557 | break; | 563 | break; |
558 | 564 | ||
559 | default: | 565 | default: |
560 | list->bufsiz = 1; | 566 | client->bufsiz = 1; |
561 | break; | 567 | break; |
562 | } | 568 | } |
563 | 569 | ||
564 | list->buffer = list->bufsiz; | 570 | client->buffer = client->bufsiz; |
565 | } | 571 | } |
566 | 572 | ||
567 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 573 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
568 | 574 | ||
569 | wake_up_interruptible(&list->mousedev->wait); | 575 | wake_up_interruptible(&client->mousedev->wait); |
570 | 576 | ||
571 | return count; | 577 | return count; |
572 | } | 578 | } |
573 | 579 | ||
574 | static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) | 580 | static ssize_t mousedev_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
575 | { | 581 | { |
576 | struct mousedev_list *list = file->private_data; | 582 | struct mousedev_client *client = file->private_data; |
577 | int retval = 0; | 583 | int retval = 0; |
578 | 584 | ||
579 | if (!list->ready && !list->buffer && (file->f_flags & O_NONBLOCK)) | 585 | if (!client->ready && !client->buffer && (file->f_flags & O_NONBLOCK)) |
580 | return -EAGAIN; | 586 | return -EAGAIN; |
581 | 587 | ||
582 | retval = wait_event_interruptible(list->mousedev->wait, | 588 | retval = wait_event_interruptible(client->mousedev->wait, |
583 | !list->mousedev->exist || list->ready || list->buffer); | 589 | !client->mousedev->exist || client->ready || client->buffer); |
584 | 590 | ||
585 | if (retval) | 591 | if (retval) |
586 | return retval; | 592 | return retval; |
587 | 593 | ||
588 | if (!list->mousedev->exist) | 594 | if (!client->mousedev->exist) |
589 | return -ENODEV; | 595 | return -ENODEV; |
590 | 596 | ||
591 | if (!list->buffer && list->ready) { | 597 | if (!client->buffer && client->ready) { |
592 | mousedev_packet(list, list->ps2); | 598 | mousedev_packet(client, client->ps2); |
593 | list->buffer = list->bufsiz; | 599 | client->buffer = client->bufsiz; |
594 | } | 600 | } |
595 | 601 | ||
596 | if (count > list->buffer) | 602 | if (count > client->buffer) |
597 | count = list->buffer; | 603 | count = client->buffer; |
598 | 604 | ||
599 | list->buffer -= count; | 605 | client->buffer -= count; |
600 | 606 | ||
601 | if (copy_to_user(buffer, list->ps2 + list->bufsiz - list->buffer - count, count)) | 607 | if (copy_to_user(buffer, client->ps2 + client->bufsiz - client->buffer - count, count)) |
602 | return -EFAULT; | 608 | return -EFAULT; |
603 | 609 | ||
604 | return count; | 610 | return count; |
@@ -607,11 +613,12 @@ static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t co | |||
607 | /* No kernel lock - fine */ | 613 | /* No kernel lock - fine */ |
608 | static unsigned int mousedev_poll(struct file *file, poll_table *wait) | 614 | static unsigned int mousedev_poll(struct file *file, poll_table *wait) |
609 | { | 615 | { |
610 | struct mousedev_list *list = file->private_data; | 616 | struct mousedev_client *client = file->private_data; |
617 | struct mousedev *mousedev = client->mousedev; | ||
611 | 618 | ||
612 | poll_wait(file, &list->mousedev->wait, wait); | 619 | poll_wait(file, &mousedev->wait, wait); |
613 | return ((list->ready || list->buffer) ? (POLLIN | POLLRDNORM) : 0) | | 620 | return ((client->ready || client->buffer) ? (POLLIN | POLLRDNORM) : 0) | |
614 | (list->mousedev->exist ? 0 : (POLLHUP | POLLERR)); | 621 | (mousedev->exist ? 0 : (POLLHUP | POLLERR)); |
615 | } | 622 | } |
616 | 623 | ||
617 | static const struct file_operations mousedev_fops = { | 624 | static const struct file_operations mousedev_fops = { |
@@ -643,7 +650,7 @@ static int mousedev_connect(struct input_handler *handler, struct input_dev *dev | |||
643 | if (!mousedev) | 650 | if (!mousedev) |
644 | return -ENOMEM; | 651 | return -ENOMEM; |
645 | 652 | ||
646 | INIT_LIST_HEAD(&mousedev->list); | 653 | INIT_LIST_HEAD(&mousedev->client_list); |
647 | INIT_LIST_HEAD(&mousedev->mixdev_node); | 654 | INIT_LIST_HEAD(&mousedev->mixdev_node); |
648 | init_waitqueue_head(&mousedev->wait); | 655 | init_waitqueue_head(&mousedev->wait); |
649 | 656 | ||
@@ -699,7 +706,7 @@ static int mousedev_connect(struct input_handler *handler, struct input_dev *dev | |||
699 | static void mousedev_disconnect(struct input_handle *handle) | 706 | static void mousedev_disconnect(struct input_handle *handle) |
700 | { | 707 | { |
701 | struct mousedev *mousedev = handle->private; | 708 | struct mousedev *mousedev = handle->private; |
702 | struct mousedev_list *list; | 709 | struct mousedev_client *client; |
703 | 710 | ||
704 | input_unregister_handle(handle); | 711 | input_unregister_handle(handle); |
705 | 712 | ||
@@ -711,8 +718,8 @@ static void mousedev_disconnect(struct input_handle *handle) | |||
711 | if (mousedev->open) { | 718 | if (mousedev->open) { |
712 | input_close_device(handle); | 719 | input_close_device(handle); |
713 | wake_up_interruptible(&mousedev->wait); | 720 | wake_up_interruptible(&mousedev->wait); |
714 | list_for_each_entry(list, &mousedev->list, node) | 721 | list_for_each_entry(client, &mousedev->client_list, node) |
715 | kill_fasync(&list->fasync, SIGIO, POLL_HUP); | 722 | kill_fasync(&client->fasync, SIGIO, POLL_HUP); |
716 | } else { | 723 | } else { |
717 | if (mousedev_mix.open) | 724 | if (mousedev_mix.open) |
718 | input_close_device(handle); | 725 | input_close_device(handle); |
@@ -745,7 +752,7 @@ static const struct input_device_id mousedev_ids[] = { | |||
745 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_TOOL_WIDTH) }, | 752 | .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_TOOL_WIDTH) }, |
746 | }, /* A touchpad */ | 753 | }, /* A touchpad */ |
747 | 754 | ||
748 | { }, /* Terminating entry */ | 755 | { }, /* Terminating entry */ |
749 | }; | 756 | }; |
750 | 757 | ||
751 | MODULE_DEVICE_TABLE(input, mousedev_ids); | 758 | MODULE_DEVICE_TABLE(input, mousedev_ids); |
@@ -777,7 +784,7 @@ static int __init mousedev_init(void) | |||
777 | return error; | 784 | return error; |
778 | 785 | ||
779 | memset(&mousedev_mix, 0, sizeof(struct mousedev)); | 786 | memset(&mousedev_mix, 0, sizeof(struct mousedev)); |
780 | INIT_LIST_HEAD(&mousedev_mix.list); | 787 | INIT_LIST_HEAD(&mousedev_mix.client_list); |
781 | init_waitqueue_head(&mousedev_mix.wait); | 788 | init_waitqueue_head(&mousedev_mix.wait); |
782 | mousedev_table[MOUSEDEV_MIX] = &mousedev_mix; | 789 | mousedev_table[MOUSEDEV_MIX] = &mousedev_mix; |
783 | mousedev_mix.exist = 1; | 790 | mousedev_mix.exist = 1; |
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c index a23aedc64ab1..fbef35d2d76c 100644 --- a/drivers/input/tsdev.c +++ b/drivers/input/tsdev.c | |||
@@ -111,13 +111,13 @@ struct tsdev { | |||
111 | int minor; | 111 | int minor; |
112 | char name[8]; | 112 | char name[8]; |
113 | wait_queue_head_t wait; | 113 | wait_queue_head_t wait; |
114 | struct list_head list; | 114 | struct list_head client_list; |
115 | struct input_handle handle; | 115 | struct input_handle handle; |
116 | int x, y, pressure; | 116 | int x, y, pressure; |
117 | struct ts_calibration cal; | 117 | struct ts_calibration cal; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | struct tsdev_list { | 120 | struct tsdev_client { |
121 | struct fasync_struct *fasync; | 121 | struct fasync_struct *fasync; |
122 | struct list_head node; | 122 | struct list_head node; |
123 | struct tsdev *tsdev; | 123 | struct tsdev *tsdev; |
@@ -139,17 +139,18 @@ static struct tsdev *tsdev_table[TSDEV_MINORS/2]; | |||
139 | 139 | ||
140 | static int tsdev_fasync(int fd, struct file *file, int on) | 140 | static int tsdev_fasync(int fd, struct file *file, int on) |
141 | { | 141 | { |
142 | struct tsdev_list *list = file->private_data; | 142 | struct tsdev_client *client = file->private_data; |
143 | int retval; | 143 | int retval; |
144 | 144 | ||
145 | retval = fasync_helper(fd, file, on, &list->fasync); | 145 | retval = fasync_helper(fd, file, on, &client->fasync); |
146 | return retval < 0 ? retval : 0; | 146 | return retval < 0 ? retval : 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | static int tsdev_open(struct inode *inode, struct file *file) | 149 | static int tsdev_open(struct inode *inode, struct file *file) |
150 | { | 150 | { |
151 | int i = iminor(inode) - TSDEV_MINOR_BASE; | 151 | int i = iminor(inode) - TSDEV_MINOR_BASE; |
152 | struct tsdev_list *list; | 152 | struct tsdev_client *client; |
153 | struct tsdev *tsdev; | ||
153 | 154 | ||
154 | printk(KERN_WARNING "tsdev (compaq touchscreen emulation) is scheduled " | 155 | printk(KERN_WARNING "tsdev (compaq touchscreen emulation) is scheduled " |
155 | "for removal.\nSee Documentation/feature-removal-schedule.txt " | 156 | "for removal.\nSee Documentation/feature-removal-schedule.txt " |
@@ -158,19 +159,22 @@ static int tsdev_open(struct inode *inode, struct file *file) | |||
158 | if (i >= TSDEV_MINORS) | 159 | if (i >= TSDEV_MINORS) |
159 | return -ENODEV; | 160 | return -ENODEV; |
160 | 161 | ||
161 | if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL))) | 162 | tsdev = tsdev_table[i & TSDEV_MINOR_MASK]; |
163 | if (!tsdev || !tsdev->exist) | ||
164 | return -ENODEV; | ||
165 | |||
166 | client = kzalloc(sizeof(struct tsdev_client), GFP_KERNEL); | ||
167 | if (!client) | ||
162 | return -ENOMEM; | 168 | return -ENOMEM; |
163 | 169 | ||
164 | list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0; | 170 | client->tsdev = tsdev; |
171 | client->raw = (i >= TSDEV_MINORS / 2) ? 1 : 0; | ||
172 | list_add_tail(&client->node, &tsdev->client_list); | ||
165 | 173 | ||
166 | i &= TSDEV_MINOR_MASK; | 174 | if (!tsdev->open++ && tsdev->exist) |
167 | list->tsdev = tsdev_table[i]; | 175 | input_open_device(&tsdev->handle); |
168 | list_add_tail(&list->node, &tsdev_table[i]->list); | ||
169 | file->private_data = list; | ||
170 | 176 | ||
171 | if (!list->tsdev->open++) | 177 | file->private_data = client; |
172 | if (list->tsdev->exist) | ||
173 | input_open_device(&list->tsdev->handle); | ||
174 | return 0; | 178 | return 0; |
175 | } | 179 | } |
176 | 180 | ||
@@ -182,45 +186,48 @@ static void tsdev_free(struct tsdev *tsdev) | |||
182 | 186 | ||
183 | static int tsdev_release(struct inode *inode, struct file *file) | 187 | static int tsdev_release(struct inode *inode, struct file *file) |
184 | { | 188 | { |
185 | struct tsdev_list *list = file->private_data; | 189 | struct tsdev_client *client = file->private_data; |
190 | struct tsdev *tsdev = client->tsdev; | ||
186 | 191 | ||
187 | tsdev_fasync(-1, file, 0); | 192 | tsdev_fasync(-1, file, 0); |
188 | list_del(&list->node); | ||
189 | 193 | ||
190 | if (!--list->tsdev->open) { | 194 | list_del(&client->node); |
191 | if (list->tsdev->exist) | 195 | kfree(client); |
192 | input_close_device(&list->tsdev->handle); | 196 | |
197 | if (!--tsdev->open) { | ||
198 | if (tsdev->exist) | ||
199 | input_close_device(&tsdev->handle); | ||
193 | else | 200 | else |
194 | tsdev_free(list->tsdev); | 201 | tsdev_free(tsdev); |
195 | } | 202 | } |
196 | kfree(list); | 203 | |
197 | return 0; | 204 | return 0; |
198 | } | 205 | } |
199 | 206 | ||
200 | static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, | 207 | static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, |
201 | loff_t * ppos) | 208 | loff_t *ppos) |
202 | { | 209 | { |
203 | struct tsdev_list *list = file->private_data; | 210 | struct tsdev_client *client = file->private_data; |
211 | struct tsdev *tsdev = client->tsdev; | ||
204 | int retval = 0; | 212 | int retval = 0; |
205 | 213 | ||
206 | if (list->head == list->tail && list->tsdev->exist && (file->f_flags & O_NONBLOCK)) | 214 | if (client->head == client->tail && tsdev->exist && (file->f_flags & O_NONBLOCK)) |
207 | return -EAGAIN; | 215 | return -EAGAIN; |
208 | 216 | ||
209 | retval = wait_event_interruptible(list->tsdev->wait, | 217 | retval = wait_event_interruptible(tsdev->wait, |
210 | list->head != list->tail || !list->tsdev->exist); | 218 | client->head != client->tail || !tsdev->exist); |
211 | |||
212 | if (retval) | 219 | if (retval) |
213 | return retval; | 220 | return retval; |
214 | 221 | ||
215 | if (!list->tsdev->exist) | 222 | if (!tsdev->exist) |
216 | return -ENODEV; | 223 | return -ENODEV; |
217 | 224 | ||
218 | while (list->head != list->tail && | 225 | while (client->head != client->tail && |
219 | retval + sizeof (struct ts_event) <= count) { | 226 | retval + sizeof (struct ts_event) <= count) { |
220 | if (copy_to_user (buffer + retval, list->event + list->tail, | 227 | if (copy_to_user (buffer + retval, client->event + client->tail, |
221 | sizeof (struct ts_event))) | 228 | sizeof (struct ts_event))) |
222 | return -EFAULT; | 229 | return -EFAULT; |
223 | list->tail = (list->tail + 1) & (TSDEV_BUFFER_SIZE - 1); | 230 | client->tail = (client->tail + 1) & (TSDEV_BUFFER_SIZE - 1); |
224 | retval += sizeof (struct ts_event); | 231 | retval += sizeof (struct ts_event); |
225 | } | 232 | } |
226 | 233 | ||
@@ -228,20 +235,21 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, | |||
228 | } | 235 | } |
229 | 236 | ||
230 | /* No kernel lock - fine */ | 237 | /* No kernel lock - fine */ |
231 | static unsigned int tsdev_poll(struct file *file, poll_table * wait) | 238 | static unsigned int tsdev_poll(struct file *file, poll_table *wait) |
232 | { | 239 | { |
233 | struct tsdev_list *list = file->private_data; | 240 | struct tsdev_client *client = file->private_data; |
241 | struct tsdev *tsdev = client->tsdev; | ||
234 | 242 | ||
235 | poll_wait(file, &list->tsdev->wait, wait); | 243 | poll_wait(file, &tsdev->wait, wait); |
236 | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | | 244 | return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) | |
237 | (list->tsdev->exist ? 0 : (POLLHUP | POLLERR)); | 245 | (tsdev->exist ? 0 : (POLLHUP | POLLERR)); |
238 | } | 246 | } |
239 | 247 | ||
240 | static int tsdev_ioctl(struct inode *inode, struct file *file, | 248 | static int tsdev_ioctl(struct inode *inode, struct file *file, |
241 | unsigned int cmd, unsigned long arg) | 249 | unsigned int cmd, unsigned long arg) |
242 | { | 250 | { |
243 | struct tsdev_list *list = file->private_data; | 251 | struct tsdev_client *client = file->private_data; |
244 | struct tsdev *tsdev = list->tsdev; | 252 | struct tsdev *tsdev = client->tsdev; |
245 | int retval = 0; | 253 | int retval = 0; |
246 | 254 | ||
247 | switch (cmd) { | 255 | switch (cmd) { |
@@ -279,7 +287,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, | |||
279 | unsigned int code, int value) | 287 | unsigned int code, int value) |
280 | { | 288 | { |
281 | struct tsdev *tsdev = handle->private; | 289 | struct tsdev *tsdev = handle->private; |
282 | struct tsdev_list *list; | 290 | struct tsdev_client *client; |
283 | struct timeval time; | 291 | struct timeval time; |
284 | 292 | ||
285 | switch (type) { | 293 | switch (type) { |
@@ -343,18 +351,18 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, | |||
343 | if (type != EV_SYN || code != SYN_REPORT) | 351 | if (type != EV_SYN || code != SYN_REPORT) |
344 | return; | 352 | return; |
345 | 353 | ||
346 | list_for_each_entry(list, &tsdev->list, node) { | 354 | list_for_each_entry(client, &tsdev->client_list, node) { |
347 | int x, y, tmp; | 355 | int x, y, tmp; |
348 | 356 | ||
349 | do_gettimeofday(&time); | 357 | do_gettimeofday(&time); |
350 | list->event[list->head].millisecs = time.tv_usec / 100; | 358 | client->event[client->head].millisecs = time.tv_usec / 100; |
351 | list->event[list->head].pressure = tsdev->pressure; | 359 | client->event[client->head].pressure = tsdev->pressure; |
352 | 360 | ||
353 | x = tsdev->x; | 361 | x = tsdev->x; |
354 | y = tsdev->y; | 362 | y = tsdev->y; |
355 | 363 | ||
356 | /* Calibration */ | 364 | /* Calibration */ |
357 | if (!list->raw) { | 365 | if (!client->raw) { |
358 | x = ((x * tsdev->cal.xscale) >> 8) + tsdev->cal.xtrans; | 366 | x = ((x * tsdev->cal.xscale) >> 8) + tsdev->cal.xtrans; |
359 | y = ((y * tsdev->cal.yscale) >> 8) + tsdev->cal.ytrans; | 367 | y = ((y * tsdev->cal.yscale) >> 8) + tsdev->cal.ytrans; |
360 | if (tsdev->cal.xyswap) { | 368 | if (tsdev->cal.xyswap) { |
@@ -362,10 +370,10 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, | |||
362 | } | 370 | } |
363 | } | 371 | } |
364 | 372 | ||
365 | list->event[list->head].x = x; | 373 | client->event[client->head].x = x; |
366 | list->event[list->head].y = y; | 374 | client->event[client->head].y = y; |
367 | list->head = (list->head + 1) & (TSDEV_BUFFER_SIZE - 1); | 375 | client->head = (client->head + 1) & (TSDEV_BUFFER_SIZE - 1); |
368 | kill_fasync(&list->fasync, SIGIO, POLL_IN); | 376 | kill_fasync(&client->fasync, SIGIO, POLL_IN); |
369 | } | 377 | } |
370 | wake_up_interruptible(&tsdev->wait); | 378 | wake_up_interruptible(&tsdev->wait); |
371 | } | 379 | } |
@@ -390,7 +398,7 @@ static int tsdev_connect(struct input_handler *handler, struct input_dev *dev, | |||
390 | if (!tsdev) | 398 | if (!tsdev) |
391 | return -ENOMEM; | 399 | return -ENOMEM; |
392 | 400 | ||
393 | INIT_LIST_HEAD(&tsdev->list); | 401 | INIT_LIST_HEAD(&tsdev->client_list); |
394 | init_waitqueue_head(&tsdev->wait); | 402 | init_waitqueue_head(&tsdev->wait); |
395 | 403 | ||
396 | sprintf(tsdev->name, "ts%d", minor); | 404 | sprintf(tsdev->name, "ts%d", minor); |
@@ -451,7 +459,7 @@ static int tsdev_connect(struct input_handler *handler, struct input_dev *dev, | |||
451 | static void tsdev_disconnect(struct input_handle *handle) | 459 | static void tsdev_disconnect(struct input_handle *handle) |
452 | { | 460 | { |
453 | struct tsdev *tsdev = handle->private; | 461 | struct tsdev *tsdev = handle->private; |
454 | struct tsdev_list *list; | 462 | struct tsdev_client *client; |
455 | 463 | ||
456 | input_unregister_handle(handle); | 464 | input_unregister_handle(handle); |
457 | 465 | ||
@@ -463,8 +471,8 @@ static void tsdev_disconnect(struct input_handle *handle) | |||
463 | if (tsdev->open) { | 471 | if (tsdev->open) { |
464 | input_close_device(handle); | 472 | input_close_device(handle); |
465 | wake_up_interruptible(&tsdev->wait); | 473 | wake_up_interruptible(&tsdev->wait); |
466 | list_for_each_entry(list, &tsdev->list, node) | 474 | list_for_each_entry(client, &tsdev->client_list, node) |
467 | kill_fasync(&list->fasync, SIGIO, POLL_HUP); | 475 | kill_fasync(&client->fasync, SIGIO, POLL_HUP); |
468 | } else | 476 | } else |
469 | tsdev_free(tsdev); | 477 | tsdev_free(tsdev); |
470 | } | 478 | } |