Module: xenomai-2.5
Branch: master
Commit: 1e4f9f3524bfc8ad84f92dfba5cbfc7f07652e7f
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=1e4f9f3524bfc8ad84f92dfba5cbfc7f07652e7f

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sat Feb  6 22:57:50 2010 +0100

analogy: add a4l_flush_sync()

The function a4l_flush_sync() was introduced so as to fix a bad
management of events in the poll ioctl.

---

 include/analogy/os_facilities.h      |    1 +
 ksrc/drivers/analogy/os_facilities.c |   18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/analogy/os_facilities.h b/include/analogy/os_facilities.h
index 91e0183..3b0b1e1 100644
--- a/include/analogy/os_facilities.h
+++ b/include/analogy/os_facilities.h
@@ -179,6 +179,7 @@ typedef struct a4l_sync a4l_sync_t;
 
 int a4l_init_sync(a4l_sync_t * snc);
 void a4l_cleanup_sync(a4l_sync_t * snc);
+void a4l_flush_sync(a4l_sync_t * snc);
 int a4l_wait_sync(a4l_sync_t * snc, int rt);
 int a4l_timedwait_sync(a4l_sync_t * snc,
                       int rt, unsigned long long ns_timeout);
diff --git a/ksrc/drivers/analogy/os_facilities.c 
b/ksrc/drivers/analogy/os_facilities.c
index 620906e..589e4f5 100644
--- a/ksrc/drivers/analogy/os_facilities.c
+++ b/ksrc/drivers/analogy/os_facilities.c
@@ -184,6 +184,15 @@ out_wait:
        return ret;
 }
 
+void a4l_flush_sync(a4l_sync_t * snc)
+{
+       /* Clear the status bitfield */
+       snc->status = 0;
+
+       /* Flush the RTDM event */
+       rtdm_event_clear(&snc->rtdm_evt);
+}
+
 void a4l_signal_sync(a4l_sync_t * snc)
 {
        int hit = 0;
@@ -193,12 +202,15 @@ void a4l_signal_sync(a4l_sync_t * snc)
        /* a4l_signal_sync() is bound not to be called upon the right
           user process context; so, the status flags stores its mode.
           Thus the proper event signaling function is called */
-
-       if (test_and_clear_bit(__RT_WAITER, &snc->status))
+       if (test_and_clear_bit(__RT_WAITER, &snc->status)) {
                rtdm_event_signal(&snc->rtdm_evt);
+               hit++;
+       }
 
-       if (test_and_clear_bit(__NRT_WAITER, &snc->status))
+       if (test_and_clear_bit(__NRT_WAITER, &snc->status)) {
                rtdm_nrtsig_pend(&snc->nrt_sig);
+               hit++;
+       }
 
        if (hit == 0) {
                /* At first signaling, we may not know the proper way


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

Reply via email to