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>
18 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
19 #define release_firmware compat_release_firmware
20 #define request_firmware compat_request_firmware
21 #define request_firmware_nowait compat_request_firmware_nowait
24 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
25 int compat_request_firmware(const struct firmware **fw, const char *name,
26 struct device *device);
27 int compat_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 compat_release_firmware(const struct firmware *fw);
34 static inline int compat_request_firmware(const struct firmware **fw,
36 struct device *device)
40 static inline int compat_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 compat_release_firmware(const struct firmware *fw)
53 /* mask KEY_RFKILL as RHEL6 backports this */
54 #if !defined(KEY_RFKILL)
55 #define KEY_RFKILL 247 /* Key that controls all radios */
58 #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
59 /* source: include/linux/if.h */
61 /* this will never happen on older kernels */
62 #define NETDEV_POST_INIT 0xffff
64 /* mask netdev_alloc_skb_ip_align as debian squeeze also backports this */
65 #define netdev_alloc_skb_ip_align(a, b) compat_netdev_alloc_skb_ip_align(a, b)
67 static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
70 struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN);
72 if (NET_IP_ALIGN && skb)
73 skb_reserve(skb, NET_IP_ALIGN);
77 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
79 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
81 #define pcmcia_request_window(a, b, c) pcmcia_request_window(&a, b, c)
83 #define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c)
85 /* loop over CIS entries */
86 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
87 int (*loop_tuple) (struct pcmcia_device *p_dev,
92 #endif /* CONFIG_PCMCIA */
94 /* loop over CIS entries */
95 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
96 cisdata_t code, cisparse_t *parse, void *priv_data,
97 int (*loop_tuple) (tuple_t *tuple,
101 #endif /* CONFIG_PCCARD */
104 * list_for_each_entry_continue_rcu - continue iteration over list of given type
105 * @pos: the type * to use as a loop cursor.
106 * @head: the head for your list.
107 * @member: the name of the list_struct within the struct.
109 * Continue to iterate over list of given type, continuing after
110 * the current position.
112 #define list_for_each_entry_continue_rcu(pos, head, member) \
113 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
114 prefetch(pos->member.next), &pos->member != (head); \
115 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
117 #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb)
119 /* mask pci_pcie_cap as debian squeeze also backports this */
120 #define pci_pcie_cap(a) compat_pci_pcie_cap(a)
123 * pci_pcie_cap - get the saved PCIe capability offset
126 * PCIe capability offset is calculated at PCI device initialization
127 * time and saved in the data structure. This function returns saved
128 * PCIe capability offset. Using this instead of pci_find_capability()
129 * reduces unnecessary search in the PCI configuration space. If you
130 * need to calculate PCIe capability offset from raw device for some
131 * reasons, please use pci_find_capability() instead.
133 static inline int pci_pcie_cap(struct pci_dev *dev)
135 return pci_find_capability(dev, PCI_CAP_ID_EXP);
138 /* mask pci_is_pcie as RHEL6 backports this */
139 #define pci_is_pcie(a) compat_pci_is_pcie(a)
142 * pci_is_pcie - check if the PCI device is PCI Express capable
145 * Retrun true if the PCI device is PCI Express capable, false otherwise.
147 static inline bool pci_is_pcie(struct pci_dev *dev)
149 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
152 return !!pci_pcie_cap(dev);
157 #define __always_unused __attribute__((unused))
159 #define __always_unused /* unimplemented */
162 /* mask IS_ERR_OR_NULL as debian squeeze also backports this */
163 #define IS_ERR_OR_NULL(a) compat_IS_ERR_OR_NULL(a)
165 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
167 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
170 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
172 #endif /* LINUX_26_33_COMPAT_H */