Release 4.11 drivers/input/evdev.c
/*
* Event char devices, giving access to raw input device events.
*
* Copyright (c) 1999-2002 Vojtech Pavlik
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define EVDEV_MINOR_BASE 64
#define EVDEV_MINORS 32
#define EVDEV_MIN_BUFFER_SIZE 64U
#define EVDEV_BUF_PACKETS 8
#include <linux/poll.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/input/mt.h>
#include <linux/major.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include "input-compat.h"
enum evdev_clock_type {
EV_CLK_REAL = 0,
EV_CLK_MONO,
EV_CLK_BOOT,
EV_CLK_MAX
};
struct evdev {
int open;
struct input_handle handle;
wait_queue_head_t wait;
struct evdev_client __rcu *grab;
struct list_head client_list;
spinlock_t client_lock; /* protects client_list */
struct mutex mutex;
struct device dev;
struct cdev cdev;
bool exist;
};
struct evdev_client {
unsigned int head;
unsigned int tail;
unsigned int packet_head; /* [future] position of the first element of next packet */
spinlock_t buffer_lock; /* protects access to buffer, head and tail */
struct fasync_struct *fasync;
struct evdev *evdev;
struct list_head node;
unsigned int clk_type;
bool revoked;
unsigned long *evmasks[EV_CNT];
unsigned int bufsize;
struct input_event buffer[];
};
static size_t evdev_get_mask_cnt(unsigned int type)
{
static const size_t counts[EV_CNT] = {
/* EV_SYN==0 is EV_CNT, _not_ SYN_CNT, see EVIOCGBIT */
[EV_SYN] = EV_CNT,
[EV_KEY] = KEY_CNT,
[EV_REL] = REL_CNT,
[EV_ABS] = ABS_CNT,
[EV_MSC] = MSC_CNT,
[EV_SW] = SW_CNT,
[EV_LED] = LED_CNT,
[EV_SND] = SND_CNT,
[EV_FF] = FF_CNT,
};
return (type < EV_CNT) ? counts[type] : 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Herrmann | 89 | 100.00% | 1 | 100.00% |
Total | 89 | 100.00% | 1 | 100.00% |
/* requires the buffer lock to be held */
static bool __evdev_is_filtered(struct evdev_client *client,
unsigned int type,
unsigned int code)
{
unsigned long *mask;
size_t cnt;
/* EV_SYN and unknown codes are never filtered */
if (type == EV_SYN || type >= EV_CNT)
return false;
/* first test whether the type is filtered */
mask = client->evmasks[0];
if (mask && !test_bit(type, mask))
return true;
/* unknown values are never filtered */
cnt = evdev_get_mask_cnt(type);
if (!cnt || code >= cnt)
return false;
mask = client->evmasks[type];
return mask && !test_bit(code, mask);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Herrmann | 106 | 100.00% | 1 | 100.00% |
Total | 106 | 100.00% | 1 | 100.00% |
/* flush queued events of type @type, caller must hold client->buffer_lock */
static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
{
unsigned int i, head, num;
unsigned int mask = client->bufsize - 1;
bool is_report;
struct input_event *ev;
BUG_ON(type == EV_SYN);
head = client->tail;
client->packet_head = client->tail;
/* init to 1 so a leading SYN_REPORT will not be dropped */
num = 1;
for (i = client->tail; i != client->head; i = (i + 1) & mask) {
ev = &client->buffer[i];
is_report = ev->type == EV_SYN && ev->code == SYN_REPORT;
if (ev->type == type) {
/* drop matched entry */
continue;
} else if (is_report && !num) {
/* drop empty SYN_REPORT groups */
continue;
} else if (head != i) {
/* move entry to fill the gap */
client->buffer[head].time = ev->time;
client->buffer[head].type = ev->type;
client->buffer[head].code = ev->code;
client->buffer[head].value = ev->value;
}
num++;
head = (head + 1) & mask;
if (is_report) {
num = 0;
client->packet_head = head;
}
}
client->head = head;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Herrmann | 238 | 100.00% | 1 | 100.00% |
Total | 238 | 100.00% | 1 | 100.00% |
static void __evdev_queue_syn_dropped(struct evdev_client *client)
{
struct input_event ev;
ktime_t time;
time = client->clk_type == EV_CLK_REAL ?
ktime_get_real() :
client->clk_type == EV_CLK_MONO ?
ktime_get() :
ktime_get_boottime();
ev.time = ktime_to_timeval(time);
ev.type = EV_SYN;
ev.code = SYN_DROPPED;
ev.value = 0;
client->buffer[client->head++] = ev;
client->head &= client->bufsize - 1;
if (unlikely(client->head == client->tail)) {
/* drop queue but keep our SYN_DROPPED event */
client->tail = (client->head - 1) & (client->bufsize - 1);
client->packet_head = client->tail;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Herrmann | 115 | 85.82% | 1 | 25.00% |
Aniroop Mathur | 12 | 8.96% | 1 | 25.00% |
Thomas Gleixner | 5 | 3.73% | 1 | 25.00% |
Dmitry Torokhov | 2 | 1.49% | 1 | 25.00% |
Total | 134 | 100.00% | 4 | 100.00% |
static void evdev_queue_syn_dropped(struct evdev_client *client)
{
unsigned long flags;
spin_lock_irqsave(&client->buffer_lock, flags);
__evdev_queue_syn_dropped(client);
spin_unlock_irqrestore(&client->buffer_lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 29 | 72.50% | 1 | 50.00% |
David Herrmann | 11 | 27.50% | 1 | 50.00% |
Total | 40 | 100.00% | 2 | 100.00% |
static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
{
unsigned long flags;
unsigned int clk_type;
switch (clkid) {
case CLOCK_REALTIME:
clk_type = EV_CLK_REAL;
break;
case CLOCK_MONOTONIC:
clk_type = EV_CLK_MONO;
break;
case CLOCK_BOOTTIME:
clk_type = EV_CLK_BOOT;
break;
default:
return -EINVAL;
}
if (client->clk_type != clk_type) {
client->clk_type = clk_type;
/*
* Flush pending events and queue SYN_DROPPED event,
* but only if the queue is not empty.
*/
spin_lock_irqsave(&client->buffer_lock, flags);
if (client->head != client->tail) {
client->packet_head = client->head = client->tail;
__evdev_queue_syn_dropped(client);
}
spin_unlock_irqrestore(&client->buffer_lock, flags);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anshul Garg | 59 | 46.46% | 1 | 33.33% |
Dmitry Torokhov | 48 | 37.80% | 1 | 33.33% |
Aniroop Mathur | 20 | 15.75% | 1 | 33.33% |
Total | 127 | 100.00% | 3 | 100.00% |
static void __pass_event(struct evdev_client *client,
const struct input_event *event)
{
client->buffer[client->head++] = *event;
client->head &= client->bufsize - 1;
if (unlikely(client->head == client->tail)) {
/*
* This effectively "drops" all unconsumed events, leaving
* EV_SYN/SYN_DROPPED plus the newest event in the queue.
*/
client->tail = (client->head - 2) & (client->bufsize - 1);
client->buffer[client->tail].time = event->time;
client->buffer[client->tail].type = EV_SYN;
client->buffer[client->tail].code = SYN_DROPPED;
client->buffer[client->tail].value = 0;
client->packet_head = client->tail;
}
if (event->type == EV_SYN && event->code == SYN_REPORT) {
client->packet_head = client->head;
kill_fasync(&client->fasync, SIGIO, POLL_IN);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Brown | 101 | 58.05% | 2 | 28.57% |
Dmitry Torokhov | 50 | 28.74% | 1 | 14.29% |
Henrik Rydberg | 15 | 8.62% | 3 | 42.86% |
Adam Jackson | 8 | 4.60% | 1 | 14.29% |
Total | 174 | 100.00% | 7 | 100.00% |
static void evdev_pass_values(struct evdev_client *client,
const struct input_value *vals, unsigned int count,
ktime_t *ev_time)
{
struct evdev *evdev = client->evdev;
const struct input_value *v;
struct input_event event;
bool wakeup = false;
if (client->revoked)
return;
event.time = ktime_to_timeval(ev_time[client->clk_type]);
/* Interrupts are disabled, just acquire the lock. */
spin_lock(&client->buffer_lock);
for (v = vals; v != vals + count; v++) {
if (__evdev_is_filtered(client, v->type, v->code))
continue;
if (v->type == EV_SYN && v->code == SYN_REPORT) {
/* drop empty SYN_REPORT */
if (client->packet_head == client->head)
continue;
wakeup = true;
}
event.type = v->type;
event.code = v->code;
event.value = v->value;
__pass_event(client, &event);
}
spin_unlock(&client->buffer_lock);
if (wakeup)
wake_up_interruptible(&evdev->wait);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Henrik Rydberg | 126 | 64.29% | 1 | 20.00% |
David Herrmann | 55 | 28.06% | 2 | 40.00% |
Jeff Brown | 9 | 4.59% | 1 | 20.00% |
Aniroop Mathur | 6 | 3.06% | 1 | 20.00% |
Total | 196 | 100.00% | 5 | 100.00% |
/*
* Pass incoming events to all connected clients.
*/
static void evdev_events(struct input_handle *handle,
const struct input_value *vals, unsigned int count)
{
struct evdev *evdev = handle->private;
struct evdev_client *client;
ktime_t ev_time[EV_CLK_MAX];
ev_time[EV_CLK_MONO] = ktime_get();
ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
TK_OFFS_BOOT);
rcu_read_lock();
client = rcu_dereference(evdev->grab);
if (client)
evdev_pass_values(client, vals, count, ev_time);
else
list_for_each_entry_rcu(client, &evdev->client_list, node)
evdev_pass_values(client, vals, count, ev_time);
rcu_read_unlock();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Aniroop Mathur | 33 | 25.98% | 1 | 10.00% |
Linus Torvalds (pre-git) | 29 | 22.83% | 1 | 10.00% |
Dmitry Torokhov | 23 | 18.11% | 3 | 30.00% |
Henrik Rydberg | 16 | 12.60% | 1 | 10.00% |
Zephaniah E. Hull | 11 | 8.66% | 1 | 10.00% |
John Stultz | 9 | 7.09% | 1 | 10.00% |
Vojtech Pavlik | 5 | 3.94% | 1 | 10.00% |
Thomas Gleixner | 1 | 0.79% | 1 | 10.00% |
Total | 127 | 100.00% | 10 | 100.00% |
/*
* Pass incoming event to all connected clients.
*/
static void evdev_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
struct input_value vals[] = { { type, code, value } };
evdev_events(handle, vals, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Henrik Rydberg | 40 | 86.96% | 1 | 33.33% |
Linus Torvalds (pre-git) | 4 | 8.70% | 1 | 33.33% |
Dmitry Torokhov | 2 | 4.35% | 1 | 33.33% |
Total | 46 | 100.00% | 3 | 100.00% |
static int evdev_fasync(int fd, struct file *file, int on)
{
struct evdev_client *client = file->private_data;
return fasync_helper(fd, file, on, &client->fasync);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 37 | 90.24% | 1 | 33.33% |
Dmitry Torokhov | 3 | 7.32% | 1 | 33.33% |
Jonathan Corbet | 1 | 2.44% | 1 | 33.33% |
Total | 41 | 100.00% | 3 | 100.00% |
static int evdev_flush(struct file *file, fl_owner_t id)
{
struct evdev_client *client = file->private_data;
struct evdev *evdev = client->evdev;
mutex_lock(&evdev->mutex);
if (evdev->exist && !client->revoked)
input_flush_device(&evdev->handle, file);
mutex_unlock(&evdev->mutex);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 32 | 44.44% | 2 | 28.57% |
Vojtech Pavlik | 30 | 41.67% | 2 | 28.57% |
Takashi Iwai | 4 | 5.56% | 1 | 14.29% |
David Herrmann | 3 | 4.17% | 1 | 14.29% |
Miklos Szeredi | 3 | 4.17% | 1 | 14.29% |
Total | 72 | 100.00% | 7 | 100.00% |
static void evdev_free(struct device *dev)
{
struct evdev *evdev = container_of(dev, struct evdev, dev);
input_put_device(evdev->handle.dev);
kfree(evdev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 32 | 80.00% | 3 | 75.00% |
Christoph Hellwig | 8 | 20.00% | 1 | 25.00% |
Total | 40 | 100.00% | 4 | 100.00% |
/*
* Grabs an event device (along with underlying input device).
* This function is called with evdev->mutex taken.
*/
static int evdev_grab(struct evdev *evdev, struct evdev_client *client)
{
int error;
if (evdev->grab)
return -EBUSY;
error = input_grab_device(&evdev->handle);
if (error)
return error;
rcu_assign_pointer(evdev->grab, client);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 55 | 94.83% | 1 | 50.00% |
Christoph Hellwig | 3 | 5.17% | 1 | 50.00% |
Total | 58 | 100.00% | 2 | 100.00% |
static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client)
{
struct evdev_client *grab = rcu_dereference_protected(evdev->grab,
lockdep_is_held(&evdev->mutex));
if (grab != client)
return -EINVAL;
rcu_assign_pointer(evdev->grab, NULL);
synchronize_rcu();
input_release_device(&evdev->handle);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 67 | 97.10% | 3 | 75.00% |
Christoph Hellwig | 2 | 2.90% | 1 | 25.00% |
Total | 69 | 100.00% | 4 | 100.00% |
static void evdev_attach_client(struct evdev *evdev,
struct evdev_client *client)
{
spin_lock(&evdev->client_lock);
list_add_tail_rcu(&client->node, &evdev->client_list);
spin_unlock(&evdev->client_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 43 | 95.56% | 1 | 50.00% |
Christoph Hellwig | 2 | 4.44% | 1 | 50.00% |
Total | 45 | 100.00% | 2 | 100.00% |
static void evdev_detach_client(struct evdev *evdev,
struct evdev_client *client)
{
spin_lock(&evdev->client_lock);
list_del_rcu(&client->node);
spin_unlock(&evdev->client_lock);
synchronize_rcu();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 43 | 100.00% | 2 | 100.00% |
Total | 43 | 100.00% | 2 | 100.00% |
static int evdev_open_device(struct evdev *evdev)
{
int retval;
retval = mutex_lock_interruptible(&evdev->mutex);
if (retval)
return retval;
if (!evdev->exist)
retval = -ENODEV;
else if (!evdev->open++) {
retval = input_open_device(&evdev->handle);
if (retval)
evdev->open--;
}
mutex_unlock(&evdev->mutex);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 73 | 86.90% | 1 | 50.00% |
Oliver Neukum | 11 | 13.10% | 1 | 50.00% |
Total | 84 | 100.00% | 2 | 100.00% |
static void evdev_close_device(struct evdev *evdev)
{
mutex_lock(&evdev->mutex);
if (evdev->exist && !--evdev->open)
input_close_device(&evdev->handle);
mutex_unlock(&evdev->mutex);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 47 | 100.00% | 1 | 100.00% |
Total | 47 | 100.00% | 1 | 100.00% |
/*
* Wake up users waiting for IO so they can disconnect from
* dead device.
*/
static void evdev_hangup(struct evdev *evdev)
{
struct evdev_client *client;
spin_lock(&evdev->client_lock);
list_for_each_entry(client, &evdev->client_list, node)
kill_fasync(&client->fasync, SIGIO, POLL_HUP);
spin_unlock(&evdev->client_lock);
wake_up_interruptible(&evdev->wait);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 57 | 95.00% | 1 | 50.00% |
Christoph Hellwig | 3 | 5.00% | 1 | 50.00% |
Total | 60 | 100.00% | 2 | 100.00% |
static int evdev_release(struct inode *inode, struct file *file)
{
struct evdev_client *client = file->private_data;
struct evdev *evdev = client->evdev;
unsigned int i;
mutex_lock(&evdev->mutex);
evdev_ungrab(evdev, client);
mutex_unlock(&evdev->mutex);
evdev_detach_client(evdev, client);
for (i = 0; i < EV_CNT; ++i)
kfree(client->evmasks[i]);
kvfree(client);
evdev_close_device(evdev);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Herrmann | 37 | 35.58% | 1 | 16.67% |
Dmitry Torokhov | 31 | 29.81% | 2 | 33.33% |
Linus Torvalds (pre-git) | 27 | 25.96% | 1 | 16.67% |
Zephaniah E. Hull | 7 | 6.73% | 1 | 16.67% |
Vojtech Pavlik | 2 | 1.92% | 1 | 16.67% |
Total | 104 | 100.00% | 6 | 100.00% |
static unsigned int evdev_compute_buffer_size(struct input_dev *dev)
{
unsigned int n_events =
max(dev->hint_events_per_packet * EVDEV_BUF_PACKETS,
EVDEV_MIN_BUFFER_SIZE);
return roundup_pow_of_two(n_events);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Henrik Rydberg | 33 | 100.00% | 2 | 100.00% |
Total | 33 | 100.00% | 2 | 100.00% |
static int evdev_open(struct inode *inode, struct file *file)
{
struct evdev *evdev = container_of(inode->i_cdev, struct evdev, cdev);
unsigned int bufsize = evdev_compute_buffer_size(evdev->handle.dev);
unsigned int size = sizeof(struct evdev_client) +
bufsize * sizeof(struct input_event);
struct evdev_client *client;
int error;
client = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
if (!client)
client = vzalloc(size);
if (!client)
return -ENOMEM;
client->bufsize = bufsize;
spin_lock_init(&client->buffer_lock);
client->evdev = evdev;
evdev_attach_client(evdev, client);
error = evdev_open_device(evdev);
if (error)
goto err_free_client;
file->private_data = client;
nonseekable_open(inode, file);
return 0;
err_free_client:
evdev_detach_client(evdev, client);
kvfree(client);
return error;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 75 | 42.13% | 6 | 50.00% |
Linus Torvalds (pre-git) | 44 | 24.72% | 2 | 16.67% |
Daniel Stone | 31 | 17.42% | 1 | 8.33% |
Henrik Rydberg | 25 | 14.04% | 1 | 8.33% |
Vojtech Pavlik | 2 | 1.12% | 1 | 8.33% |
Andrew Morton | 1 | 0.56% | 1 | 8.33% |
Total | 178 | 100.00% | 12 | 100.00% |
static ssize_t evdev_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
struct evdev_client *client = file->private_data;
struct evdev *evdev = client->evdev;
struct input_event event;
int retval = 0;
if (count != 0 && count < input_event_size())
return -EINVAL;
retval = mutex_lock_interruptible(&evdev->mutex);
if (retval)
return retval;
if (!evdev->exist || client->revoked) {
retval = -ENODEV;
goto out;
}
while (retval + input_event_size() <= count) {
if (input_event_from_user(buffer + retval, &event)) {
retval = -EFAULT;
goto out;
}
retval += input_event_size();
input_inject_event(&evdev->handle,
event.type, event.code, event.value);
}
out:
mutex_unlock(&evdev->mutex);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 147 | 84.00% | 5 | 50.00% |
Peter Korsgaard | 17 | 9.71% | 1 | 10.00% |
Juergen Kreileder | 4 | 2.29% | 1 | 10.00% |
David Herrmann | 4 | 2.29% | 1 | 10.00% |
Heiko Stübner | 2 | 1.14% | 1 | 10.00% |
Philip Langdale | 1 | 0.57% | 1 | 10.00% |
Total | 175 | 100.00% | 10 | 100.00% |
static int evdev_fetch_next_event(struct evdev_client *client,
struct input_event *event)
{
int have_event;
spin_lock_irq(&client->buffer_lock);
have_event = client->packet_head != client->tail;
if (have_event) {
*event = client->buffer[client->tail++];
client->tail &= client->bufsize - 1;
}
spin_unlock_irq(&client->buffer_lock);
return have_event;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 73 | 94.81% | 1 | 33.33% |
Henrik Rydberg | 3 | 3.90% | 1 | 33.33% |
Dima Zavin | 1 | 1.30% | 1 | 33.33% |
Total | 77 | 100.00% | 3 | 100.00% |
static ssize_t evdev_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos)
{
struct evdev_client *client = file->private_data;
struct evdev *evdev = client->evdev;
struct input_event event;
size_t read = 0;
int error;
if (count != 0 && count < input_event_size())
return -EINVAL;
for (;;) {
if (!evdev->exist || client->revoked)
return -ENODEV;
if (client->packet_head == client->tail &&
(file->f_flags & O_NONBLOCK))
return -EAGAIN;
/*
* count == 0 is special - no IO is done but we check
* for error conditions (see above).
*/
if (count == 0)
break;
while (read + input_event_size() <= count &&
evdev_fetch_next_event(client, &event)) {
if (input_event_to_user(buffer + read, &event))
return -EFAULT;
read += input_event_size();
}
if (read)
break;
if (!(file->f_flags & O_NONBLOCK)) {
error = wait_event_interruptible(evdev->wait,
client->packet_head != client->tail ||
!evdev->exist || client->revoked);
if (error)
return error;
}
}
return read;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 147 | 68.69% | 4 | 36.36% |
Juergen Kreileder | 39 | 18.22% | 1 | 9.09% |
Dima Zavin | 13 | 6.07% | 2 | 18.18% |
David Herrmann | 8 | 3.74% | 1 | 9.09% |
Philip Langdale | 4 | 1.87% | 1 | 9.09% |
Heiko Stübner | 2 | 0.93% | 1 | 9.09% |
Jeff Brown | 1 | 0.47% | 1 | 9.09% |
Total | 214 | 100.00% | 11 | 100.00% |
/* No kernel lock - fine */
static unsigned int evdev_poll(struct file *file, poll_table *wait)
{
struct evdev_client *client = file->private_data;
struct evdev *evdev = client->evdev;
unsigned int mask;
poll_wait(file, &evdev->wait, wait);
if (evdev->exist && !client->revoked)
mask = POLLOUT | POLLWRNORM;
else
mask = POLLHUP | POLLERR;
if (client->packet_head != client->tail)
mask |= POLLIN | POLLRDNORM;
return mask;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Torokhov | 36 | 38.71% | 2 | 33.33% |
Juergen Kreileder | 26 | 27.96% | 1 | 16.67% |
Linus Torvalds (pre-git) | 16 | 17.20% | 1 | 16.67% |
David Herrmann | 14 | 15.05% | 1 | 16.67% |
Jeff Brown | 1 | 1.08% | 1 | 16.67% |
Total | 93 | 100.00% | 6 | 100.00% |
#ifdef CONFIG_COMPAT
#define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8)
#define BITS_TO_LONGS_COMPAT(x) ((((x) - 1) / BITS_PER_LONG_COMPAT) + 1)
#ifdef __BIG_ENDIAN
static int bits_to_user(unsigned long *bits, unsigned int maxbit,
unsigned int maxlen, void __user *p, int compat)
{
int len, i;
if (compat) {
len = BITS_TO_LONGS_COMPAT(maxbit)