Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306605
b: refs/heads/master
c: 46f49b7
h: refs/heads/master
i:
  306603: df0422e
v: v3
  • Loading branch information
Dmitry Torokhov committed May 2, 2012
1 parent 9c3b85f commit 7b4f000
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 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: eb71d1bb270ef6b2a9c1bfaa7818e1e75b3d4546
refs/heads/master: 46f49b7a223ac7493e7cf619fb583d11edefc2c2
33 changes: 18 additions & 15 deletions trunk/drivers/input/serio/serio_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ 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 error = 0;
int error;

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

Expand All @@ -179,33 +179,32 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
break;

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

if (read)
break;

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

out:
return read ?: error;
return read;
}

static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
struct serio_raw_client *client = file->private_data;
struct serio_raw *serio_raw = client->serio_raw;
ssize_t written = 0;
int retval;
int retval = 0;
unsigned char c;

retval = mutex_lock_interruptible(&serio_raw_mutex);
Expand All @@ -225,16 +224,20 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
retval = -EFAULT;
goto out;
}

if (serio_write(serio_raw->serio, c)) {
retval = -EIO;
/* Either signal error or partial write */
if (retval == 0)
retval = -EIO;
goto out;
}
written++;

retval++;
}

out:
mutex_unlock(&serio_raw_mutex);
return written ?: retval;
return retval;
}

static unsigned int serio_raw_poll(struct file *file, poll_table *wait)
Expand Down

0 comments on commit 7b4f000

Please sign in to comment.