1 #ifndef LINUX_26_23_COMPAT_H
2 #define LINUX_26_23_COMPAT_H
4 #include <linux/version.h>
6 /* Compat work for < 2.6.23 */
7 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
9 #include <linux/netdevice.h>
10 #include <linux/sched.h>
11 #include <linux/workqueue.h>
12 #include <linux/genetlink.h>
13 #include <net/sch_generic.h>
16 * Tell gcc if a function is cold. The compiler will assume any path
17 * directly leading to the call is unlikely.
20 #if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3)
21 /* Mark functions as cold. gcc will assume any path leading to a call
22 * to them will be unlikely. This means a lot of manual unlikely()s
23 * are unnecessary now for any paths leading to the usual suspects
24 * like BUG(), printk(), panic() etc. [but let's keep them for now for
27 * Early snapshots of gcc 4.3 don't support this and we can't detect this
28 * in the preprocessor, but we can live with this because they're unreleased.
29 * Maketime probing would be overkill here.
31 * gcc also has a __attribute__((__hot__)) to move hot functions into
32 * a special section, but I don't see any sense in this right now in
33 * the kernel context */
34 #define __cold __attribute__((__cold__))
35 #endif /* gcc 4.3 check */
41 /* Added as of 2.6.23 in include/linux/netdevice.h */
42 #define alloc_netdev_mq(sizeof_priv, name, setup, queue) \
43 alloc_netdev(sizeof_priv, name, setup)
44 #define NETIF_F_MULTI_QUEUE 16384
46 /* Added as of 2.6.23 on include/linux/netdevice.h */
47 static inline int netif_is_multiqueue(const struct net_device *dev)
49 return (!!(NETIF_F_MULTI_QUEUE & dev->features));
52 /* 2.6.23 fixed a bug in tcf_destroy_chain and the parameter changed */
53 static inline void tcf_destroy_chain_compat(struct tcf_proto **fl)
57 while ((tp = *fl) != NULL) {
60 module_put(tp->ops->owner);
65 /* dev_mc_list was replaced with dev_addr_list as of 2.6.23,
66 * only new member added is da_synced. */
67 #define dev_addr_list dev_mc_list
68 #define da_addr dmi_addr
69 #define da_addrlen dmi_addrlen
70 #define da_users dmi_users
71 #define da_gusers dmi_gusers
73 /* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and
74 * dev_set_promiscuity() became a wrapper. */
75 #define __dev_set_promiscuity dev_set_promiscuity
77 /* Our own 2.6.22 port on compat.c */
78 extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
79 extern int dev_mc_sync(struct net_device *to, struct net_device *from);
81 /* Our own 2.6.22 port on compat.c */
82 extern void __dev_set_rx_mode(struct net_device *dev);
84 /* Simple to add this */
85 extern int cancel_delayed_work_sync(struct delayed_work *work);
87 #define cancel_delayed_work_sync cancel_rearming_delayed_work
89 #define debugfs_rename(a, b, c, d) 1
91 /* nl80211 requires multicast group support which is new and added on
92 * 2.6.23. We can't add support for it for older kernels to support it
93 * genl_family structure was changed. Lets just let through the
94 * genl_register_mc_group call. This means no multicast group suppport */
96 #define genl_register_mc_group(a, b) 0
99 * struct genl_multicast_group - generic netlink multicast group
100 * @name: name of the multicast group, names are per-family
101 * @id: multicast group ID, assigned by the core, to use with
102 * genlmsg_multicast().
103 * @list: list entry for linking
104 * @family: pointer to family, need not be set before registering
106 struct genl_multicast_group
108 struct genl_family *family; /* private */
109 struct list_head list; /* private */
110 char name[GENL_NAMSIZ];
115 /* Added as of 2.6.23 */
116 int pci_try_set_mwi(struct pci_dev *dev);
118 /* Added as of 2.6.23 */
119 #ifdef CONFIG_PM_SLEEP
121 * Tell the freezer that the current task should be frozen by it
123 static inline void set_freezable(void)
125 current->flags &= ~PF_NOFREEZE;
129 static inline void set_freezable(void) {}
130 #endif /* CONFIG_PM_SLEEP */
133 #define tcf_destroy_chain_compat tcf_destroy_chain
134 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */
136 #endif /* LINUX_26_23_COMPAT_H */