cdf397d9ade203c09ec8312bbd3ce02053c5d8fc
[feed/routing.git] / batman-adv / files / compat-hacks.h
1 /* Please avoid adding hacks here - instead add it to mac80211/backports.git */
2
3 #undef CONFIG_MODULE_STRIPPED
4
5 #include <linux/version.h> /* LINUX_VERSION_CODE */
6 #include <linux/types.h>
7
8 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
9
10 #define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
11
12 #endif /* < KERNEL_VERSION(4, 1, 0) */
13
14 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
15
16 #include <linux/netdevice.h>
17
18 #define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
19 BUILD_BUG_ON(upper_priv != NULL); \
20 BUILD_BUG_ON(upper_info != NULL); \
21 netdev_set_master(dev, upper_dev); \
22 })
23
24 #elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
25
26 #include <linux/netdevice.h>
27
28 #define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
29 BUILD_BUG_ON(upper_priv != NULL); \
30 BUILD_BUG_ON(upper_info != NULL); \
31 netdev_master_upper_dev_link(dev, upper_dev); \
32 })
33
34 #endif /* < KERNEL_VERSION(4, 5, 0) */
35
36
37 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
38
39 #define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
40
41 #endif /* < KERNEL_VERSION(4, 3, 0) */
42
43 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
44
45 #include <linux/ethtool.h>
46
47 #define ethtool_link_ksettings batadv_ethtool_link_ksettings
48
49 struct batadv_ethtool_link_ksettings {
50 struct {
51 __u32 speed;
52 __u8 duplex;
53 } base;
54 };
55
56 #define __ethtool_get_link_ksettings(__dev, __link_settings) \
57 batadv_ethtool_get_link_ksettings(__dev, __link_settings)
58
59 static inline int
60 batadv_ethtool_get_link_ksettings(struct net_device *dev,
61 struct ethtool_link_ksettings *link_ksettings)
62 {
63 struct ethtool_cmd cmd;
64 int ret;
65
66 memset(&cmd, 0, sizeof(cmd));
67 ret = __ethtool_get_settings(dev, &cmd);
68
69 if (ret != 0)
70 return ret;
71
72 link_ksettings->base.duplex = cmd.duplex;
73 link_ksettings->base.speed = ethtool_cmd_speed(&cmd);
74
75 return 0;
76 }
77
78 #endif /* < KERNEL_VERSION(4, 6, 0) */
79
80 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
81
82 #define netif_trans_update batadv_netif_trans_update
83 static inline void batadv_netif_trans_update(struct net_device *dev)
84 {
85 dev->trans_start = jiffies;
86 }
87
88 #endif /* < KERNEL_VERSION(4, 7, 0) */