Lines Matching refs:evdev

28 struct evdev {  struct
46 struct evdev *evdev; argument
52 static struct evdev *evdev_table[EVDEV_MINORS];
89 struct evdev *evdev = handle->private; in evdev_event() local
100 client = rcu_dereference(evdev->grab); in evdev_event()
104 list_for_each_entry_rcu(client, &evdev->client_list, node) in evdev_event()
109 wake_up_interruptible(&evdev->wait); in evdev_event()
122 struct evdev *evdev = client->evdev; in evdev_flush() local
125 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_flush()
129 if (!evdev->exist) in evdev_flush()
132 retval = input_flush_device(&evdev->handle, file); in evdev_flush()
134 mutex_unlock(&evdev->mutex); in evdev_flush()
140 struct evdev *evdev = container_of(dev, struct evdev, dev); in evdev_free() local
142 input_put_device(evdev->handle.dev); in evdev_free()
143 kfree(evdev); in evdev_free()
150 static int evdev_grab(struct evdev *evdev, struct evdev_client *client) in evdev_grab() argument
154 if (evdev->grab) in evdev_grab()
157 error = input_grab_device(&evdev->handle); in evdev_grab()
161 rcu_assign_pointer(evdev->grab, client); in evdev_grab()
167 static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client) in evdev_ungrab() argument
169 if (evdev->grab != client) in evdev_ungrab()
172 rcu_assign_pointer(evdev->grab, NULL); in evdev_ungrab()
174 input_release_device(&evdev->handle); in evdev_ungrab()
179 static void evdev_attach_client(struct evdev *evdev, in evdev_attach_client() argument
182 spin_lock(&evdev->client_lock); in evdev_attach_client()
183 list_add_tail_rcu(&client->node, &evdev->client_list); in evdev_attach_client()
184 spin_unlock(&evdev->client_lock); in evdev_attach_client()
188 static void evdev_detach_client(struct evdev *evdev, in evdev_detach_client() argument
191 spin_lock(&evdev->client_lock); in evdev_detach_client()
193 spin_unlock(&evdev->client_lock); in evdev_detach_client()
197 static int evdev_open_device(struct evdev *evdev) in evdev_open_device() argument
201 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_open_device()
205 if (!evdev->exist) in evdev_open_device()
207 else if (!evdev->open++) { in evdev_open_device()
208 retval = input_open_device(&evdev->handle); in evdev_open_device()
210 evdev->open--; in evdev_open_device()
213 mutex_unlock(&evdev->mutex); in evdev_open_device()
217 static void evdev_close_device(struct evdev *evdev) in evdev_close_device() argument
219 mutex_lock(&evdev->mutex); in evdev_close_device()
221 if (evdev->exist && !--evdev->open) in evdev_close_device()
222 input_close_device(&evdev->handle); in evdev_close_device()
224 mutex_unlock(&evdev->mutex); in evdev_close_device()
231 static void evdev_hangup(struct evdev *evdev) in evdev_hangup() argument
235 spin_lock(&evdev->client_lock); in evdev_hangup()
236 list_for_each_entry(client, &evdev->client_list, node) in evdev_hangup()
238 spin_unlock(&evdev->client_lock); in evdev_hangup()
240 wake_up_interruptible(&evdev->wait); in evdev_hangup()
246 struct evdev *evdev = client->evdev; in evdev_release() local
248 mutex_lock(&evdev->mutex); in evdev_release()
249 if (evdev->grab == client) in evdev_release()
250 evdev_ungrab(evdev, client); in evdev_release()
251 mutex_unlock(&evdev->mutex); in evdev_release()
253 evdev_detach_client(evdev, client); in evdev_release()
256 evdev_close_device(evdev); in evdev_release()
257 put_device(&evdev->dev); in evdev_release()
273 struct evdev *evdev; in evdev_open() local
285 evdev = evdev_table[i]; in evdev_open()
286 if (evdev) in evdev_open()
287 get_device(&evdev->dev); in evdev_open()
290 if (!evdev) in evdev_open()
293 bufsize = evdev_compute_buffer_size(evdev->handle.dev); in evdev_open()
305 client->evdev = evdev; in evdev_open()
306 evdev_attach_client(evdev, client); in evdev_open()
308 error = evdev_open_device(evdev); in evdev_open()
318 evdev_detach_client(evdev, client); in evdev_open()
321 put_device(&evdev->dev); in evdev_open()
329 struct evdev *evdev = client->evdev; in evdev_write() local
336 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_write()
340 if (!evdev->exist) { in evdev_write()
352 input_inject_event(&evdev->handle, in evdev_write()
357 mutex_unlock(&evdev->mutex); in evdev_write()
383 struct evdev *evdev = client->evdev; in evdev_read() local
390 if (client->head == client->tail && evdev->exist && in evdev_read()
394 retval = wait_event_interruptible(evdev->wait, in evdev_read()
395 client->head != client->tail || !evdev->exist); in evdev_read()
399 if (!evdev->exist) in evdev_read()
418 struct evdev *evdev = client->evdev; in evdev_poll() local
421 poll_wait(file, &evdev->wait, wait); in evdev_poll()
423 mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; in evdev_poll()
624 struct evdev *evdev = client->evdev; in evdev_do_ioctl() local
625 struct input_dev *dev = evdev->handle.dev; in evdev_do_ioctl()
661 input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u); in evdev_do_ioctl()
662 input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v); in evdev_do_ioctl()
678 return evdev_grab(evdev, client); in evdev_do_ioctl()
680 return evdev_ungrab(evdev, client); in evdev_do_ioctl()
805 struct evdev *evdev = client->evdev; in evdev_ioctl_handler() local
808 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_ioctl_handler()
812 if (!evdev->exist) { in evdev_ioctl_handler()
820 mutex_unlock(&evdev->mutex); in evdev_ioctl_handler()
853 static int evdev_install_chrdev(struct evdev *evdev) in evdev_install_chrdev() argument
859 evdev_table[evdev->minor] = evdev; in evdev_install_chrdev()
863 static void evdev_remove_chrdev(struct evdev *evdev) in evdev_remove_chrdev() argument
869 evdev_table[evdev->minor] = NULL; in evdev_remove_chrdev()
878 static void evdev_mark_dead(struct evdev *evdev) in evdev_mark_dead() argument
880 mutex_lock(&evdev->mutex); in evdev_mark_dead()
881 evdev->exist = false; in evdev_mark_dead()
882 mutex_unlock(&evdev->mutex); in evdev_mark_dead()
885 static void evdev_cleanup(struct evdev *evdev) in evdev_cleanup() argument
887 struct input_handle *handle = &evdev->handle; in evdev_cleanup()
889 evdev_mark_dead(evdev); in evdev_cleanup()
890 evdev_hangup(evdev); in evdev_cleanup()
891 evdev_remove_chrdev(evdev); in evdev_cleanup()
894 if (evdev->open) { in evdev_cleanup()
907 struct evdev *evdev; in evdev_connect() local
920 evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL); in evdev_connect()
921 if (!evdev) in evdev_connect()
924 INIT_LIST_HEAD(&evdev->client_list); in evdev_connect()
925 spin_lock_init(&evdev->client_lock); in evdev_connect()
926 mutex_init(&evdev->mutex); in evdev_connect()
927 init_waitqueue_head(&evdev->wait); in evdev_connect()
929 dev_set_name(&evdev->dev, "event%d", minor); in evdev_connect()
930 evdev->exist = true; in evdev_connect()
931 evdev->minor = minor; in evdev_connect()
933 evdev->handle.dev = input_get_device(dev); in evdev_connect()
934 evdev->handle.name = dev_name(&evdev->dev); in evdev_connect()
935 evdev->handle.handler = handler; in evdev_connect()
936 evdev->handle.private = evdev; in evdev_connect()
938 evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor); in evdev_connect()
939 evdev->dev.class = &input_class; in evdev_connect()
940 evdev->dev.parent = &dev->dev; in evdev_connect()
941 evdev->dev.release = evdev_free; in evdev_connect()
942 device_initialize(&evdev->dev); in evdev_connect()
944 error = input_register_handle(&evdev->handle); in evdev_connect()
948 error = evdev_install_chrdev(evdev); in evdev_connect()
952 error = device_add(&evdev->dev); in evdev_connect()
959 evdev_cleanup(evdev); in evdev_connect()
961 input_unregister_handle(&evdev->handle); in evdev_connect()
963 put_device(&evdev->dev); in evdev_connect()
969 struct evdev *evdev = handle->private; in evdev_disconnect() local
971 device_del(&evdev->dev); in evdev_disconnect()
972 evdev_cleanup(evdev); in evdev_disconnect()
974 put_device(&evdev->dev); in evdev_disconnect()