From: Frank Mori Hess Date: Thu, 18 Oct 2001 23:16:58 +0000 (+0000) Subject: read now returns -EIO (once) at end of data stream if aquisition was terminated by X-Git-Tag: r0_7_61~41 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=28fce7293078346d071681b1ddbc5d6bc38e5222;p=comedi.git read now returns -EIO (once) at end of data stream if aquisition was terminated by an error, returns 0 if aquisition terminated normally. --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index b1375201..297b699f 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -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; + } } /* diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h index 44cfff66..bf229398 100644 --- a/include/linux/comedidev.h +++ b/include/linux/comedidev.h @@ -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