diff options
| author | Jens Axboe <jens.axboe@oracle.com> | 2007-10-24 05:20:47 -0400 |
|---|---|---|
| committer | Jens Axboe <jens.axboe@oracle.com> | 2007-10-24 05:20:47 -0400 |
| commit | 642f149031d70415d9318b919d50b71e4724adbd (patch) | |
| tree | e792ad29dedffc6756d55e9d63e18ada35515b4b /include/linux | |
| parent | bd6dee6f30a0f6943df190b387b5f8fe98a848f3 (diff) | |
SG: Change sg_set_page() to take length and offset argument
Most drivers need to set length and offset as well, so may as well fold
those three lines into one.
Add sg_assign_page() for those two locations that only needed to set
the page, where the offset/length is set outside of the function context.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux')
| -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 | /* |
