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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jul 17 17:20:12 2015 +0200

rtdm/waitqueue: fix error codes

---

 include/cobalt/kernel/rtdm/driver.h |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 4853ba9..80308ca 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -656,13 +656,28 @@ static inline void rtdm_waitqueue_destroy(struct 
rtdm_waitqueue *wq)
        xnsynch_destroy(&wq->wait);
 }
 
+static inline int __rtdm_dowait(struct rtdm_waitqueue *wq,
+                               nanosecs_rel_t timeout, xntmode_t timeout_mode)
+{
+       int ret;
+       
+       ret = xnsynch_sleep_on(&wq->wait, timeout, timeout_mode);
+       if (ret & XNBREAK)
+               return -EINTR;
+       if (ret & XNTIMEO)
+               return -ETIMEDOUT;
+       if (ret & XNRMID)
+               return -EIDRM;
+       return 0;
+}
+
 static inline int __rtdm_timedwait(struct rtdm_waitqueue *wq,
                                   nanosecs_rel_t timeout, rtdm_toseq_t *toseq)
 {
        if (toseq && timeout > 0)
-               return xnsynch_sleep_on(&wq->wait, *toseq, XN_ABSOLUTE);
+               return __rtdm_dowait(wq, *toseq, XN_ABSOLUTE);
 
-       return xnsynch_sleep_on(&wq->wait, timeout, XN_RELATIVE);
+       return __rtdm_dowait(wq, timeout, XN_RELATIVE);
 }
 
 #define rtdm_timedwait_condition_locked(__wq, __cond, __timeout, __toseq) \
@@ -677,8 +692,8 @@ static inline int __rtdm_timedwait(struct rtdm_waitqueue 
*wq,
        ({                                                              \
                int __ret = 0;                                          \
                while (__ret == 0 && !(__cond))                         \
-                       __ret = xnsynch_sleep_on(&(__wq)->wait,         \
-                                                XN_INFINITE, XN_RELATIVE); \
+                       __ret = __rtdm_dowait(__wq,                     \
+                                             XN_INFINITE, XN_RELATIVE); \
                __ret;                                                  \
        })
 
@@ -710,7 +725,7 @@ static inline int __rtdm_timedwait(struct rtdm_waitqueue 
*wq,
        })
 
 #define rtdm_wait(__wq)                                                        
\
-       xnsynch_sleep_on(&(__wq)->wait, XN_INFINITE, XN_RELATIVE)
+       __rtdm_dowait(__wq, XN_INFINITE, XN_RELATIVE)
 
 #define rtdm_wait_locked(__wq)  rtdm_wait(__wq)
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to