Module: xenomai-forge
Branch: rtdm-api-waitqueues
Commit: 61150a92f2ebca24d37a614d6ac55609062b4e55
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=61150a92f2ebca24d37a614d6ac55609062b4e55

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Apr 12 17:35:51 2014 +0200

rtdm: introduce lock name as RTDM_LOCK_UNLOCK() argument

Mapping RTDM locks over native spinlocks will require to pass the lock
name to the native spinlock initializer, so make sure we receive it
from the RTDM client code.

This change is propagated to all driver stacks concerned (i.e. analogy
and CAN).

---

 include/analogy/os_facilities.h       |    5 ++++-
 include/cobalt/kernel/rtdm/driver.h   |    7 +++++--
 kernel/drivers/analogy/testing/fake.c |    2 +-
 kernel/drivers/can/rtcan_dev.c        |    2 +-
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/analogy/os_facilities.h b/include/analogy/os_facilities.h
index 0f99cbf..35f4155 100644
--- a/include/analogy/os_facilities.h
+++ b/include/analogy/os_facilities.h
@@ -85,7 +85,10 @@
 
 typedef rtdm_lock_t a4l_lock_t;
 
-#define A4L_LOCK_UNLOCKED RTDM_LOCK_UNLOCKED
+#define A4L_LOCK_UNLOCKED(__name) RTDM_LOCK_UNLOCKED(__name)
+
+#define DEFINE_A4L_LOCK(__name)                \
+       a4l_lock_t __name = A4L_LOCK_UNLOCKED(__name)
 
 #define a4l_lock_init(lock) rtdm_lock_init(lock)
 #define a4l_lock(lock) rtdm_lock_get(lock)
diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index bbcc6fb..77e0341 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -690,7 +690,10 @@ int rtdm_select_bind(int fd, rtdm_selector_t *selector,
 /**
  * Static lock initialisation
  */
-#define RTDM_LOCK_UNLOCKED     IPIPE_SPIN_LOCK_UNLOCKED
+#define RTDM_LOCK_UNLOCKED(__name)     IPIPE_SPIN_LOCK_UNLOCKED
+
+#define DEFINE_RTDM_LOCK(__name)               \
+       rtdm_lock_t __name = RTDM_LOCK_UNLOCKED(__name)
 
 /** Lock variable */
 typedef ipipe_spinlock_t rtdm_lock_t;
@@ -1443,7 +1446,7 @@ int rtdm_ratelimit(struct rtdm_ratelimit_state *rs, const 
char *func);
 
 #define DEFINE_RTDM_RATELIMIT_STATE(name, interval_init, burst_init)   \
        struct rtdm_ratelimit_state name = {                            \
-               .lock           = RTDM_LOCK_UNLOCKED,                   \
+               .lock           = RTDM_LOCK_UNLOCKED((name).lock),      \
                .interval       = interval_init,                        \
                .burst          = burst_init,                           \
        }
diff --git a/kernel/drivers/analogy/testing/fake.c 
b/kernel/drivers/analogy/testing/fake.c
index 3871cc5..a2390aa 100644
--- a/kernel/drivers/analogy/testing/fake.c
+++ b/kernel/drivers/analogy/testing/fake.c
@@ -116,7 +116,7 @@ static inline uint16_t ai_value_output(struct ai_priv *priv)
                0x8000, 0xa000, 0xc000, 0xffff
        };
        static unsigned int output_idx;
-       static a4l_lock_t output_lock = A4L_LOCK_UNLOCKED;
+       static DEFINE_A4L_LOCK(output_lock);
 
        unsigned long flags;
        unsigned int idx;
diff --git a/kernel/drivers/can/rtcan_dev.c b/kernel/drivers/can/rtcan_dev.c
index 3280587..5caea3a 100644
--- a/kernel/drivers/can/rtcan_dev.c
+++ b/kernel/drivers/can/rtcan_dev.c
@@ -34,7 +34,7 @@
 
 
 static struct rtcan_device *rtcan_devices[RTCAN_MAX_DEVICES];
-static rtdm_lock_t rtcan_devices_rt_lock = RTDM_LOCK_UNLOCKED;
+static DEFINE_RTDM_LOCK(rtcan_devices_rt_lock);
 
 static int rtcan_global_init_done;
 


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

Reply via email to