From: Hauke Mehrtens Date: Wed, 31 Aug 2011 22:20:11 +0000 (+0200) Subject: compat: add skb_frag_dma_map X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b22456c9fc7f11567f1feb7192a107dc67a674cd;p=openwrt%2Fstaging%2Fblogic.git compat: add skb_frag_dma_map Signed-off-by: Hauke Mehrtens --- diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index d10495cc17a6..009e34104b82 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -5,6 +5,9 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) +#include +#include + /* * This is not part of The 2.6.37 kernel yet but we * we use it to optimize the backport code we @@ -24,6 +27,37 @@ #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) +/** + * skb_frag_page - retrieve the page refered to by a paged fragment + * @frag: the paged fragment + * + * Returns the &struct page associated with @frag. + */ +static inline struct page *skb_frag_page(const skb_frag_t *frag) +{ + return frag->page; +} + +/** + * skb_frag_dma_map - maps a paged fragment via the DMA API + * @device: the device to map the fragment to + * @frag: the paged fragment to map + * @offset: the offset within the fragment (starting at the + * fragment's own offset) + * @size: the number of bytes to map + * @direction: the direction of the mapping (%PCI_DMA_*) + * + * Maps the page associated with @frag to @device. + */ +static inline dma_addr_t skb_frag_dma_map(struct device *dev, + const skb_frag_t *frag, + size_t offset, size_t size, + enum dma_data_direction dir) +{ + return dma_map_page(dev, skb_frag_page(frag), + frag->page_offset + offset, size, dir); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */