Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223570
b: refs/heads/master
c: 250f7a5
h: refs/heads/master
v: v3
  • Loading branch information
Dan Carpenter authored and Mauro Carvalho Chehab committed Dec 20, 2010
1 parent c007dd9 commit d3ff520
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 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: 5c769a68beaee924e1dc90bf06e1b087b1d46237
refs/heads/master: 250f7a5f62a08985af5cf7728ae7ba9edbfdc0a9
25 changes: 15 additions & 10 deletions trunk/drivers/media/IR/lirc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,18 +647,18 @@ ssize_t lirc_dev_fop_read(struct file *file,
if (!buf)
return -ENOMEM;

if (mutex_lock_interruptible(&ir->irctl_lock))
return -ERESTARTSYS;
if (mutex_lock_interruptible(&ir->irctl_lock)) {
ret = -ERESTARTSYS;
goto out_unlocked;
}
if (!ir->attached) {
mutex_unlock(&ir->irctl_lock);
return -ENODEV;
ret = -ENODEV;
goto out_locked;
}

if (length % ir->chunk_size) {
dev_dbg(ir->d.dev, LOGHEAD "read result = -EINVAL\n",
ir->d.name, ir->d.minor);
mutex_unlock(&ir->irctl_lock);
return -EINVAL;
ret = -EINVAL;
goto out_locked;
}

/*
Expand Down Expand Up @@ -709,18 +709,23 @@ ssize_t lirc_dev_fop_read(struct file *file,
lirc_buffer_read(ir->buf, buf);
ret = copy_to_user((void *)buffer+written, buf,
ir->buf->chunk_size);
written += ir->buf->chunk_size;
if (!ret)
written += ir->buf->chunk_size;
else
ret = -EFAULT;
}
}

remove_wait_queue(&ir->buf->wait_poll, &wait);
set_current_state(TASK_RUNNING);

out_locked:
mutex_unlock(&ir->irctl_lock);

out_unlocked:
kfree(buf);
dev_dbg(ir->d.dev, LOGHEAD "read result = %s (%d)\n",
ir->d.name, ir->d.minor, ret ? "-EFAULT" : "OK", ret);
ir->d.name, ir->d.minor, ret ? "<fail>" : "<ok>", ret);

return ret ? ret : written;
}
Expand Down

0 comments on commit d3ff520

Please sign in to comment.