summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorH Hartley Sweeten2014-06-20 19:58:28 +0200
committerGreg Kroah-Hartman2014-06-27 02:00:44 +0200
commitf4f3f7cf27e7ae015672b59ec40c7deabeaf5d2e (patch)
tree615d870861548b465c1ae279c94f89407305647f /drivers/staging/comedi/comedi_fops.c
parentstaging: comedi: ke_counter: expose clock source options to user space (diff)
downloadkernel-qcow2-linux-f4f3f7cf27e7ae015672b59ec40c7deabeaf5d2e.tar.gz
kernel-qcow2-linux-f4f3f7cf27e7ae015672b59ec40c7deabeaf5d2e.tar.xz
kernel-qcow2-linux-f4f3f7cf27e7ae015672b59ec40c7deabeaf5d2e.zip
staging: comedi: introduce comedi_buf_n_bytes_ready()
Introduce an inline helper to return the number of bytes that are ready to read from the comedi_async buffer. Use the helper in the comedi drivers that currently do the calculation as part of the (*poll) operation. Also, use the helper in comedi_fops where the calculation is used as part of the subdevice going nonbusy. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r--drivers/staging/comedi/comedi_fops.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index c54ed42f8310..d4904cc50f77 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -997,7 +997,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
comedi_buf_read_free(s, bi.bytes_read);
if (comedi_is_subdevice_idle(s) &&
- async->buf_write_count == async->buf_read_count) {
+ comedi_buf_n_bytes_ready(s) == 0) {
do_become_nonbusy(dev, s);
}
}
@@ -2303,8 +2303,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
new_s = comedi_read_subdevice(dev, minor);
if (dev->attached && old_detach_count == dev->detach_count &&
s == new_s && new_s->async == async) {
- if (become_nonbusy ||
- async->buf_read_count - async->buf_write_count == 0)
+ if (become_nonbusy || comedi_buf_n_bytes_ready(s) == 0)
do_become_nonbusy(dev, s);
}
mutex_unlock(&dev->mutex);