Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1244887

[PATCH 02/10] staging: comedi: don't consider "unmunged" data when becoming non-busy

From Ian Abbott <abbotti@mev.co.uk>
Newsgroups linux.kernel
Subject [PATCH 02/10] staging: comedi: don't consider "unmunged" data when becoming non-busy
Date 2015-10-12 18:30 +0200
Message-ID <qiO95-4kn-49@gated-at.bofh.it> (permalink)
References <qiO94-4kn-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/staging/comedi/comedi_fops.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index f533113..89e8e87 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);
 		}
 	}
@@ -2570,7 +2570,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);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/10] staging: comedi: some comedi_read() changes Ian Abbott <abbotti@mev.co.uk> - 2015-10-12 18:30 +0200
  [PATCH 01/10] staging: comedi: remain busy until read end-of-file Ian Abbott <abbotti@mev.co.uk> - 2015-10-12 18:30 +0200
  [PATCH 07/10] staging: comedi: remove superfluous retval = 0 in comedi_read() Ian Abbott <abbotti@mev.co.uk> - 2015-10-12 18:30 +0200
  [PATCH 02/10] staging: comedi: don't consider "unmunged" data when becoming non-busy Ian Abbott <abbotti@mev.co.uk> - 2015-10-12 18:30 +0200
  [PATCH 04/10] staging: comedi: make some variables unsigned in comedi_read() Ian Abbott <abbotti@mev.co.uk> - 2015-10-12 18:30 +0200
  [PATCH 03/10] staging: comedi: do extra checks for becoming non-busy for "read" Ian Abbott <abbotti@mev.co.uk> - 2015-10-12 18:30 +0200
  RE: [PATCH 00/10] staging: comedi: some comedi_read() changes Hartley Sweeten <HartleyS@visionengravers.com> - 2015-10-12 19:10 +0200

csiph-web