Module: xenomai-gch
Branch: next
Commit: 2a524d27305ec24fd40cadaf536f650457b81ac4
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=2a524d27305ec24fd40cadaf536f650457b81ac4

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Nov  8 16:57:02 2015 +0100

cobalt/wrappers: revert wrappers order

---

 .../cobalt/include/asm-generic/xenomai/wrappers.h  |  116 ++++++++++----------
 kernel/cobalt/rtdm/wrappers.c                      |   63 ++++++-----
 2 files changed, 93 insertions(+), 86 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 224924f..d793d73 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -20,14 +20,12 @@
 
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
-#error "Xenomai/cobalt requires Linux kernel 3.10 or above"
-#endif
-
 #ifdef CONFIG_IPIPE_LEGACY
 #error "CONFIG_IPIPE_LEGACY must be switched off"
 #endif
 
+#define XENO_BACKPORT(__sym) xeno_backport_ ##__sym
+
 /*
  * To keep the #ifdefery as readable as possible, please:
  *
@@ -37,46 +35,37 @@
  * - identify the first kernel release for which the wrapper should
  *   be defined, instead of testing the existence of a preprocessor
  *   symbol, so that obsolete wrappers can be spotted.
+ * - put the newer wrappers in front, so that old wrappers can be removed
+ *   without side effects on newer wrappers.
  */
 
-#define XENO_BACKPORT(__sym) xeno_backport_ ##__sym
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+#define user_msghdr msghdr
+#endif /* < 3.19 */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
-#define DEVICE_ATTR_RW(_name)  __ATTR_RW(_name)
-#define DEVICE_ATTR_RO(_name)  __ATTR_RO(_name)
-#define DEVICE_ATTR_WO(_name)  __ATTR_WO(_name)
-#endif /* < 3.11 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#include <linux/netdevice.h>
+#include <linux/trace_seq.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
-#include <linux/dma-mapping.h>
-#include <linux/hwmon.h>
+#undef alloc_netdev
+#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
+       alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
 
-#define dma_set_mask_and_coherent \
-       XENO_BACKPORT(dma_set_mask_and_coherent)
-static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
+static inline unsigned char *
+trace_seq_buffer_ptr(struct trace_seq *s)
 {
-       int rc = dma_set_mask(dev, mask);
-       if (rc == 0)
-               dma_set_coherent_mask(dev, mask);
-       return rc;
+       return s->buffer + s->len;
 }
+#endif /* < 3.17 */
 
-#ifdef CONFIG_HWMON
-#define hwmon_device_register_with_groups \
-       XENO_BACKPORT(hwmon_device_register_with_groups)
-struct device *
-hwmon_device_register_with_groups(struct device *dev, const char *name,
-                               void *drvdata,
-                               const struct attribute_group **groups);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
+#define smp_mb__before_atomic()  smp_mb()
+#define smp_mb__after_atomic()   smp_mb()
+#endif /* < 3.16 */
 
-#define devm_hwmon_device_register_with_groups \
-       XENO_BACKPORT(devm_hwmon_device_register_with_groups)
-struct device *
-devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
-                               void *drvdata,
-                               const struct attribute_group **groups);
-#endif /* hwmon */
-#endif /* < 3,13 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
+#define raw_cpu_ptr(v) __this_cpu_ptr(v)
+#endif /* < 3.15 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 #include <linux/pci.h>
@@ -100,32 +89,45 @@ static inline int pci_enable_msix_range(struct pci_dev 
*dev,
 #define get_current_uuid() from_kuid_munged(current_user_ns(), current_uid())
 #endif /* >= 3.14 */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
-#define raw_cpu_ptr(v) __this_cpu_ptr(v)
-#endif /* < 3.15 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
+#include <linux/dma-mapping.h>
+#include <linux/hwmon.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
-#define smp_mb__before_atomic()  smp_mb()
-#define smp_mb__after_atomic()   smp_mb()
-#endif /* < 3.16 */
+#define dma_set_mask_and_coherent \
+       XENO_BACKPORT(dma_set_mask_and_coherent)
+static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
+{
+       int rc = dma_set_mask(dev, mask);
+       if (rc == 0)
+               dma_set_coherent_mask(dev, mask);
+       return rc;
+}
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
-#include <linux/netdevice.h>
-#include <linux/trace_seq.h>
+#ifdef CONFIG_HWMON
+#define hwmon_device_register_with_groups \
+       XENO_BACKPORT(hwmon_device_register_with_groups)
+struct device *
+hwmon_device_register_with_groups(struct device *dev, const char *name,
+                               void *drvdata,
+                               const struct attribute_group **groups);
 
-#undef alloc_netdev
-#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
-       alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
+#define devm_hwmon_device_register_with_groups \
+       XENO_BACKPORT(devm_hwmon_device_register_with_groups)
+struct device *
+devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
+                               void *drvdata,
+                               const struct attribute_group **groups);
+#endif /* hwmon */
+#endif /* < 3,13 */
 
