diff options
author | Ian Abbott | 2015-10-12 18:21:20 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2015-10-13 19:29:48 +0200 |
commit | 970679b04c4b2ae8aaede98e214449eb3e6e6b06 (patch) | |
tree | 3895f06cc877f4ab56313cb3350aca281b6b2119 /drivers/staging/comedi/comedi_fops.c | |
parent | staging: comedi: don't use mutex when polling file (diff) | |
download | kernel-qcow2-linux-970679b04c4b2ae8aaede98e214449eb3e6e6b06.tar.gz kernel-qcow2-linux-970679b04c4b2ae8aaede98e214449eb3e6e6b06.tar.xz kernel-qcow2-linux-970679b04c4b2ae8aaede98e214449eb3e6e6b06.zip |
staging: comedi: remain busy until read end-of-file
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>
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.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index fe25287c5688..bb2e0ae0e052 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2551,7 +2551,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; /* |