Module: xenomai-abe
Branch: analogy
Commit: d558760aab95add2e32b020e8e770360e5c73ce6
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=d558760aab95add2e32b020e8e770360e5c73ce6

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sat Feb  6 23:00:54 2010 +0100

analogy: read() and poll() return no more -ENOENT when acquisition is over

---

 ksrc/drivers/analogy/buffer.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c
index dba2e53..0c66b4a 100644
--- a/ksrc/drivers/analogy/buffer.c
+++ b/ksrc/drivers/analogy/buffer.c
@@ -670,10 +670,17 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t 
nbytes)
                if (tmp_cnt > nbytes - count)
                        tmp_cnt = nbytes - count;
 
-               if ((ret < 0 && ret != -ENOENT) ||
-                   (ret == -ENOENT && tmp_cnt == 0)) {
+               /* We check whether there is an error */
+               if (ret < 0 && ret != -ENOENT) {
                        a4l_cancel_transfer(cxt, idx_subd);
                        count = ret;
+                       goto out_a4l_read;                      
+               }
+               
+               /* We check whether the acquisition is over */
+               if (ret == -ENOENT && tmp_cnt == 0) {
+                       a4l_cancel_transfer(cxt, idx_subd);
+                       count = 0;
                        goto out_a4l_read;
                }
 
@@ -711,7 +718,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t 
nbytes)
                }
                /* If the acquisition is not over, we must not
                   leave the function without having read a least byte */
-               else if (ret != -ENOENT) {
+               else {
                        ret = a4l_wait_sync(&(buf->sync), a4l_test_rt());
                        if (ret < 0) {
                                if (ret == -ERESTARTSYS)
@@ -897,8 +904,9 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg)
        }
 
        buf = dev->transfer.bufs[poll.idx_subd];
-
+       
        /* Checks the buffer events */
+       a4l_flush_sync(&buf->sync);
        ret = __handle_event(buf);
 
        /* Retrieves the data amount to compute 
@@ -908,14 +916,17 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg)
 
                tmp_cnt = __count_to_get(buf);
 
-               /* If some error occured... */
-               if ((ret < 0 && ret != -ENOENT) ||
-                   /* ...or if we reached the end of the input transfer... */
-                   (ret == -ENOENT && tmp_cnt == 0)) {
-                       /* ...cancel the transfer */
+               /* Check if some error occured */
+               if (ret < 0 && ret != -ENOENT) {
                        a4l_cancel_transfer(cxt, poll.idx_subd);
                        return ret;
                }
+
+               /* Check whether the acquisition is over */
+               if (ret == -ENOENT && tmp_cnt == 0) {
+                       a4l_cancel_transfer(cxt, poll.idx_subd);
+                       return 0;
+               }
        } else {
 
                /* If some error was detected, cancel the transfer */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to