diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2010-05-19 12:22:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-06-04 16:38:53 -0400 |
commit | d261154057c27f6c1d256b6198b0ad08733f1758 (patch) | |
tree | 34c298f6a4390675b1e87a17893793d7e2925f1d /drivers | |
parent | ee4063fa6bd801fa6ea045f23a2934db009b3dac (diff) |
Staging: comedi: don't write to buffer if command finished
For write(), any data copied to the data buffer after the previously
set up streaming acquisition command has finished won't be used, but a
non-empty write() does not currently return 0 (or -EPIPE on error) after
the command has finished until the data buffer has been filled up.
Change this behavior to return 0 (or -EPIPE) any time after the command
has finished, without bothering to fill up the buffer with more useless
data.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index aced00e5cd10..39ed22b80229 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c | |||
@@ -1576,6 +1576,19 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, | |||
1576 | while (nbytes > 0 && !retval) { | 1576 | while (nbytes > 0 && !retval) { |
1577 | set_current_state(TASK_INTERRUPTIBLE); | 1577 | set_current_state(TASK_INTERRUPTIBLE); |
1578 | 1578 | ||
1579 | if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) { | ||
1580 | if (count == 0) { | ||
1581 | if (comedi_get_subdevice_runflags(s) & | ||
1582 | SRF_ERROR) { | ||
1583 | retval = -EPIPE; | ||
1584 | } else { | ||
1585 | retval = 0; | ||
1586 | } | ||
1587 | do_become_nonbusy(dev, s); | ||
1588 | } | ||
1589 | break; | ||
1590 | } | ||
1591 | |||
1579 | n = nbytes; | 1592 | n = nbytes; |
1580 | 1593 | ||
1581 | m = n; | 1594 | m = n; |
@@ -1588,16 +1601,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, | |||
1588 | n = m; | 1601 | n = m; |
1589 | 1602 | ||
1590 | if (n == 0) { | 1603 | if (n == 0) { |
1591 | if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) { | ||
1592 | if (comedi_get_subdevice_runflags(s) & | ||
1593 | SRF_ERROR) { | ||
1594 | retval = -EPIPE; | ||
1595 | } else { | ||
1596 | retval = 0; | ||
1597 | } | ||
1598 | do_become_nonbusy(dev, s); | ||
1599 | break; | ||
1600 | } | ||
1601 | if (file->f_flags & O_NONBLOCK) { | 1604 | if (file->f_flags & O_NONBLOCK) { |
1602 | retval = -EAGAIN; | 1605 | retval = -EAGAIN; |
1603 | break; | 1606 | break; |