]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/staging/comedi/comedi_fops.c
Staging: comedi: COMEDI_BUFINFO with no async - report no bytes read or written
[net-next-2.6.git] / drivers / staging / comedi / comedi_fops.c
index aced00e5cd107ae03b7c5e4edc81f1135aa711cc..75256251250d75cc97858bab1c7575ac5c52119b 100644 (file)
@@ -584,6 +584,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
                bi.buf_read_ptr = 0;
                bi.buf_write_count = 0;
                bi.buf_read_count = 0;
+               bi.bytes_read = 0;
+               bi.bytes_written = 0;
                goto copyback;
        }
 
@@ -1576,6 +1578,19 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
        while (nbytes > 0 && !retval) {
                set_current_state(TASK_INTERRUPTIBLE);
 
+               if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) {
+                       if (count == 0) {
+                               if (comedi_get_subdevice_runflags(s) &
+                                       SRF_ERROR) {
+                                       retval = -EPIPE;
+                               } else {
+                                       retval = 0;
+                               }
+                               do_become_nonbusy(dev, s);
+                       }
+                       break;
+               }
+
                n = nbytes;
 
                m = n;
@@ -1588,16 +1603,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
                        n = m;
 
                if (n == 0) {
-                       if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) {
-                               if (comedi_get_subdevice_runflags(s) &
-                                   SRF_ERROR) {
-                                       retval = -EPIPE;
-                               } else {
-                                       retval = 0;
-                               }
-                               do_become_nonbusy(dev, s);
-                               break;
-                       }
                        if (file->f_flags & O_NONBLOCK) {
                                retval = -EAGAIN;
                                break;