1 #ifndef LINUX_3_0_COMPAT_H
2 #define LINUX_3_0_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0))
8 #include <linux/rcupdate.h>
11 * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171
12 * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is
13 * called automatically. This is not implemented in older kernel
14 * versions so it will result in device wrong names.
16 static inline int register_netdevice_name(struct net_device *dev)
20 if (strchr(dev->name, '%')) {
21 err = dev_alloc_name(dev, dev->name);
26 return register_netdevice(dev);
29 #define register_netdevice(dev) register_netdevice_name(dev)
31 /* BCMA core, see drivers/bcma/ */
33 /* Broadcom's specific AMBA core, see drivers/bcma/ */
34 struct bcma_device_id {
40 #define BCMA_CORE(_manuf, _id, _rev, _class) \
41 { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, }
42 #define BCMA_CORETABLE_END \
45 #define BCMA_ANY_MANUF 0xFFFF
46 #define BCMA_ANY_ID 0xFFFF
47 #define BCMA_ANY_REV 0xFF
48 #define BCMA_ANY_CLASS 0xFF
49 #endif /* BCMA_CORE */
51 int mac_pton(const char *s, u8 *mac);
53 #ifndef CONFIG_COMPAT_RHEL_6_4
54 int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
55 int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
56 int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
57 int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
58 int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
59 int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
60 int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
61 int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
62 int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
63 int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
65 static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
67 return kstrtoull_from_user(s, count, base, res);
70 static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
72 return kstrtoll_from_user(s, count, base, res);
75 static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
77 return kstrtouint_from_user(s, count, base, res);
80 static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
82 return kstrtoint_from_user(s, count, base, res);
84 #endif /* CONFIG_COMPAT_RHEL_6_4 */
88 * This adds a nested function everywhere kfree_rcu() was called. This
89 * function frees the memory and is given as a function to call_rcu().
90 * The rcu callback could happen every time also after the module was
91 * unloaded and this will cause problems.
93 #define kfree_rcu(data, rcuhead) do { \
94 void __kfree_rcu_fn(struct rcu_head *rcu_head) \
97 ___ptr = container_of(rcu_head, typeof(*(data)), rcuhead);\
100 call_rcu(&(data)->rcuhead, __kfree_rcu_fn); \
107 * The define overwriting module_exit is based on the original module_exit
108 * which looks like this:
109 * #define module_exit(exitfn) \
110 * static inline exitcall_t __exittest(void) \
111 * { return exitfn; } \
112 * void cleanup_module(void) __attribute__((alias(#exitfn)));
114 * We replaced the call to the actual function exitfn() with a call to our
115 * function which calls the original exitfn() and then rcu_barrier()
117 * As a module will not be unloaded that ofter it should not have a big
118 * performance impact when rcu_barrier() is called on every module exit,
119 * also when no kfree_rcu() backport is used in that module.
122 #define module_exit(exitfn) \
123 static void __exit __exit_compat(void) \
128 void cleanup_module(void) __attribute__((alias("__exit_compat")));
132 #ifndef CONFIG_COMPAT_RHEL_6_4
134 * enum ethtool_phys_id_state - indicator state for physical identification
135 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
136 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
137 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
139 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
142 enum ethtool_phys_id_state {
148 #endif /* CONFIG_COMPAT_RHEL_6_4 */
150 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
152 #endif /* LINUX_3_0_COMPAT_H */