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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Nov  8 13:22:35 2015 +0100

cobalt/wrappers: add wrappers for igb driver

---

 kernel/cobalt/Makefile                             |    1 +
 kernel/cobalt/compat.c                             |  101 ++++++++++++++++++++
 .../cobalt/include/asm-generic/xenomai/wrappers.h  |   47 ++++++++-
 3 files changed, 144 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile
index 6e1cebe..d2f9592 100644
--- a/kernel/cobalt/Makefile
+++ b/kernel/cobalt/Makefile
@@ -4,6 +4,7 @@ xenomai-y :=    apc.o           \
                arith.o         \
                bufd.o          \
                clock.o         \
+               compat.o        \
                heap.o          \
                init.o          \
                intr.o          \
diff --git a/kernel/cobalt/compat.c b/kernel/cobalt/compat.c
new file mode 100644
index 0000000..0d098ad
--- /dev/null
+++ b/kernel/cobalt/compat.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, void *vgroups)
+{
+       const struct attribute_group **groups = vgroups;
+       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, void *vgroups)
+{
+       const struct attribute_group **groups = vgroups;
+       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(void *vdev, void *ventries, int minvec, int maxvec)
+{
+       struct pci_dev *dev = vdev;
+       struct msix_entry *entries = ventries;
+       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 */
diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index c742202..2bf6430 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -39,26 +39,63 @@
  *   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)
+#define dma_set_mask_and_coherent(dev, mask)                   \
+       ({                                                      \
+               int __rc = dma_set_mask(dev, mask);             \
+               if (__rc == 0)                                  \
+                       dma_set_coherent_mask(dev, mask);       \
+               __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, void *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, void *groups);
+#endif /* hwmon */
+#endif /* < 3,13 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 #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(void *dev, void *entries, int minvec, int maxvec);
+#else /* not pci msi */
+static inline int pci_enable_msix_range(void *dev,
+                                       void *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 +110,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 */


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

Reply via email to