aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/evdev.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-01-31 09:13:14 -0500
committerTakashi Iwai <tiwai@suse.de>2012-01-31 09:13:14 -0500
commitea51e5040e24eefe44d70bc654a237ca1f0225b0 (patch)
treedf2e5922dcdfafae62a10d8cd97f98121064fc23 /drivers/input/evdev.c
parent3422a47041b8cb8f14ac1e3926bcf711121df6dc (diff)
parent8dbd52daee38adaae4d5a674bcca837e694a4f4c (diff)
Merge branch 'fix/asoc' into for-linus
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r--drivers/input/evdev.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 4cf25347b015..76457d50bc34 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -369,7 +369,7 @@ static int evdev_fetch_next_event(struct evdev_client *client,
369 369
370 spin_lock_irq(&client->buffer_lock); 370 spin_lock_irq(&client->buffer_lock);
371 371
372 have_event = client->head != client->tail; 372 have_event = client->packet_head != client->tail;
373 if (have_event) { 373 if (have_event) {
374 *event = client->buffer[client->tail++]; 374 *event = client->buffer[client->tail++];
375 client->tail &= client->bufsize - 1; 375 client->tail &= client->bufsize - 1;
@@ -391,14 +391,13 @@ static ssize_t evdev_read(struct file *file, char __user *buffer,
391 if (count < input_event_size()) 391 if (count < input_event_size())
392 return -EINVAL; 392 return -EINVAL;
393 393
394 if (client->packet_head == client->tail && evdev->exist && 394 if (!(file->f_flags & O_NONBLOCK)) {
395 (file->f_flags & O_NONBLOCK)) 395 retval = wait_event_interruptible(evdev->wait,
396 return -EAGAIN; 396 client->packet_head != client->tail ||
397 397 !evdev->exist);
398 retval = wait_event_interruptible(evdev->wait, 398 if (retval)
399 client->packet_head != client->tail || !evdev->exist); 399 return retval;
400 if (retval) 400 }
401 return retval;
402 401
403 if (!evdev->exist) 402 if (!evdev->exist)
404 return -ENODEV; 403 return -ENODEV;
@@ -412,6 +411,9 @@ static ssize_t evdev_read(struct file *file, char __user *buffer,
412 retval += input_event_size(); 411 retval += input_event_size();
413 } 412 }
414 413
414 if (retval == 0 && (file->f_flags & O_NONBLOCK))
415 return -EAGAIN;
416
415 return retval; 417 return retval;
416} 418}
417 419