1 #ifndef LINUX_26_33_COMPAT_H
2 #define LINUX_26_33_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
8 #include <linux/skbuff.h>
10 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
11 #include <pcmcia/cs_types.h>
12 #include <pcmcia/cistpl.h>
13 #include <pcmcia/ds.h>
15 #include <linux/firmware.h>
16 #include <linux/input.h>
17 #include <linux/sched.h>
19 #if defined(CONFIG_COMPAT_FIRMWARE_CLASS)
20 #define request_firmware_nowait LINUX_BACKPORT(request_firmware_nowait)
21 #define request_firmware LINUX_BACKPORT(request_firmware)
22 #define release_firmware LINUX_BACKPORT(release_firmware)
24 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
25 int request_firmware(const struct firmware **fw, const char *name,
26 struct device *device);
27 int request_firmware_nowait(
28 struct module *module, int uevent,
29 const char *name, struct device *device, gfp_t gfp, void *context,
30 void (*cont)(const struct firmware *fw, void *context));
32 void release_firmware(const struct firmware *fw);
34 static inline int request_firmware(const struct firmware **fw,
36 struct device *device)
40 static inline int request_firmware_nowait(
41 struct module *module, int uevent,
42 const char *name, struct device *device, gfp_t gfp, void *context,
43 void (*cont)(const struct firmware *fw, void *context))
48 static inline void release_firmware(const struct firmware *fw)
54 /* mask KEY_RFKILL as RHEL6 backports this */
55 #if !defined(KEY_RFKILL)
56 #define KEY_RFKILL 247 /* Key that controls all radios */
59 #ifndef IFF_DONT_BRIDGE
60 #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
61 #endif /* IFF_DONT_BRIDGE */
62 /* source: include/linux/if.h */
64 /* this will never happen on older kernels */
65 #ifndef NETDEV_POST_INIT
66 #define NETDEV_POST_INIT 0xffff
67 #endif /* NETDEV_POST_INIT */
69 /* mask netdev_alloc_skb_ip_align as debian squeeze also backports this */
70 #define netdev_alloc_skb_ip_align(a, b) compat_netdev_alloc_skb_ip_align(a, b)
72 static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
75 struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN);
77 if (NET_IP_ALIGN && skb)
78 skb_reserve(skb, NET_IP_ALIGN);
83 * list_for_each_entry_continue_rcu - continue iteration over list of given type
84 * @pos: the type * to use as a loop cursor.
85 * @head: the head for your list.
86 * @member: the name of the list_struct within the struct.
88 * Continue to iterate over list of given type, continuing after
89 * the current position.
91 #define list_for_each_entry_continue_rcu(pos, head, member) \
92 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
93 prefetch(pos->member.next), &pos->member != (head); \
94 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
96 #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb)
98 #define pci_pcie_cap LINUX_BACKPORT(pci_pcie_cap)
101 * pci_pcie_cap - get the saved PCIe capability offset
104 * PCIe capability offset is calculated at PCI device initialization
105 * time and saved in the data structure. This function returns saved
106 * PCIe capability offset. Using this instead of pci_find_capability()
107 * reduces unnecessary search in the PCI configuration space. If you
108 * need to calculate PCIe capability offset from raw device for some
109 * reasons, please use pci_find_capability() instead.
111 static inline int pci_pcie_cap(struct pci_dev *dev)
113 return pci_find_capability(dev, PCI_CAP_ID_EXP);
116 #define pci_is_pcie LINUX_BACKPORT(pci_is_pcie)
119 * pci_is_pcie - check if the PCI device is PCI Express capable
122 * Retrun true if the PCI device is PCI Express capable, false otherwise.
124 static inline bool pci_is_pcie(struct pci_dev *dev)
126 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
129 return !!pci_pcie_cap(dev);
134 #define __always_unused __attribute__((unused))
136 #define __always_unused /* unimplemented */
139 /* mask IS_ERR_OR_NULL as debian squeeze also backports this */
140 #define IS_ERR_OR_NULL(a) compat_IS_ERR_OR_NULL(a)
142 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
144 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
147 #define for_each_netdev_rcu(net, d) \
148 list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
150 #define IPV4_FLOW 0x10 /* hash only */
151 #define IPV6_FLOW 0x11 /* hash only */
153 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
155 #ifndef CONFIG_COMPAT_IS_BITMAP
157 extern void bitmap_set(unsigned long *map, int i, int len);
158 extern void bitmap_clear(unsigned long *map, int start, int nr);
159 extern unsigned long bitmap_find_next_zero_area(unsigned long *map,
163 unsigned long align_mask);
165 #endif /* CONFIG_COMPAT_IS_BITMAP */
169 #define NUMA_NO_NODE (-1)
171 #endif /* CONFIG_PPC */
173 #define strim LINUX_BACKPORT(strim)
174 extern char *strim(char *);
176 #define skip_spaces LINUX_BACKPORT(skip_spaces)
177 extern char * __must_check skip_spaces(const char *);
179 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
181 #endif /* LINUX_26_33_COMPAT_H */