aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/evdev.c
diff options
context:
space:
mode:
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