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