1 #ifndef LINUX_3_2_COMPAT_H
2 #define LINUX_3_2_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0))
8 #include <linux/skbuff.h>
9 #include <linux/dma-mapping.h>
10 #include <linux/ethtool.h>
12 /* backports b4625dab */
13 #define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */
14 #define SDIO_SDIO_REV_3_00 4 /* SDIO Spec Version 3.00 */
16 #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0)
18 extern int __ethtool_get_settings(struct net_device *dev,
19 struct ethtool_cmd *cmd);
21 #ifdef CONFIG_COMPAT_SKB_FRAG_NEEDED
24 * skb_frag_page - retrieve the page refered to by a paged fragment
25 * @frag: the paged fragment
27 * Returns the &struct page associated with @frag.
29 static inline struct page *skb_frag_page(const skb_frag_t *frag)
35 * __skb_frag_set_page - sets the page contained in a paged fragment
36 * @frag: the paged fragment
37 * @page: the page to set
39 * Sets the fragment @frag to contain @page.
41 static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
47 * skb_frag_set_page - sets the page contained in a paged fragment of an skb
49 * @f: the fragment offset
50 * @page: the page to set
52 * Sets the @f'th fragment of @skb to contain @page.
54 static inline void skb_frag_set_page(struct sk_buff *skb, int f,
57 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
61 * skb_frag_address_safe - gets the address of the data contained in a paged fragment
62 * @frag: the paged fragment buffer
64 * Returns the address of the data within @frag. Checks that the page
65 * is mapped and returns %NULL otherwise.
67 static inline void *skb_frag_address_safe(const skb_frag_t *frag)
69 void *ptr = page_address(skb_frag_page(frag));
73 return ptr + frag->page_offset;
77 * skb_frag_dma_map - maps a paged fragment via the DMA API
78 * @device: the device to map the fragment to
79 * @frag: the paged fragment to map
80 * @offset: the offset within the fragment (starting at the
81 * fragment's own offset)
82 * @size: the number of bytes to map
83 * @direction: the direction of the mapping (%PCI_DMA_*)
85 * Maps the page associated with @frag to @device.
87 static inline dma_addr_t skb_frag_dma_map(struct device *dev,
88 const skb_frag_t *frag,
89 size_t offset, size_t size,
90 enum dma_data_direction dir)
92 return dma_map_page(dev, skb_frag_page(frag),
93 frag->page_offset + offset, size, dir);
96 #define ETH_P_TDLS 0x890D /* TDLS */
98 static inline unsigned int skb_frag_size(const skb_frag_t *frag)
103 static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size)
108 static inline void skb_frag_size_add(skb_frag_t *frag, int delta)
113 static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
118 #endif /* CONFIG_COMPAT_SKB_FRAG_NEEDED */
120 static inline char *hex_byte_pack(char *buf, u8 byte)
122 *buf++ = hex_asc_hi(byte);
123 *buf++ = hex_asc_lo(byte);
127 /* module_platform_driver() - Helper macro for drivers that don't do
128 * anything special in module init/exit. This eliminates a lot of
129 * boilerplate. Each module may only use this macro once, and
130 * calling it replaces module_init() and module_exit()
132 #define module_platform_driver(__platform_driver) \
133 module_driver(__platform_driver, platform_driver_register, \
134 platform_driver_unregister)
136 static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
137 dma_addr_t *dma_handle, gfp_t flag)
139 void *ret = dma_alloc_coherent(dev, size, dma_handle, flag);
141 memset(ret, 0, size);
145 extern int __netdev_printk(const char *level, const struct net_device *dev,
146 struct va_format *vaf);
148 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */
150 #endif /* LINUX_3_2_COMPAT_H */