Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 353933
b: refs/heads/master
c: ca081b1
h: refs/heads/master
i:
  353931: c16a83f
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jan 7, 2013
1 parent 7c8edf5 commit 6db9d69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 30 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: 0e700923bf63b4afb7bb213f140d5a6e28c32aa6
refs/heads/master: ca081b1d7e2f355b54a6fa1e63f84b8ceb9597de
49 changes: 20 additions & 29 deletions trunk/drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1823,49 +1823,40 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_subdevice *read_subdev;
struct comedi_subdevice *write_subdev;
struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev;
struct comedi_device *dev = comedi_dev_from_minor(minor);
struct comedi_subdevice *s;

if (info == NULL)
return -ENODEV;
dev = info->device;
if (dev == NULL)
if (!dev)
return -ENODEV;

mutex_lock(&dev->mutex);

if (!dev->attached) {
DPRINTK("no driver configured on comedi%i\n", dev->minor);
mutex_unlock(&dev->mutex);
return 0;
goto done;
}

mask = 0;
read_subdev = comedi_read_subdevice(info);
if (read_subdev) {
poll_wait(file, &read_subdev->async->wait_head, wait);
if (!read_subdev->busy
|| comedi_buf_read_n_available(read_subdev->async) > 0
|| !(comedi_get_subdevice_runflags(read_subdev) &
SRF_RUNNING)) {
s = comedi_read_subdevice(info);
if (s) {
poll_wait(file, &s->async->wait_head, wait);
if (!s->busy || !(comedi_get_subdevice_runflags(s) & SRF_RUNNING) ||
comedi_buf_read_n_available(s->async) > 0)
mask |= POLLIN | POLLRDNORM;
}
}
write_subdev = comedi_write_subdevice(info);
if (write_subdev) {
poll_wait(file, &write_subdev->async->wait_head, wait);
comedi_buf_write_alloc(write_subdev->async,
write_subdev->async->prealloc_bufsz);
if (!write_subdev->busy
|| !(comedi_get_subdevice_runflags(write_subdev) &
SRF_RUNNING)
|| comedi_buf_write_n_allocated(write_subdev->async) >=
bytes_per_sample(write_subdev->async->subdevice)) {

s = comedi_write_subdevice(info);
if (s) {
unsigned int bps = bytes_per_sample(s->async->subdevice);

poll_wait(file, &s->async->wait_head, wait);
comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz);
if (!s->busy || !(comedi_get_subdevice_runflags(s) & SRF_RUNNING) ||
comedi_buf_write_n_allocated(s->async) >= bps)
mask |= POLLOUT | POLLWRNORM;
}
}

done:
mutex_unlock(&dev->mutex);
return mask;
}
Expand Down

0 comments on commit 6db9d69

Please sign in to comment.