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 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
21 #define release_firmware compat_release_firmware
22 #define request_firmware compat_request_firmware
23 #define request_firmware_nowait compat_request_firmware_nowait
27 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
28 int compat_request_firmware(const struct firmware **fw, const char *name,
29 struct device *device);
30 int compat_request_firmware_nowait(
31 struct module *module, int uevent,
32 const char *name, struct device *device, gfp_t gfp, void *context,
33 void (*cont)(const struct firmware *fw, void *context));
35 void compat_release_firmware(const struct firmware *fw);
37 static inline int compat_request_firmware(const struct firmware **fw,
39 struct device *device)
43 static inline int compat_request_firmware_nowait(
44 struct module *module, int uevent,
45 const char *name, struct device *device, gfp_t gfp, void *context,
46 void (*cont)(const struct firmware *fw, void *context))
51 static inline void compat_release_firmware(const struct firmware *fw)
56 /* mask KEY_RFKILL as RHEL6 backports this */
57 #if !defined(KEY_RFKILL)
58 #define KEY_RFKILL 247 /* Key that controls all radios */
61 #ifndef IFF_DONT_BRIDGE
62 #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
63 #endif /* IFF_DONT_BRIDGE */
64 /* source: include/linux/if.h */
66 /* this will never happen on older kernels */
67 #ifndef NETDEV_POST_INIT
68 #define NETDEV_POST_INIT 0xffff
69 #endif /* NETDEV_POST_INIT */
71 /* mask netdev_alloc_skb_ip_align as debian squeeze also backports this */
72 #define netdev_alloc_skb_ip_align(a, b) compat_netdev_alloc_skb_ip_align(a, b)
74 static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
77 struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN);
79 if (NET_IP_ALIGN && skb)
80 skb_reserve(skb, NET_IP_ALIGN);
84 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
86 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
88 #define pcmcia_request_window(a, b, c) pcmcia_request_window(&a, b, c)
90 #define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c)
92 /* loop over CIS entries */
93 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
94 int (*loop_tuple) (struct pcmcia_device *p_dev,
99 #endif /* CONFIG_PCMCIA */
101 /* loop over CIS entries */
102 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
103 cisdata_t code, cisparse_t *parse, void *priv_data,
104 int (*loop_tuple) (tuple_t *tuple,
108 #endif /* CONFIG_PCCARD */
111 * list_for_each_entry_continue_rcu - continue iteration over list of given type
112 * @pos: the type * to use as a loop cursor.
113 * @head: the head for your list.
114 * @member: the name of the list_struct within the struct.
116 * Continue to iterate over list of given type, continuing after
117 * the current position.
119 #define list_for_each_entry_continue_rcu(pos, head, member) \
120 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
121 prefetch(pos->member.next), &pos->member != (head); \
122 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
124 #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb)
126 /* mask pci_pcie_cap as debian squeeze also backports this */
127 #define pci_pcie_cap(a) compat_pci_pcie_cap(a)
130 * pci_pcie_cap - get the saved PCIe capability offset
133 * PCIe capability offset is calculated at PCI device initialization
134 * time and saved in the data structure. This function returns saved
135 * PCIe capability offset. Using this instead of pci_find_capability()
136 * reduces unnecessary search in the PCI configuration space. If you
137 * need to calculate PCIe capability offset from raw device for some
138 * reasons, please use pci_find_capability() instead.
140 static inline int pci_pcie_cap(struct pci_dev *dev)
142 return pci_find_capability(dev, PCI_CAP_ID_EXP);
145 /* mask pci_is_pcie as RHEL6 backports this */
146 #define pci_is_pcie(a) compat_pci_is_pcie(a)
149 * pci_is_pcie - check if the PCI device is PCI Express capable
152 * Retrun true if the PCI device is PCI Express capable, false otherwise.
154 static inline bool pci_is_pcie(struct pci_dev *dev)
156 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
159 return !!pci_pcie_cap(dev);
164 #define __always_unused __attribute__((unused))
166 #define __always_unused /* unimplemented */
169 /* mask IS_ERR_OR_NULL as debian squeeze also backports this */
170 #define IS_ERR_OR_NULL(a) compat_IS_ERR_OR_NULL(a)
172 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
174 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
177 #define for_each_netdev_rcu(net, d) \
178 list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
180 #define IPV4_FLOW 0x10 /* hash only */
181 #define IPV6_FLOW 0x11 /* hash only */
183 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
185 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
187 #endif /* LINUX_26_33_COMPAT_H */