For read and write, check if command still running in non-blocking mode as well.
authorIan Abbott <abbotti@mev.co.uk>
Wed, 5 Dec 2007 17:02:01 +0000 (17:02 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Wed, 5 Dec 2007 17:02:01 +0000 (17:02 +0000)
comedi/comedi_fops.c

index e686a1786dea48f2649d10811b2e4b4ac635989a..eb0347b342d224bb0aa024d588e2c1e8e5a59df3 100644 (file)
@@ -1459,10 +1459,6 @@ static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes,
                        n = m;
 
                if (n == 0) {
-                       if (file->f_flags & O_NONBLOCK) {
-                               retval = -EAGAIN;
-                               break;
-                       }
                        if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) {
                                if (comedi_get_subdevice_runflags(s) &
                                        SRF_ERROR) {
@@ -1473,6 +1469,10 @@ static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes,
                                do_become_nonbusy(dev, s);
                                break;
                        }
+                       if (file->f_flags & O_NONBLOCK) {
+                               retval = -EAGAIN;
+                               break;
+                       }
                        if (signal_pending(current)) {
                                retval = -ERESTARTSYS;
                                break;
@@ -1545,10 +1545,6 @@ static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes,
                        n = m;
 
                if (n == 0) {
-                       if (file->f_flags & O_NONBLOCK) {
-                               retval = -EAGAIN;
-                               break;
-                       }
                        if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) {
                                do_become_nonbusy(dev, s);
                                if (comedi_get_subdevice_runflags(s) &
@@ -1559,6 +1555,10 @@ static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes,
                                }
                                break;
                        }
+                       if (file->f_flags & O_NONBLOCK) {
+                               retval = -EAGAIN;
+                               break;
+                       }
                        if (signal_pending(current)) {
                                retval = -ERESTARTSYS;
                                break;