summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2014-10-30 13:42:31 +0100
committerGreg Kroah-Hartman2014-11-04 01:28:47 +0100
commit662c722b645b22782eecdddf324c3a64d303baf3 (patch)
treece907bd525fbef92a1bc0e0fde76c6866a9e3fab /drivers/staging/comedi/comedi_fops.c
parentstaging: comedi: don't allow write() on async command set up for "read" (diff)
downloadkernel-qcow2-linux-662c722b645b22782eecdddf324c3a64d303baf3.tar.gz
kernel-qcow2-linux-662c722b645b22782eecdddf324c3a64d303baf3.tar.xz
kernel-qcow2-linux-662c722b645b22782eecdddf324c3a64d303baf3.zip
staging: comedi: check command direction in poll() file operation
`comedi_poll()` handles the poll() file operation for comedi devices. If no asynchronous command has been set up on the current "read" subdevice, it sets the `POLLIN` and `POLLRDNORM` bits in the return value to indicate that the read() file operation would not block as it would return an error. Add a check so it also does that if the asynchronous command has been set up in the "write" direction as that also causes the read() file operation to return an error. Similarly, if no asynchronous command has need set up on the current "write" subdevice, it sets the `POLLOUT` and `POLLWRNORM` bits in the return value to indicate that the write() file operation would not block as it would return an error. Add a check so it also does that if the asynchronous command has been set up in the "read" direction as that also causes the write() file operation to return an error. 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.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 0ed6f1f00e7f..63afd78441f1 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2017,6 +2017,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
if (s && s->async) {
poll_wait(file, &s->async->wait_head, wait);
if (!s->busy || !comedi_is_subdevice_running(s) ||
+ (s->async->cmd.flags & CMDF_WRITE) ||
comedi_buf_read_n_available(s) > 0)
mask |= POLLIN | POLLRDNORM;
}
@@ -2028,6 +2029,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
poll_wait(file, &s->async->wait_head, wait);
comedi_buf_write_alloc(s, s->async->prealloc_bufsz);
if (!s->busy || !comedi_is_subdevice_running(s) ||
+ !(s->async->cmd.flags & CMDF_WRITE) ||
comedi_buf_write_n_allocated(s) >= bps)
mask |= POLLOUT | POLLWRNORM;
}