staging: comedi: comedi_fops: introduce comedi_is_subdevice_in_error()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 19 Dec 2012 22:44:02 +0000 (15:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Jan 2013 22:25:49 +0000 (14:25 -0800)
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>
drivers/staging/comedi/comedi_fops.c

index 7d85f57f584bc1baae7587cdcf8ac79cd2ced89c..eb962178b643d8d765214e9e683b28f57348a347 100644 (file)
@@ -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) {
This page took 0.027744 seconds and 5 git commands to generate.