Revert some previous dumb changes with events. This should
authorDavid Schleef <ds@schleef.org>
Wed, 6 Feb 2002 09:04:55 +0000 (09:04 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 6 Feb 2002 09:04:55 +0000 (09:04 +0000)
get polling/select/regular read working again.  There is an
unresolved problem:  a normal select/read cycle on a device will
fail to show the end of acquisition.  One solution is to always
have the app read 0 bytes at the end of acquisition, but people
got confused when that was necessary.

comedi/comedi_fops.c

index 01c8b89e6778d73f2c042d49624858d3ac3bf7af..3581c0e2a98f3525077cab8040e1abd615ed68d7 100644 (file)
@@ -1290,8 +1290,8 @@ static unsigned int comedi_poll_v22(struct file *file, poll_table * wait)
                s = dev->read_subdev;
                async = s->async;
                if(s->busy){
-                       if((!s->subdev_flags&SDF_RUNNING) ||
-                          (async->buf_user_count < async->buf_int_count)){
+                       if((async->buf_user_count < async->buf_int_count) ||
+                          !(s->subdev_flags&SDF_RUNNING)){
                                mask |= POLLIN | POLLRDNORM;
                        }
                }
@@ -1300,8 +1300,9 @@ static unsigned int comedi_poll_v22(struct file *file, poll_table * wait)
                s = dev->write_subdev;
                async = s->async;
                if(s->busy){
-                       if((!s->subdev_flags&SDF_RUNNING) ||
-                          (async->buf_user_count < async->buf_int_count)){
+                       if(!(s->subdev_flags&SDF_RUNNING) ||
+                          (async->buf_user_count < async->buf_int_count +
+                             async->prealloc_bufsz)){
                                mask |= POLLOUT | POLLWRNORM;
                        }
                }
@@ -1519,9 +1520,6 @@ printk("m is %d\n",m);
 void do_become_nonbusy(comedi_device *dev,comedi_subdevice *s)
 {
        comedi_async *async = s->async;
-#if 0
-       printk("becoming non-busy\n");
-#endif
        /* we do this because it's useful for the non-standard cases */
        s->subdev_flags &= ~SDF_RUNNING;
 
@@ -1797,6 +1795,17 @@ void comedi_event(comedi_device *dev,comedi_subdevice *s,unsigned int mask)
 
        //DPRINTK("comedi_event %x\n",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;
+       }
+
+       s->async->events = 0;
        if(async->cb_mask&mask){
                if(s->runflags&SRF_USER){
 
@@ -1829,18 +1838,6 @@ void comedi_event(comedi_device *dev,comedi_subdevice *s,unsigned int mask)
                         * common, I'm not going to worry about it. */
                }
        }
-
-       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;
-       }
-
-       s->async->events = 0;
 }
 
 #if 0