Xenomai 3.3.2
Loading...
Searching...
No Matches
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#define COBALT_BACKPORT(__sym) __cobalt_backport_ ##__sym
24
25/*
26 * To keep the #ifdefery as readable as possible, please:
27 *
28 * - keep the conditional structure flat, no nesting (e.g. do not fold
29 * the pre-3.11 conditions into the pre-3.14 ones).
30 * - group all wrappers for a single kernel revision.
31 * - list conditional blocks in order of kernel release, latest first
32 * - identify the first kernel release for which the wrapper should
33 * be defined, instead of testing the existence of a preprocessor
34 * symbol, so that obsolete wrappers can be spotted.
35 */
36
37#define DEFINE_PROC_OPS(__name, __open, __release, __read, __write) \
38 struct proc_ops __name = { \
39 .proc_open = (__open), \
40 .proc_release = (__release), \
41 .proc_read = (__read), \
42 .proc_write = (__write), \
43 .proc_lseek = seq_lseek, \
44}
45
46#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)
47#define IRQ_WORK_INIT(_func) (struct irq_work) { \
48 .flags = ATOMIC_INIT(0), \
49 .func = (_func), \
50}
51#endif
52
53#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0) && \
54 (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) || \
55 LINUX_VERSION_CODE < KERNEL_VERSION(5,10,220))
56#define close_fd(__ufd) __close_fd(current->files, __ufd)
57#endif
58
59#if LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) && \
60 (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) || \
61 LINUX_VERSION_CODE < KERNEL_VERSION(5,10,188))
62#define dev_addr_set(dev, addr) memcpy((dev)->dev_addr, addr, MAX_ADDR_LEN)
63#define eth_hw_addr_set(dev, addr) memcpy((dev)->dev_addr, addr, ETH_ALEN)
64#endif
65
66#if LINUX_VERSION_CODE < KERNEL_VERSION(5,17,0)
67#define pde_data(i) PDE_DATA(i)
68#endif
69
70#if LINUX_VERSION_CODE < KERNEL_VERSION(6,2,0)
71#define timer_delete_sync del_timer_sync
72#endif
73
74#if LINUX_VERSION_CODE < KERNEL_VERSION(6,3,0)
75#define spi_get_chipselect(spi, idx) ((spi)->chip_select)
76#define spi_get_csgpiod(spi, idx) ((spi)->cs_gpiod)
77#endif
78
79#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
80#define MAX_PAGE_ORDER MAX_ORDER
81#endif
82
83#if LINUX_VERSION_CODE < KERNEL_VERSION(6,10,0)
84#define __wrap_assign_str __assign_str
85#else
86#define __wrap_assign_str(dst, src) __assign_str(dst)
87#endif
88
89#if LINUX_VERSION_CODE < KERNEL_VERSION(6,10,0)
90#define mm_get_unmapped_area(__mm, __filp, __addr, __len, __pgoff, __flags) \
91 (__mm)->get_unmapped_area(__filp, __addr, __len, __pgoff, __flags)
92#endif
93
94#if LINUX_VERSION_CODE < KERNEL_VERSION(6,16,0)
95#define timer_container_of from_timer
96#endif
97
98#endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */