summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2015-10-12 18:21:21 +0200
committerGreg Kroah-Hartman2015-10-13 19:29:48 +0200
commit09d6b9a9ddbbdbf4e45f553fa4405aeacfd12e47 (patch)
tree223956be22eac8c278f30cb08ab8d6f77afb2a56 /drivers/staging/comedi/comedi_fops.c
parentstaging: comedi: remain busy until read end-of-file (diff)
downloadkernel-qcow2-linux-09d6b9a9ddbbdbf4e45f553fa4405aeacfd12e47.tar.gz
kernel-qcow2-linux-09d6b9a9ddbbdbf4e45f553fa4405aeacfd12e47.tar.xz
kernel-qcow2-linux-09d6b9a9ddbbdbf4e45f553fa4405aeacfd12e47.zip
staging: comedi: don't consider "unmunged" data when becoming non-busy
If an asynchronous "read" command is no longer running but the subdevice is still busy, it becomes non-busy once there is no more data available in the buffer. Some or all of the data written to the buffer might not have been "munged" yet, and it cannot be read until it has been munged by the writer. However, since the command is no longer running, we cannot expect any remaining unmunged data to get munged so we should ignore it. Call `comedi_buf_read_n_available()` to check the amount of munged data available to be read, replacing the call to `comedi_buf_n_bytes_ready()` which checked the amount of written (but possibly not yet munged) data available to be read. This affects both the "read" file operation (done in `comedi_read()`) and the `COMEDI_BUFINFO` ioctl handling (done in `do_bufinfo_ioctl()`). (The latter is used when data is transferred directly through the mmapped buffer instead of via the "read" file operation.) Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> 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, 3 insertions, 2 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index bb2e0ae0e052..c74c50a6e52d 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1146,7 +1146,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
comedi_buf_read_free(s, bi.bytes_read);
if (comedi_is_subdevice_idle(s) &&
- comedi_buf_n_bytes_ready(s) == 0) {
+ comedi_buf_read_n_available(s) == 0) {
do_become_nonbusy(dev, s);
}
}
@@ -2571,7 +2571,8 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
new_s = comedi_file_read_subdevice(file);
if (dev->attached && old_detach_count == dev->detach_count &&
s == new_s && new_s->async == async) {
- if (become_nonbusy || comedi_buf_n_bytes_ready(s) == 0)
+ if (become_nonbusy ||
+ comedi_buf_read_n_available(s) == 0)
do_become_nonbusy(dev, s);
}
mutex_unlock(&dev->mutex);