summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorH Hartley Sweeten2012-12-19 23:44:02 +0100
committerGreg Kroah-Hartman2013-01-07 23:25:49 +0100
commitc098c21a9d32f1cd828f23e617cb55909c75e7e2 (patch)
tree2e9e7ebd62a4cb218cc350fc5a4ea40d7c8acc2f /drivers/staging/comedi/comedi_fops.c
parentstaging: comedi: comedi_fops: don't export comedi_get_subdevice_runflags() (diff)
downloadkernel-qcow2-linux-c098c21a9d32f1cd828f23e617cb55909c75e7e2.tar.gz
kernel-qcow2-linux-c098c21a9d32f1cd828f23e617cb55909c75e7e2.tar.xz
kernel-qcow2-linux-c098c21a9d32f1cd828f23e617cb55909c75e7e2.zip
staging: comedi: comedi_fops: introduce comedi_is_subdevice_in_error()
Introduce, and use, a helper to check the subdevice runflags to see if the SRF_ERROR flag is set. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> 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.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 7d85f57f584b..eb962178b643 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -382,6 +382,13 @@ bool comedi_is_subdevice_running(struct comedi_subdevice *s)
}
EXPORT_SYMBOL_GPL(comedi_is_subdevice_running);
+static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s)
+{
+ unsigned runflags = comedi_get_subdevice_runflags(s);
+
+ return (runflags & SRF_ERROR) ? true : false;
+}
+
/*
This function restores a subdevice to an idle state.
*/
@@ -1908,12 +1915,10 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
if (!comedi_is_subdevice_running(s)) {
if (count == 0) {
- if (comedi_get_subdevice_runflags(s) &
- SRF_ERROR) {
+ if (comedi_is_subdevice_in_error(s))
retval = -EPIPE;
- } else {
+ else
retval = 0;
- }
do_become_nonbusy(dev, s);
}
break;
@@ -2015,12 +2020,10 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
if (n == 0) {
if (!comedi_is_subdevice_running(s)) {
do_become_nonbusy(dev, s);
- if (comedi_get_subdevice_runflags(s) &
- SRF_ERROR) {
+ if (comedi_is_subdevice_in_error(s))
retval = -EPIPE;
- } else {
+ else
retval = 0;
- }
break;
}
if (file->f_flags & O_NONBLOCK) {