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>
17 #define release_firmware compat_release_firmware
18 #define request_firmware compat_request_firmware
19 #define request_firmware_nowait compat_request_firmware_nowait
21 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
22 int compat_request_firmware(const struct firmware **fw, const char *name,
23 struct device *device);
24 int compat_request_firmware_nowait(
25 struct module *module, int uevent,
26 const char *name, struct device *device, gfp_t gfp, void *context,
27 void (*cont)(const struct firmware *fw, void *context));
29 void compat_release_firmware(const struct firmware *fw);
31 static inline int compat_request_firmware(const struct firmware **fw,
33 struct device *device)
37 static inline int request_firmware_nowait(
38 struct module *module, int uevent,
39 const char *name, struct device *device, gfp_t gfp, void *context,
40 void (*cont)(const struct firmware *fw, void *context))
45 static inline void compat_release_firmware(const struct firmware *fw)
50 #define KEY_RFKILL 247 /* Key that controls all radios */
52 #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
53 /* source: include/linux/if.h */
55 /* this will never happen on older kernels */
56 #define NETDEV_POST_INIT 0xffff
58 static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
61 struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN);
63 if (NET_IP_ALIGN && skb)
64 skb_reserve(skb, NET_IP_ALIGN);
68 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
70 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
72 #define pcmcia_request_window(a, b, c) pcmcia_request_window(&a, b, c)
74 #define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c)
76 /* loop over CIS entries */
77 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
78 int (*loop_tuple) (struct pcmcia_device *p_dev,
83 #endif /* CONFIG_PCMCIA */
85 /* loop over CIS entries */
86 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
87 cisdata_t code, cisparse_t *parse, void *priv_data,
88 int (*loop_tuple) (tuple_t *tuple,
92 #endif /* CONFIG_PCCARD */
95 * list_for_each_entry_continue_rcu - continue iteration over list of given type
96 * @pos: the type * to use as a loop cursor.
97 * @head: the head for your list.
98 * @member: the name of the list_struct within the struct.
100 * Continue to iterate over list of given type, continuing after
101 * the current position.
103 #define list_for_each_entry_continue_rcu(pos, head, member) \
104 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
105 prefetch(pos->member.next), &pos->member != (head); \
106 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
108 #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb)
111 * pci_pcie_cap - get the saved PCIe capability offset
114 * PCIe capability offset is calculated at PCI device initialization
115 * time and saved in the data structure. This function returns saved
116 * PCIe capability offset. Using this instead of pci_find_capability()
117 * reduces unnecessary search in the PCI configuration space. If you
118 * need to calculate PCIe capability offset from raw device for some
119 * reasons, please use pci_find_capability() instead.
121 static inline int pci_pcie_cap(struct pci_dev *dev)
123 return pci_find_capability(dev, PCI_CAP_ID_EXP);
127 * pci_is_pcie - check if the PCI device is PCI Express capable
130 * Retrun true if the PCI device is PCI Express capable, false otherwise.
132 static inline bool pci_is_pcie(struct pci_dev *dev)
134 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
137 return !!pci_pcie_cap(dev);
142 #define __always_unused __attribute__((unused))
144 #define __always_unused /* unimplemented */
147 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
149 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
152 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
154 #endif /* LINUX_26_33_COMPAT_H */