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

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 9aa0637..3bf7f2b 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -688,7 +688,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;
@@ -1441,7 +1444,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 c3e9e5e..10d3a53 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