aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-24 05:20:47 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-24 05:20:47 -0400
commit642f149031d70415d9318b919d50b71e4724adbd (patch)
treee792ad29dedffc6756d55e9d63e18ada35515b4b /include
parentbd6dee6f30a0f6943df190b387b5f8fe98a848f3 (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')
-rw-r--r--include/asm-frv/scatterlist.h3
-rw-r--r--include/linux/scatterlist.h40
2 files changed, 30 insertions, 13 deletions
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h
index 99ba76edc42a..2e7143b5a7ad 100644
--- a/include/asm-frv/scatterlist.h
+++ b/include/asm-frv/scatterlist.h
@@ -16,8 +16,7 @@
16 * 16 *
17 * can be rewritten as 17 * can be rewritten as
18 * 18 *
19 * sg_set_page(virt_to_page(some_ptr)); 19 * sg_set_buf(sg, some_ptr, length);
20 * sg->offset = (unsigned long) some_ptr & ~PAGE_MASK;
21 * 20 *
22 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens 21 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
23 */ 22 */
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 **/
40static inline void sg_set_page(struct scatterlist *sg, struct page *page) 38static 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 **/
67static 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)
64static inline void sg_set_buf(struct scatterlist *sg, const void *buf, 84static 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/*