Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306591
b: refs/heads/master
c: 486c8ab
h: refs/heads/master
i:
  306589: 46be923
  306587: 9f0bff1
  306583: bcc30cf
  306575: 1cae49e
  306559: 8c33cc6
v: v3
  • Loading branch information
Dmitry Torokhov committed Apr 21, 2012
1 parent e882795 commit 00d83fe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 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: 71f3d070a309504cdfef87b9e98836395b75ae0e
refs/heads/master: 486c8aba39e5f194519cd5c0e85e5d1de8b74b03
43 changes: 25 additions & 18 deletions trunk/drivers/input/serio/serio_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,38 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
struct serio_raw *serio_raw = client->serio_raw;
char uninitialized_var(c);
ssize_t read = 0;
int retval;
int error = 0;

if (serio_raw->dead)
return -ENODEV;
do {
if (serio_raw->dead)
return -ENODEV;

if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK))
return -EAGAIN;
if (serio_raw->head == serio_raw->tail &&
(file->f_flags & O_NONBLOCK))
return -EAGAIN;

retval = wait_event_interruptible(serio_raw->wait,
serio_raw->head != serio_raw->tail || serio_raw->dead);
if (retval)
return retval;
if (count == 0)
break;

if (serio_raw->dead)
return -ENODEV;
while (read < count && serio_raw_fetch_byte(serio_raw, &c)) {
if (put_user(c, buffer++)) {
error = -EFAULT;
goto out;
}
read++;
}

while (read < count && serio_raw_fetch_byte(serio_raw, &c)) {
if (put_user(c, buffer++)) {
retval = -EFAULT;
if (read)
break;
}
read++;
}

return read ?: retval;
if (!(file->f_flags & O_NONBLOCK))
error = wait_event_interruptible(serio_raw->wait,
serio_raw->head != serio_raw->tail ||
serio_raw->dead);
} while (!error);

out:
return read ?: error;
}

static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
Expand Down

0 comments on commit 00d83fe

Please sign in to comment.