Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294008
b: refs/heads/master
c: a80b83b
h: refs/heads/master
v: v3
  • Loading branch information
John Stultz authored and Dmitry Torokhov committed Feb 3, 2012
1 parent 4ab01ae commit f06b7d4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4065d1e7b2164cff4af57b58fac887df2fe75d2a
refs/heads/master: a80b83b7b8456e9b475346c2e01d7e210883208c
25 changes: 21 additions & 4 deletions trunk/drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct evdev_client {
struct fasync_struct *fasync;
struct evdev *evdev;
struct list_head node;
int clkid;
unsigned int bufsize;
struct input_event buffer[];
};
Expand All @@ -54,8 +55,12 @@ static struct evdev *evdev_table[EVDEV_MINORS];
static DEFINE_MUTEX(evdev_table_mutex);

static void evdev_pass_event(struct evdev_client *client,
struct input_event *event)
struct input_event *event,
ktime_t mono, ktime_t real)
{
event->time = ktime_to_timeval(client->clkid == CLOCK_MONOTONIC ?
mono : real);

/* Interrupts are disabled, just acquire the lock. */
spin_lock(&client->buffer_lock);

Expand Down Expand Up @@ -94,20 +99,24 @@ static void evdev_event(struct input_handle *handle,
struct evdev *evdev = handle->private;
struct evdev_client *client;
struct input_event event;
ktime_t time_mono, time_real;

time_mono = ktime_get();
time_real = ktime_sub(time_mono, ktime_get_monotonic_offset());

do_gettimeofday(&event.time);
event.type = type;
event.code = code;
event.value = value;

rcu_read_lock();

client = rcu_dereference(evdev->grab);

if (client)
evdev_pass_event(client, &event);
evdev_pass_event(client, &event, time_mono, time_real);
else
list_for_each_entry_rcu(client, &evdev->client_list, node)
evdev_pass_event(client, &event);
evdev_pass_event(client, &event, time_mono, time_real);

rcu_read_unlock();

Expand Down Expand Up @@ -685,6 +694,14 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
else
return evdev_ungrab(evdev, client);

case EVIOCSCLOCKID:
if (copy_from_user(&i, p, sizeof(unsigned int)))
return -EFAULT;
if (i != CLOCK_MONOTONIC && i != CLOCK_REALTIME)
return -EINVAL;
client->clkid = i;
return 0;

case EVIOCGKEYCODE:
return evdev_handle_get_keycode(dev, p);

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ struct input_keymap_entry {

#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */

#define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */

/*
* Device properties and quirks
*/
Expand Down
2 changes: 2 additions & 0 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,8 @@ ktime_t ktime_get_monotonic_offset(void)
} while (read_seqretry(&xtime_lock, seq));
return timespec_to_ktime(wtom);
}
EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset);


/**
* xtime_update() - advances the timekeeping infrastructure
Expand Down

0 comments on commit f06b7d4

Please sign in to comment.