Module: xenomai-gch Branch: next Commit: ff2f8d9128a9cb272d0c71b67728f20bef6cca08 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=ff2f8d9128a9cb272d0c71b67728f20bef6cca08
Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org> Date: Sun Nov 8 13:22:35 2015 +0100 cobalt/wrappers: add wrappers for igb driver --- .../cobalt/include/asm-generic/xenomai/wrappers.h | 59 +++++++++++- kernel/cobalt/rtdm/Makefile | 3 +- kernel/cobalt/rtdm/wrappers.c | 101 ++++++++++++++++++++ 3 files changed, 157 insertions(+), 6 deletions(-) diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h index c742202..224924f 100644 --- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h +++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h @@ -39,26 +39,75 @@ * symbol, so that obsolete wrappers can be spotted. */ +#define XENO_BACKPORT(__sym) xeno_backport_ ##__sym + #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,13,0) +#include <linux/dma-mapping.h> +#include <linux/hwmon.h> + +#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; +} + +#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); + +#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,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 +#endif /* >= 3.14 */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) #define raw_cpu_ptr(v) __this_cpu_ptr(v) -#endif +#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 +#endif /* < 3.16 */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) #include <linux/netdevice.h> @@ -73,10 +122,10 @@ trace_seq_buffer_ptr(struct trace_seq *s) { return s->buffer + s->len; } -#endif +#endif /* < 3.17 */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) #define user_msghdr msghdr -#endif +#endif /* < 3.19 */ #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */ diff --git a/kernel/cobalt/rtdm/Makefile b/kernel/cobalt/rtdm/Makefile index 9ca7bac..ce215fe 100644 --- a/kernel/cobalt/rtdm/Makefile +++ b/kernel/cobalt/rtdm/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_XENOMAI) += xenomai.o xenomai-y := core.o \ device.o \ drvlib.o \ - fd.o + fd.o \ + wrappers.o ccflags-y += -I$(src)/.. diff --git a/kernel/cobalt/rtdm/wrappers.c b/kernel/cobalt/rtdm/wrappers.c new file mode 100644 index 0000000..b196138 --- /dev/null +++ b/kernel/cobalt/rtdm/wrappers.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2013 Hauke Mehrtens <ha...@hauke-m.de> + * Copyright (c) 2013 Hannes Frederic Sowa <han...@stressinduktion.org> + * Copyright (c) 2014 Luis R. Rodriguez <mcg...@do-not-panic.com> + * + * Backport functionality introduced in Linux 3.13. + * + * Copyright (c) 2014 Hauke Mehrtens <ha...@hauke-m.de> + * + * Backport functionality introduced in Linux 3.14. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/pci.h> +#include <linux/hwmon.h> +#include <asm/xenomai/wrappers.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) +#ifdef CONFIG_HWMON +struct device* +hwmon_device_register_with_groups(struct device *dev, const char *name, + void *drvdata, + const struct attribute_group **groups) +{ + struct device *hwdev; + + hwdev = hwmon_device_register(dev); + hwdev->groups = groups; + dev_set_drvdata(hwdev, drvdata); + return hwdev; +} + +static void devm_hwmon_release(struct device *dev, void *res) +{ + struct device *hwdev = *(struct device **)res; + + hwmon_device_unregister(hwdev); +} + +struct device * +devm_hwmon_device_register_with_groups(struct device *dev, const char *name, + void *drvdata, + const struct attribute_group **groups) +{ + struct device **ptr, *hwdev; + + if (!dev) + return ERR_PTR(-EINVAL); + + ptr = devres_alloc(devm_hwmon_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + hwdev = hwmon_device_register_with_groups(dev, name, drvdata, groups); + if (IS_ERR(hwdev)) + goto error; + + *ptr = hwdev; + devres_add(dev, ptr); + return hwdev; + +error: + devres_free(ptr); + return hwdev; +} +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