Lines Matching refs:evdev

28 struct evdev {  struct
47 struct evdev *evdev; argument
145 ktime_t *ev_time = input_get_timestamp(client->evdev->handle.dev); in __evdev_queue_syn_dropped()
294 struct evdev *evdev = handle->private; in evdev_events() local
300 client = rcu_dereference(evdev->grab); in evdev_events()
305 list_for_each_entry_rcu(client, &evdev->client_list, node) in evdev_events()
331 struct evdev *evdev = container_of(dev, struct evdev, dev); in evdev_free() local
333 input_put_device(evdev->handle.dev); in evdev_free()
334 kfree(evdev); in evdev_free()
341 static int evdev_grab(struct evdev *evdev, struct evdev_client *client) in evdev_grab() argument
345 if (evdev->grab) in evdev_grab()
348 error = input_grab_device(&evdev->handle); in evdev_grab()
352 rcu_assign_pointer(evdev->grab, client); in evdev_grab()
357 static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client) in evdev_ungrab() argument
359 struct evdev_client *grab = rcu_dereference_protected(evdev->grab, in evdev_ungrab()
360 lockdep_is_held(&evdev->mutex)); in evdev_ungrab()
365 rcu_assign_pointer(evdev->grab, NULL); in evdev_ungrab()
367 input_release_device(&evdev->handle); in evdev_ungrab()
372 static void evdev_attach_client(struct evdev *evdev, in evdev_attach_client() argument
375 spin_lock(&evdev->client_lock); in evdev_attach_client()
376 list_add_tail_rcu(&client->node, &evdev->client_list); in evdev_attach_client()
377 spin_unlock(&evdev->client_lock); in evdev_attach_client()
380 static void evdev_detach_client(struct evdev *evdev, in evdev_detach_client() argument
383 spin_lock(&evdev->client_lock); in evdev_detach_client()
385 spin_unlock(&evdev->client_lock); in evdev_detach_client()
389 static int evdev_open_device(struct evdev *evdev) in evdev_open_device() argument
393 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_open_device()
397 if (!evdev->exist) in evdev_open_device()
399 else if (!evdev->open++) { in evdev_open_device()
400 retval = input_open_device(&evdev->handle); in evdev_open_device()
402 evdev->open--; in evdev_open_device()
405 mutex_unlock(&evdev->mutex); in evdev_open_device()
409 static void evdev_close_device(struct evdev *evdev) in evdev_close_device() argument
411 mutex_lock(&evdev->mutex); in evdev_close_device()
413 if (evdev->exist && !--evdev->open) in evdev_close_device()
414 input_close_device(&evdev->handle); in evdev_close_device()
416 mutex_unlock(&evdev->mutex); in evdev_close_device()
423 static void evdev_hangup(struct evdev *evdev) in evdev_hangup() argument
427 spin_lock(&evdev->client_lock); in evdev_hangup()
428 list_for_each_entry(client, &evdev->client_list, node) { in evdev_hangup()
432 spin_unlock(&evdev->client_lock); in evdev_hangup()
438 struct evdev *evdev = client->evdev; in evdev_release() local
441 mutex_lock(&evdev->mutex); in evdev_release()
443 if (evdev->exist && !client->revoked) in evdev_release()
444 input_flush_device(&evdev->handle, file); in evdev_release()
446 evdev_ungrab(evdev, client); in evdev_release()
447 mutex_unlock(&evdev->mutex); in evdev_release()
449 evdev_detach_client(evdev, client); in evdev_release()
456 evdev_close_device(evdev); in evdev_release()
472 struct evdev *evdev = container_of(inode->i_cdev, struct evdev, cdev); in evdev_open() local
473 unsigned int bufsize = evdev_compute_buffer_size(evdev->handle.dev); in evdev_open()
484 client->evdev = evdev; in evdev_open()
485 evdev_attach_client(evdev, client); in evdev_open()
487 error = evdev_open_device(evdev); in evdev_open()
497 evdev_detach_client(evdev, client); in evdev_open()
506 struct evdev *evdev = client->evdev; in evdev_write() local
513 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_write()
517 if (!evdev->exist || client->revoked) { in evdev_write()
530 input_inject_event(&evdev->handle, in evdev_write()
536 mutex_unlock(&evdev->mutex); in evdev_write()
562 struct evdev *evdev = client->evdev; in evdev_read() local
571 if (!evdev->exist || client->revoked) in evdev_read()
600 !evdev->exist || client->revoked); in evdev_read()
613 struct evdev *evdev = client->evdev; in evdev_poll() local
618 if (evdev->exist && !client->revoked) in evdev_poll()
943 static int evdev_revoke(struct evdev *evdev, struct evdev_client *client, in evdev_revoke() argument
947 evdev_ungrab(evdev, client); in evdev_revoke()
948 input_flush_device(&evdev->handle, file); in evdev_revoke()
1033 struct evdev *evdev = client->evdev; in evdev_do_ioctl() local
1034 struct input_dev *dev = evdev->handle.dev; in evdev_do_ioctl()
1071 input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u); in evdev_do_ioctl()
1072 input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v); in evdev_do_ioctl()
1088 return evdev_grab(evdev, client); in evdev_do_ioctl()
1090 return evdev_ungrab(evdev, client); in evdev_do_ioctl()
1096 return evdev_revoke(evdev, client, file); in evdev_do_ioctl()
1260 struct evdev *evdev = client->evdev; in evdev_ioctl_handler() local
1263 retval = mutex_lock_interruptible(&evdev->mutex); in evdev_ioctl_handler()
1267 if (!evdev->exist || client->revoked) { in evdev_ioctl_handler()
1275 mutex_unlock(&evdev->mutex); in evdev_ioctl_handler()
1312 static void evdev_mark_dead(struct evdev *evdev) in evdev_mark_dead() argument
1314 mutex_lock(&evdev->mutex); in evdev_mark_dead()
1315 evdev->exist = false; in evdev_mark_dead()
1316 mutex_unlock(&evdev->mutex); in evdev_mark_dead()
1319 static void evdev_cleanup(struct evdev *evdev) in evdev_cleanup() argument
1321 struct input_handle *handle = &evdev->handle; in evdev_cleanup()
1323 evdev_mark_dead(evdev); in evdev_cleanup()
1324 evdev_hangup(evdev); in evdev_cleanup()
1327 if (evdev->open) { in evdev_cleanup()
1340 struct evdev *evdev; in evdev_connect() local
1352 evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL); in evdev_connect()
1353 if (!evdev) { in evdev_connect()
1358 INIT_LIST_HEAD(&evdev->client_list); in evdev_connect()
1359 spin_lock_init(&evdev->client_lock); in evdev_connect()
1360 mutex_init(&evdev->mutex); in evdev_connect()
1361 evdev->exist = true; in evdev_connect()
1367 dev_set_name(&evdev->dev, "event%d", dev_no); in evdev_connect()
1369 evdev->handle.dev = input_get_device(dev); in evdev_connect()
1370 evdev->handle.name = dev_name(&evdev->dev); in evdev_connect()
1371 evdev->handle.handler = handler; in evdev_connect()
1372 evdev->handle.private = evdev; in evdev_connect()
1374 evdev->dev.devt = MKDEV(INPUT_MAJOR, minor); in evdev_connect()
1375 evdev->dev.class = &input_class; in evdev_connect()
1376 evdev->dev.parent = &dev->dev; in evdev_connect()
1377 evdev->dev.release = evdev_free; in evdev_connect()
1378 device_initialize(&evdev->dev); in evdev_connect()
1380 error = input_register_handle(&evdev->handle); in evdev_connect()
1384 cdev_init(&evdev->cdev, &evdev_fops); in evdev_connect()
1386 error = cdev_device_add(&evdev->cdev, &evdev->dev); in evdev_connect()
1393 evdev_cleanup(evdev); in evdev_connect()
1394 input_unregister_handle(&evdev->handle); in evdev_connect()
1396 put_device(&evdev->dev); in evdev_connect()
1404 struct evdev *evdev = handle->private; in evdev_disconnect() local
1406 cdev_device_del(&evdev->cdev, &evdev->dev); in evdev_disconnect()
1407 evdev_cleanup(evdev); in evdev_disconnect()
1408 input_free_minor(MINOR(evdev->dev.devt)); in evdev_disconnect()
1410 put_device(&evdev->dev); in evdev_disconnect()