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 #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0)
14 extern int __ethtool_get_settings(struct net_device *dev,
15 struct ethtool_cmd *cmd);
18 * skb_frag_page - retrieve the page refered to by a paged fragment
19 * @frag: the paged fragment
21 * Returns the &struct page associated with @frag.
23 static inline struct page *skb_frag_page(const skb_frag_t *frag)
29 * __skb_frag_set_page - sets the page contained in a paged fragment
30 * @frag: the paged fragment
31 * @page: the page to set
33 * Sets the fragment @frag to contain @page.
35 static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
41 * skb_frag_set_page - sets the page contained in a paged fragment of an skb
43 * @f: the fragment offset
44 * @page: the page to set
46 * Sets the @f'th fragment of @skb to contain @page.
48 static inline void skb_frag_set_page(struct sk_buff *skb, int f,
51 __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
55 * skb_frag_address_safe - gets the address of the data contained in a paged fragment
56 * @frag: the paged fragment buffer
58 * Returns the address of the data within @frag. Checks that the page
59 * is mapped and returns %NULL otherwise.
61 static inline void *skb_frag_address_safe(const skb_frag_t *frag)
63 void *ptr = page_address(skb_frag_page(frag));
67 return ptr + frag->page_offset;
71 * skb_frag_dma_map - maps a paged fragment via the DMA API
72 * @device: the device to map the fragment to
73 * @frag: the paged fragment to map
74 * @offset: the offset within the fragment (starting at the
75 * fragment's own offset)
76 * @size: the number of bytes to map
77 * @direction: the direction of the mapping (%PCI_DMA_*)
79 * Maps the page associated with @frag to @device.
81 static inline dma_addr_t skb_frag_dma_map(struct device *dev,
82 const skb_frag_t *frag,
83 size_t offset, size_t size,
84 enum dma_data_direction dir)
86 return dma_map_page(dev, skb_frag_page(frag),
87 frag->page_offset + offset, size, dir);
90 #define ETH_P_TDLS 0x890D /* TDLS */
92 static inline unsigned int skb_frag_size(const skb_frag_t *frag)
97 static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size)
102 static inline void skb_frag_size_add(skb_frag_t *frag, int delta)
107 static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
112 static inline char *hex_byte_pack(char *buf, u8 byte)
114 *buf++ = hex_asc_hi(byte);
115 *buf++ = hex_asc_lo(byte);
119 /* module_platform_driver() - Helper macro for drivers that don't do
120 * anything special in module init/exit. This eliminates a lot of
121 * boilerplate. Each module may only use this macro once, and
122 * calling it replaces module_init() and module_exit()
124 #define module_platform_driver(__platform_driver) \
125 module_driver(__platform_driver, platform_driver_register, \
126 platform_driver_unregister)
128 static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
129 dma_addr_t *dma_handle, gfp_t flag)
131 void *ret = dma_alloc_coherent(dev, size, dma_handle, flag);
133 memset(ret, 0, size);
137 extern int __netdev_printk(const char *level, const struct net_device *dev,
138 struct va_format *vaf);
140 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */
142 #endif /* LINUX_3_2_COMPAT_H */