-static inline unsigned char *
-trace_seq_buffer_ptr(struct trace_seq *s)
-{
-       return s->buffer + s->len;
-}
-#endif /* < 3.17 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
+#define DEVICE_ATTR_RW(_name)  __ATTR_RW(_name)
+#define DEVICE_ATTR_RO(_name)  __ATTR_RO(_name)
+#define DEVICE_ATTR_WO(_name)  __ATTR_WO(_name)
+#endif /* < 3.11 */
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
-#define user_msghdr msghdr
-#endif /* < 3.19 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
+#error "Xenomai/cobalt requires Linux kernel 3.10 or above"
+#endif /* < 3.10 */
 
 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */
diff --git a/kernel/cobalt/rtdm/wrappers.c b/kernel/cobalt/rtdm/wrappers.c
index b196138..d35bb3b 100644
--- a/kernel/cobalt/rtdm/wrappers.c
+++ b/kernel/cobalt/rtdm/wrappers.c
@@ -19,6 +19,40 @@
 #include <linux/hwmon.h>
 #include <asm/xenomai/wrappers.h>
 
+/*
+ * Same rules as kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+ * apply to reduce #ifdefery.
+ */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
+#ifdef CONFIG_PCI_MSI
+int pci_enable_msix_range(struct pci_dev *dev,
+                       struct msix_entry *entries,
+                       int minvec, int maxvec)
+{
+       int nvec = maxvec;
+       int rc;
+
+       if (maxvec < minvec)
+               return -ERANGE;
+
+       do {
+               rc = pci_enable_msix(dev, entries, nvec);
+               if (rc < 0) {
+                       return rc;
+               } else if (rc > 0) {
+                       if (rc < minvec)
+                               return -ENOSPC;
+                       nvec = rc;
+               }
+       } while (rc);
+
+       return nvec;
+}
+EXPORT_SYMBOL(pci_enable_msix_range);
+#endif
+#endif /* < 3.14 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
 #ifdef CONFIG_HWMON
 struct device*
@@ -70,32 +104,3 @@ error:
 EXPORT_SYMBOL_GPL(devm_hwmon_device_register_with_groups);
 #endif
 #endif /* < 3.13 */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
-#ifdef CONFIG_PCI_MSI
-int pci_enable_msix_range(struct pci_dev *dev,
-                       struct msix_entry *entries,
-                       int minvec, int maxvec)
-{
-       int nvec = maxvec;
-       int rc;
-
-       if (maxvec < minvec)
-               return -ERANGE;
-
-       do {
-               rc = pci_enable_msix(dev, entries, nvec);
-               if (rc < 0) {
-                       return rc;
-               } else if (rc > 0) {
-                       if (rc < minvec)
-                               return -ENOSPC;
-                       nvec = rc;
-               }
-       } while (rc);
-
-       return nvec;
-}
-EXPORT_SYMBOL(pci_enable_msix_range);
-#endif
-#endif /* < 3.14 */


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

Reply via email to