Xenomai  3.0.8
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/xenomai/wrappers.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 fold
33  * the pre-3.11 conditions into the pre-3.14 ones).
34  * - group all wrappers for a single kernel revision.
35  * - list conditional blocks in order of kernel release, latest first
36  * - identify the first kernel release for which the wrapper should
37  * be defined, instead of testing the existence of a preprocessor
38  * symbol, so that obsolete wrappers can be spotted.
39  */
40 
41 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
42 #define raw_copy_to_user(__to, __from, __n) __copy_to_user_inatomic(__to, __from, __n)
43 #define raw_copy_from_user(__to, __from, __n) __copy_from_user_inatomic(__to, __from, __n)
44 #define raw_put_user(__from, __to) __put_user_inatomic(__from, __to)
45 #define raw_get_user(__to, __from) __get_user_inatomic(__to, __from)
46 #endif
47 
48 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
49 #define in_ia32_syscall() (current_thread_info()->status & TS_COMPAT)
50 #endif
51 
52 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0)
53 #define cobalt_gpiochip_dev(__gc) ((__gc)->dev)
54 #else
55 #define cobalt_gpiochip_dev(__gc) ((__gc)->parent)
56 #endif
57 
58 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
59 #define cobalt_get_restart_block(p) (&task_thread_info(p)->restart_block)
60 #else
61 #define cobalt_get_restart_block(p) (&(p)->restart_block)
62 #endif
63 
64 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
65 #define user_msghdr msghdr
66 #endif
67 
68 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
69 #include <linux/netdevice.h>
70 
71 #undef alloc_netdev
72 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
73  alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
74 
75 #include <linux/trace_seq.h>
76 
77 static inline unsigned char *
78 trace_seq_buffer_ptr(struct trace_seq *s)
79 {
80  return s->buffer + s->len;
81 }
82 
83 #endif /* < 3.17 */
84 
85 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
86 #define smp_mb__before_atomic() smp_mb()
87 #define smp_mb__after_atomic() smp_mb()
88 #endif /* < 3.16 */
89 
90 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
91 #define raw_cpu_ptr(v) __this_cpu_ptr(v)
92 #endif /* < 3.15 */
93 
94 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
95 #include <linux/pci.h>
96 
97 #ifdef CONFIG_PCI
98 #define pci_enable_msix_range COBALT_BACKPORT(pci_enable_msix_range)
99 #ifdef CONFIG_PCI_MSI
100 int pci_enable_msix_range(struct pci_dev *dev,
101  struct msix_entry *entries,
102  int minvec, int maxvec);
103 #else /* !CONFIG_PCI_MSI */
104 static inline
105 int pci_enable_msix_range(struct pci_dev *dev,
106  struct msix_entry *entries,
107  int minvec, int maxvec)
108 {
109  return -ENOSYS;
110 }
111 #endif /* !CONFIG_PCI_MSI */
112 #endif /* CONFIG_PCI */
113 #endif /* < 3.14 */
114 
115 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
116 #include <linux/dma-mapping.h>
117 #include <linux/hwmon.h>
118 
119 #define dma_set_mask_and_coherent COBALT_BACKPORT(dma_set_mask_and_coherent)
120 static inline
121 int dma_set_mask_and_coherent(struct device *dev, u64 mask)
122 {
123  int rc = dma_set_mask(dev, mask);
124  if (rc == 0)
125  dma_set_coherent_mask(dev, mask);
126  return rc;
127 }
128 
129 #ifdef CONFIG_HWMON
130 #define hwmon_device_register_with_groups \
131  COBALT_BACKPORT(hwmon_device_register_with_groups)
132 struct device *
133 hwmon_device_register_with_groups(struct device *dev, const char *name,
134  void *drvdata,
135  const struct attribute_group **groups);
136 
137 #define devm_hwmon_device_register_with_groups \
138  COBALT_BACKPORT(devm_hwmon_device_register_with_groups)
139 struct device *
140 devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
141  void *drvdata,
142  const struct attribute_group **groups);
143 #endif /* !CONFIG_HWMON */
144 
145 #define reinit_completion(__x) INIT_COMPLETION(*(__x))
146 
147 #endif /* < 3.13 */
148 
149 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
150 #define DEVICE_ATTR_RW(_name) __ATTR_RW(_name)
151 #define DEVICE_ATTR_RO(_name) __ATTR_RO(_name)
152 #define DEVICE_ATTR_WO(_name) __ATTR_WO(_name)
153 #endif /* < 3.11 */
154 
155 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
156 #error "Xenomai/cobalt requires Linux kernel 3.10 or above"
157 #endif /* < 3.10 */
158 
159 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */