Module: xenomai-3 Branch: stable-3.0.x Commit: 5baa56fe8f610d4e0b6d45416bd87bc3f3296ff4 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5baa56fe8f610d4e0b6d45416bd87bc3f3296ff4
Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org> Date: Sun Nov 8 16:57:02 2015 +0100 cobalt/wrappers: reverse wrappers order (latest kernel release first) --- .../cobalt/include/asm-generic/xenomai/wrappers.h | 96 ++++++++++---------- kernel/cobalt/rtdm/wrappers.c | 63 +++++++------ 2 files changed, 83 insertions(+), 76 deletions(-) diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h index 3230060..173315c 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,15 +35,48 @@ * - 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,17,0) +#include <linux/netdevice.h> -#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 */ +#undef alloc_netdev +#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \ + alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1) +#endif /* < 3.17 */ + +#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 */ + +#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> + +#define get_current_uuid() current_uid() + +#ifdef CONFIG_PCI +#define pci_enable_msix_range XENO_BACKPORT(pci_enable_msix_range) +#ifdef CONFIG_PCI_MSI +int pci_enable_msix_range(struct pci_dev *dev, + struct msix_entry *entries, + int minvec, int maxvec); +#else /* not pci msi */ +static inline int pci_enable_msix_range(struct pci_dev *dev, + struct msix_entry *entries, + int minvec, int maxvec) +{ return -ENOSYS; } +#endif /* not pci msi */ +#endif /* pci */ +#else /* >= 3.14 */ +#define get_current_uuid() from_kuid_munged(current_user_ns(), current_uid()) +#endif /* >= 3.14 */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) #include <linux/dma-mapping.h> @@ -78,43 +109,14 @@ devm_hwmon_device_register_with_groups(struct device *dev, const char *name, #endif /* hwmon */ #endif /* < 3,13 */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0) -#include <linux/pci.h> - -#define get_current_uuid() current_uid() - -#ifdef CONFIG_PCI -#define pci_enable_msix_range XENO_BACKPORT(pci_enable_msix_range) -#ifdef CONFIG_PCI_MSI -int pci_enable_msix_range(struct pci_dev *dev, - struct msix_entry *entries, - int minvec, int maxvec); -#else /* not pci msi */ -static inline int pci_enable_msix_range(struct pci_dev *dev, - struct msix_entry *entries, - int minvec, int maxvec) -{ return -ENOSYS; } -#endif /* not pci msi */ -#endif /* pci */ -#else /* >= 3.14 */ -#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,16,0) -#define smp_mb__before_atomic() smp_mb() -#define smp_mb__after_atomic() smp_mb() -#endif /* < 3.16 */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) -#include <linux/netdevice.h> +#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 */ -#undef alloc_netdev -#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \ - alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1) -#endif /* < 3.17 */ +#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