aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/scatterlist.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/scatterlist.h')
-rw-r--r--include/linux/scatterlist.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index bfc47e0de81c..5951e3f38878 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -251,13 +251,13 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
251 * sg page iterator 251 * sg page iterator
252 * 252 *
253 * Iterates over sg entries page-by-page. On each successful iteration, 253 * Iterates over sg entries page-by-page. On each successful iteration,
254 * @piter->page points to the current page, @piter->sg to the sg holding this 254 * you can call sg_page_iter_page(@piter) and sg_page_iter_dma_address(@piter)
255 * page and @piter->sg_pgoffset to the page's page offset within the sg. The 255 * to get the current page and its dma address. @piter->sg will point to the
256 * iteration will stop either when a maximum number of sg entries was reached 256 * sg holding this page and @piter->sg_pgoffset to the page's page offset
257 * or a terminating sg (sg_last(sg) == true) was reached. 257 * within the sg. The iteration will stop either when a maximum number of sg
258 * entries was reached or a terminating sg (sg_last(sg) == true) was reached.
258 */ 259 */
259struct sg_page_iter { 260struct sg_page_iter {
260 struct page *page; /* current page */
261 struct scatterlist *sg; /* sg holding the page */ 261 struct scatterlist *sg; /* sg holding the page */
262 unsigned int sg_pgoffset; /* page offset within the sg */ 262 unsigned int sg_pgoffset; /* page offset within the sg */
263 263
@@ -271,6 +271,24 @@ bool __sg_page_iter_next(struct sg_page_iter *piter);
271void __sg_page_iter_start(struct sg_page_iter *piter, 271void __sg_page_iter_start(struct sg_page_iter *piter,
272 struct scatterlist *sglist, unsigned int nents, 272 struct scatterlist *sglist, unsigned int nents,
273 unsigned long pgoffset); 273 unsigned long pgoffset);
274/**
275 * sg_page_iter_page - get the current page held by the page iterator
276 * @piter: page iterator holding the page
277 */
278static inline struct page *sg_page_iter_page(struct sg_page_iter *piter)
279{
280 return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
281}
282
283/**
284 * sg_page_iter_dma_address - get the dma address of the current page held by
285 * the page iterator.
286 * @piter: page iterator holding the page
287 */
288static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter)
289{
290 return sg_dma_address(piter->sg) + (piter->sg_pgoffset << PAGE_SHIFT);
291}
274 292
275/** 293/**
276 * for_each_sg_page - iterate over the pages of the given sg list 294 * for_each_sg_page - iterate over the pages of the given sg list