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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Sep  3 11:59:21 2012 +0200

wrappers, hal: simplify checks for pipeline core API

We may safely assume IPIPE_CORE_APIREV == 0 for legacy pipelines
(!CONFIG_IPIPE_CORE). Based on this assumption, this patch reworks
some conditionals to test for the API revision number only, removing
redundant checks for CONFIG_IPIPE_CORE.

---

 include/asm-arm/bits/timer.h     |    2 +-
 include/asm-generic/wrappers.h   |   23 +++++++++++------------
 include/asm-nios2/bits/timer.h   |    2 +-
 include/asm-powerpc/bits/timer.h |    2 +-
 include/asm-sh/bits/timer.h      |    2 +-
 include/asm-x86/bits/timer.h     |    2 +-
 ksrc/arch/arm/hal.c              |    4 ++--
 7 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/include/asm-arm/bits/timer.h b/include/asm-arm/bits/timer.h
index fcc17c1..916f5e9 100644
--- a/include/asm-arm/bits/timer.h
+++ b/include/asm-arm/bits/timer.h
@@ -29,7 +29,7 @@
 
 #include <asm/xenomai/arith.h>
 
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
 extern rthal_u32frac_t rthal_tsc_to_timer;
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index c508df7..20a95fa 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -25,6 +25,7 @@
 #error "Pure kernel header included from user-space!"
 #endif
 
+#include <linux/ipipe.h>
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -33,6 +34,10 @@
 #endif /* CONFIG_XENO_OPT_HOSTRT || __IPIPE_FEATURE_REQUEST_TICKDEV */
 #include <asm/io.h>
 
+#ifndef CONFIG_IPIPE_CORE
+#define IPIPE_CORE_APIREV  0
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
 #include <asm/system.h>
 #endif /* kernel < 3.4.0 */
@@ -424,23 +429,19 @@ static inline void *kzalloc(size_t size, int flags)
 #define pgprot_noncached(p) (p)
 #endif /* !pgprot_noncached */
 
-#ifdef CONFIG_IPIPE_CORE
 #if IPIPE_CORE_APIREV >= 2
 #define wrap_switch_mm(prev, next, tsk) \
        ipipe_switch_mm_head(prev, next, tsk)
-#else /* IPIPE_CORE_APIREV < 2 */
+#elif IPIPE_CORE_APIREV == 1
 #define wrap_switch_mm(prev, next, tsk) \
        __switch_mm(prev, next, tsk)
-#endif /* IPIPE_CORE_APIREV < 2 */
-#else /* !I-pipe core */
-#ifdef __IPIPE_FEATURE_HARDENED_SWITCHMM
+#elif defined(__IPIPE_FEATURE_HARDENED_SWITCHMM)
 #define wrap_switch_mm(prev, next, tsk) \
        __switch_mm(prev, next, tsk)
-#else /* !__IPIPE_FEATURE_HARDENED_SWITCHMM */
+#else
 #define wrap_switch_mm(prev, next, tsk) \
        switch_mm(prev, next, tsk)
-#endif /* !__IPIPE_FEATURE_HARDENED_SWITCHMM */
-#endif /* !I-pipe core */
+#endif
 
 #define wrap_enter_lazy_tlb(mm,task)   \
     enter_lazy_tlb(mm,task)
@@ -726,12 +727,10 @@ unsigned long vm_mmap(struct file *file, unsigned long 
addr,
 
 #endif /* LINUX_VERSION_CODE < 3.4.0 */
 
-#ifdef CONFIG_IPIPE_CORE
 #if IPIPE_CORE_APIREV >= 2
 #define wrap_select_timers(mask) ipipe_select_timers(mask)
-#else /* IPIPE_CORE_APIREV < 2 */
+#elif IPIPE_CORE_APIREV == 1
 #define wrap_select_timers(mask) ipipe_timers_request()
-#endif /* IPIPE_CORE_APIREV < 2 */
-#endif /* I-pipe core */
+#endif
 
 #endif /* _XENO_ASM_GENERIC_WRAPPERS_H */
diff --git a/include/asm-nios2/bits/timer.h b/include/asm-nios2/bits/timer.h
index ce95dfc..9fe1b1b 100644
--- a/include/asm-nios2/bits/timer.h
+++ b/include/asm-nios2/bits/timer.h
@@ -26,7 +26,7 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
 
        unsigned long d;
        d = rthal_imuldiv_ceil(delay, RTHAL_TIMER_FREQ, RTHAL_CLOCK_FREQ);
diff --git a/include/asm-powerpc/bits/timer.h b/include/asm-powerpc/bits/timer.h
index ade0b73..e7989cd 100644
--- a/include/asm-powerpc/bits/timer.h
+++ b/include/asm-powerpc/bits/timer.h
@@ -29,7 +29,7 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
        /*
         * Even though some architectures may use a 64 bits delay
         * here, we voluntarily limit to 32 bits, 4 billions ticks
diff --git a/include/asm-sh/bits/timer.h b/include/asm-sh/bits/timer.h
index d8e7981..7d5526c 100644
--- a/include/asm-sh/bits/timer.h
+++ b/include/asm-sh/bits/timer.h
@@ -26,7 +26,7 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
        unsigned long d;
        d = rthal_imuldiv_ceil(delay, RTHAL_TIMER_FREQ, RTHAL_CLOCK_FREQ);
        rthal_timer_program_shot(d);
diff --git a/include/asm-x86/bits/timer.h b/include/asm-x86/bits/timer.h
index 1836c81..9bd7c79 100644
--- a/include/asm-x86/bits/timer.h
+++ b/include/asm-x86/bits/timer.h
@@ -26,7 +26,7 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
        /*
         * Even though we may use a 64 bits delay here, we voluntarily
         * limit to 32 bits, 4 billions ticks should be enough for
diff --git a/ksrc/arch/arm/hal.c b/ksrc/arch/arm/hal.c
index 5e26ad5..2a48012 100644
--- a/ksrc/arch/arm/hal.c
+++ b/ksrc/arch/arm/hal.c
@@ -227,7 +227,7 @@ unsigned long rthal_timer_calibrate(void)
                for (j = 0; j < RTHAL_CALIBRATE_LOOPS; j++) {
                        rthal_read_tsc(start);
                        barrier();
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
                        rthal_timer_program_shot(
                                rthal_nodiv_imuldiv_ceil(delay, 
rthal_tsc_to_timer));
 #else
@@ -551,7 +551,7 @@ int rthal_arch_init(void)
        if (rthal_clockfreq_arg == 0)
                rthal_clockfreq_arg = rthal_get_clockfreq();
 
-#if !defined(CONFIG_IPIPE_CORE) || IPIPE_CORE_APIREV < 2
+#if IPIPE_CORE_APIREV < 2
        xnarch_init_u32frac(&rthal_tsc_to_timer,
                            rthal_timerfreq_arg, rthal_clockfreq_arg);
 #endif


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

Reply via email to