]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: don't allocate buffer space when polling for write
authorIan Abbott <abbotti@mev.co.uk>
Fri, 9 Oct 2015 11:26:50 +0000 (12:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Oct 2015 17:28:40 +0000 (10:28 -0700)
When handling the "poll" file operation and checking for `POLLOUT`,
don't allocate space from the buffer for writing, just check that space
is available for writing.  That check is done after checking that an
asynchronous "write" command is running on the subdevice.  Allocating
the buffer space before checking a "write" command is running can cause
problems if the subdevice supports commands in either direction and
currently has an active "read" command.

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>
drivers/staging/comedi/comedi_fops.c

index bd124815c06a9b8055f856d10b45c828ceb6ae6b..42f6971c8061d4a00eb7edc96d5c4c62d3fe3300 100644 (file)
@@ -2287,10 +2287,9 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
 
                if (s != s_read)
                        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)
+                   comedi_buf_write_n_available(s) >= bps)
                        mask |= POLLOUT | POLLWRNORM;
        }