read now returns -EIO (once) at end of data stream if aquisition was terminated by
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 18 Oct 2001 23:16:58 +0000 (23:16 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 18 Oct 2001 23:16:58 +0000 (23:16 +0000)
an error, returns 0 if aquisition terminated normally.

comedi/comedi_fops.c
include/linux/comedidev.h

index b13752013f766c73a1d0dcebe8fd8f6ae19f2b94..297b699f39ee403af47c64aa86d5bcf5c21144f8 100644 (file)
@@ -1489,7 +1489,11 @@ printk("m is %d\n",m);
                if(n==0){
                        if(!(s->subdev_flags&SDF_RUNNING)){
                                do_become_nonbusy(dev,s);
-                               retval=-EINVAL;
+                               if(s->runflags & SRF_ERROR){
+                                       retval = -EIO;
+                               }else{
+                                       retval = 0;
+                               }
                                break;
                        }
                        if(file->f_flags&O_NONBLOCK){
@@ -1511,7 +1515,7 @@ printk("m is %d\n",m);
                if(async->buf_int_count - async->buf_user_count > async->data_len){
                        async->buf_user_count = async->buf_int_count;
                        async->buf_user_ptr = async->buf_int_ptr;
-                       retval=-EINVAL;
+                       retval=-EIO;
                        do_cancel(dev, dev->read_subdev);
                        DPRINTK("buffer overrun\n");
                        break;
@@ -1529,7 +1533,9 @@ printk("m is %d\n",m);
                buf+=n;
                break;  /* makes device work like a pipe */
        }
-       if(!(s->subdev_flags&SDF_RUNNING) && async->buf_int_count-async->buf_user_count==0){
+       if(!(s->subdev_flags&SDF_RUNNING) &&
+               !(s->runflags & SRF_ERROR))
+       {
                do_become_nonbusy(dev,s);
        }
        current->state=TASK_RUNNING;
@@ -1876,6 +1882,12 @@ void comedi_event(comedi_device *dev,comedi_subdevice *s,unsigned int mask)
        if(mask&COMEDI_CB_EOA){
                s->subdev_flags &= ~SDF_RUNNING;
        }
+
+       /* remember if an error event has occured, so an error
+        * can be returned the next time the user does a read() */
+       if(mask & COMEDI_CB_ERROR){
+               s->runflags |= SRF_ERROR;
+       }
 }
 
 /*
index 44cfff663306aca07289c93ce14270e8ef989a44..bf229398d7f0577b6c81ef7840a8eec191372365 100644 (file)
@@ -215,10 +215,11 @@ void stop_polling(comedi_device *);
 void comedi_proc_init(void);
 void comedi_proc_cleanup(void);
 
-
+// subdevice runflags
 #define SRF_USER               0x00000001
 #define SRF_RT                 0x00000002
-
+// indicates an COMEDI_CB_ERROR event has occurred since the last command was started
+#define SRF_ERROR              0x00000004
 
 /*
    various internal comedi functions