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


Groups > linux.kernel > #1244883

[PATCH 01/10] staging: comedi: remain busy until read end-of-file

From Ian Abbott <abbotti@mev.co.uk>
Newsgroups linux.kernel
Subject [PATCH 01/10] staging: comedi: remain busy until read end-of-file
Date 2015-10-12 18:30 +0200
Message-ID <qiO95-4kn-35@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 a COMEDI subdevice is busy handling an asynchronous command in the
"read" direction, then after the command has terminated itself, the
"read" file operation handler, `comedi_read()` should keep the subdevice
busy until all available data has been read and it has returned 0 to
indicate an "end-of-file" condition.  Currently, it has a bug where it
can mark the subdevice as non-busy even when returning a non-zero count.
The bug is slightly hidden because the next "read" will return 0 because
the subdevice is no longer busy.  Fix it by checking the return count is
0 before deciding to mark the subdevice as non-busy.

The call to `comedi_is_subdevice_idle()` is superfluous as the
`become_nonbusy` variable will have been set to `true` when considering
becoming non-busy.  Strictly speaking, checking the return count is
superfluous too, as `become_nonbusy` doesn't get set to `true` unless
the count is 0, but check the return count anyway to make the intention
clearer.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 drivers/staging/comedi/comedi_fops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index ef4b58b..f533113 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2550,7 +2550,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
 	}
 	remove_wait_queue(&async->wait_head, &wait);
 	set_current_state(TASK_RUNNING);
-	if (become_nonbusy || comedi_is_subdevice_idle(s)) {
+	if (become_nonbusy && count == 0) {
 		struct comedi_subdevice *new_s;
 
 		/*
-- 
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