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_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
20 #define release_firmware compat_release_firmware
21 #define request_firmware compat_request_firmware
22 #define request_firmware_nowait compat_request_firmware_nowait
25 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
26 int compat_request_firmware(const struct firmware **fw, const char *name,
27 struct device *device);
28 int compat_request_firmware_nowait(
29 struct module *module, int uevent,
30 const char *name, struct device *device, gfp_t gfp, void *context,
31 void (*cont)(const struct firmware *fw, void *context));
33 void compat_release_firmware(const struct firmware *fw);
35 static inline int compat_request_firmware(const struct firmware **fw,
37 struct device *device)
41 static inline int compat_request_firmware_nowait(
42 struct module *module, int uevent,
43 const char *name, struct device *device, gfp_t gfp, void *context,
44 void (*cont)(const struct firmware *fw, void *context))
49 static inline void compat_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);
82 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
84 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
86 #define pcmcia_request_window(a, b, c) pcmcia_request_window(&a, b, c)
88 #define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c)
90 /* loop over CIS entries */
91 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
92 int (*loop_tuple) (struct pcmcia_device *p_dev,
97 #endif /* CONFIG_PCMCIA */
99 /* loop over CIS entries */
100 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
101 cisdata_t code, cisparse_t *parse, void *priv_data,
102 int (*loop_tuple) (tuple_t *tuple,
106 #endif /* CONFIG_PCCARD */
109 * list_for_each_entry_continue_rcu - continue iteration over list of given type
110 * @pos: the type * to use as a loop cursor.
111 * @head: the head for your list.
112 * @member: the name of the list_struct within the struct.
114 * Continue to iterate over list of given type, continuing after
115 * the current position.
117 #define list_for_each_entry_continue_rcu(pos, head, member) \
118 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
119 prefetch(pos->member.next), &pos->member != (head); \
120 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
122 #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb)
124 /* mask pci_pcie_cap as debian squeeze also backports this */
125 #define pci_pcie_cap(a) compat_pci_pcie_cap(a)
128 * pci_pcie_cap - get the saved PCIe capability offset
131 * PCIe capability offset is calculated at PCI device initialization
132 * time and saved in the data structure. This function returns saved
133 * PCIe capability offset. Using this instead of pci_find_capability()
134 * reduces unnecessary search in the PCI configuration space. If you
135 * need to calculate PCIe capability offset from raw device for some
136 * reasons, please use pci_find_capability() instead.
138 static inline int pci_pcie_cap(struct pci_dev *dev)
140 return pci_find_capability(dev, PCI_CAP_ID_EXP);
143 /* mask pci_is_pcie as RHEL6 backports this */
144 #define pci_is_pcie(a) compat_pci_is_pcie(a)
147 * pci_is_pcie - check if the PCI device is PCI Express capable
150 * Retrun true if the PCI device is PCI Express capable, false otherwise.
152 static inline bool pci_is_pcie(struct pci_dev *dev)
154 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
157 return !!pci_pcie_cap(dev);
162 #define __always_unused __attribute__((unused))
164 #define __always_unused /* unimplemented */
167 /* mask IS_ERR_OR_NULL as debian squeeze also backports this */
168 #define IS_ERR_OR_NULL(a) compat_IS_ERR_OR_NULL(a)
170 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
172 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
175 #define for_each_netdev_rcu(net, d) \
176 list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
178 #define IPV4_FLOW 0x10 /* hash only */
179 #define IPV6_FLOW 0x11 /* hash only */
181 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
183 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
185 #endif /* LINUX_26_33_COMPAT_H */