Xenomai  3.0.2
wrappers.h
1 /*
2  * Copyright (C) 2005-2012 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * Xenomai is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _COBALT_ASM_GENERIC_WRAPPERS_H
20 
21 #include <linux/version.h>
22 
23 #ifdef CONFIG_IPIPE_LEGACY
24 #error "CONFIG_IPIPE_LEGACY must be switched off"
25 #endif
26 
27 #define COBALT_BACKPORT(__sym) __cobalt_backport_ ##__sym
28 
29 /*
30  * To keep the #ifdefery as readable as possible, please:
31  *
32  * - keep the conditional structure flat, no nesting (e.g. do not nest
33  * the pre-3.11 conditions into the pre-3.14 ones).
34  * - group all wrappers which share the same condition.
35  * - identify the first kernel release for which the wrapper should
36  * be defined, instead of testing the existence of a preprocessor
37  * symbol, so that obsolete wrappers can be spotted.
38  * - put the newer wrappers in front, so that old wrappers can be removed
39  * without side effects on newer wrappers.
40  */
41 
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
43 #include <linux/netdevice.h>
44 
45 #undef alloc_netdev
46 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
47  alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
48 #endif /* < 3.17 */
49 
50 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
51 #define smp_mb__before_atomic() smp_mb()
52 #define smp_mb__after_atomic() smp_mb()
53 #endif /* < 3.16 */
54 
55 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
56 #define raw_cpu_ptr(v) __this_cpu_ptr(v)
57 #endif /* < 3.15 */
58 
59 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
60 #include <linux/pci.h>
61 
62 #ifdef CONFIG_PCI
63 #define pci_enable_msix_range \
64  COBALT_BACKPORT(pci_enable_msix_range)
65 #ifdef CONFIG_PCI_MSI
66 int pci_enable_msix_range(struct pci_dev *dev,
67  struct msix_entry *entries,
68  int minvec, int maxvec);
69 #else /* not pci msi */
70 static inline int pci_enable_msix_range(struct pci_dev *dev,
71  struct msix_entry *entries,
72  int minvec, int maxvec)
73 { return -ENOSYS; }
74 #endif /* not pci msi */
75 #endif /* pci */
76 #endif /* < 3.14 */
77 
78 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
79 #include <linux/dma-mapping.h>
80 #include <linux/hwmon.h>
81 
82 #define dma_set_mask_and_coherent \
83  COBALT_BACKPORT(dma_set_mask_and_coherent)
84 static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
85 {
86  int rc = dma_set_mask(dev, mask);
87  if (rc == 0)
88  dma_set_coherent_mask(dev, mask);
89  return rc;
90 }
91 
92 #ifdef CONFIG_HWMON
93 #define hwmon_device_register_with_groups \
94  COBALT_BACKPORT(hwmon_device_register_with_groups)
95 struct device *
96 hwmon_device_register_with_groups(struct device *dev, const char *name,
97  void *drvdata,
98  const struct attribute_group **groups);
99 
100 #define devm_hwmon_device_register_with_groups \
101  COBALT_BACKPORT(devm_hwmon_device_register_with_groups)
102 struct device *
103 devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
104  void *drvdata,
105  const struct attribute_group **groups);
106 #endif /* hwmon */
107 #endif /* < 3,13 */
108 
109 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
110 #define DEVICE_ATTR_RW(_name) __ATTR_RW(_name)
111 #define DEVICE_ATTR_RO(_name) __ATTR_RO(_name)
112 #define DEVICE_ATTR_WO(_name) __ATTR_WO(_name)
113 #endif /* < 3.11 */
114 
115 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
116 #error "Xenomai/cobalt requires Linux kernel 3.10 or above"
117 #endif /* < 3.10 */
118 
119 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
120 #include <linux/trace_seq.h>
121 
122 static inline unsigned char *
123 trace_seq_buffer_ptr(struct trace_seq *s)
124 {
125  return s->buffer + s->len;
126 }
127 #endif
128 
129 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
130 #define user_msghdr msghdr
131 #endif
132 
133 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
134 #define user_msghdr msghdr
135 #endif
136 
137 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */