diff options
Diffstat (limited to 'include/linux/scatterlist.h')
-rw-r--r-- | include/linux/scatterlist.h | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index df7ddcee7c4b..809b2ac2e37e 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h | |||
@@ -26,18 +26,16 @@ | |||
26 | #define SG_MAGIC 0x87654321 | 26 | #define SG_MAGIC 0x87654321 |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * sg_set_page - Set sg entry to point at given page | 29 | * sg_assign_page - Assign a given page to an SG entry |
30 | * @sg: SG entry | 30 | * @sg: SG entry |
31 | * @page: The page | 31 | * @page: The page |
32 | * | 32 | * |
33 | * Description: | 33 | * Description: |
34 | * Use this function to set an sg entry pointing at a page, never assign | 34 | * Assign page to sg entry. Also see sg_set_page(), the most commonly used |
35 | * the page directly. We encode sg table information in the lower bits | 35 | * variant. |
36 | * of the page pointer. See sg_page() for looking up the page belonging | ||
37 | * to an sg entry. | ||
38 | * | 36 | * |
39 | **/ | 37 | **/ |
40 | static inline void sg_set_page(struct scatterlist *sg, struct page *page) | 38 | static inline void sg_assign_page(struct scatterlist *sg, struct page *page) |
41 | { | 39 | { |
42 | unsigned long page_link = sg->page_link & 0x3; | 40 | unsigned long page_link = sg->page_link & 0x3; |
43 | 41 | ||
@@ -52,6 +50,28 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page) | |||
52 | sg->page_link = page_link | (unsigned long) page; | 50 | sg->page_link = page_link | (unsigned long) page; |
53 | } | 51 | } |
54 | 52 | ||
53 | /** | ||
54 | * sg_set_page - Set sg entry to point at given page | ||
55 | * @sg: SG entry | ||
56 | * @page: The page | ||
57 | * @len: Length of data | ||
58 | * @offset: Offset into page | ||
59 | * | ||
60 | * Description: | ||
61 | * Use this function to set an sg entry pointing at a page, never assign | ||
62 | * the page directly. We encode sg table information in the lower bits | ||
63 | * of the page pointer. See sg_page() for looking up the page belonging | ||
64 | * to an sg entry. | ||
65 | * | ||
66 | **/ | ||
67 | static inline void sg_set_page(struct scatterlist *sg, struct page *page, | ||
68 | unsigned int len, unsigned int offset) | ||
69 | { | ||
70 | sg_assign_page(sg, page); | ||
71 | sg->offset = offset; | ||
72 | sg->length = len; | ||
73 | } | ||
74 | |||
55 | #define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) | 75 | #define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) |
56 | 76 | ||
57 | /** | 77 | /** |
@@ -64,9 +84,7 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page) | |||
64 | static inline void sg_set_buf(struct scatterlist *sg, const void *buf, | 84 | static inline void sg_set_buf(struct scatterlist *sg, const void *buf, |
65 | unsigned int buflen) | 85 | unsigned int buflen) |
66 | { | 86 | { |
67 | sg_set_page(sg, virt_to_page(buf)); | 87 | sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); |
68 | sg->offset = offset_in_page(buf); | ||
69 | sg->length = buflen; | ||
70 | } | 88 | } |
71 | 89 | ||
72 | /* | 90 | /* |