summaryrefslogtreecommitdiffstats
path: root/include/linux/scatterlist.h
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-24 11:20:47 +0200
committerJens Axboe <jens.axboe@oracle.com>2007-10-24 11:20:47 +0200
commit642f149031d70415d9318b919d50b71e4724adbd (patch)
treee792ad29dedffc6756d55e9d63e18ada35515b4b /include/linux/scatterlist.h
parentbd6dee6f30a0f6943df190b387b5f8fe98a848f3 (diff)
downloadblackbird-op-linux-642f149031d70415d9318b919d50b71e4724adbd.tar.gz
blackbird-op-linux-642f149031d70415d9318b919d50b71e4724adbd.zip
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/scatterlist.h')
-rw-r--r--include/linux/scatterlist.h40
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 @@
#define SG_MAGIC 0x87654321
/**
- * sg_set_page - Set sg entry to point at given page
- * @sg: SG entry
- * @page: The page
+ * sg_assign_page - Assign a given page to an SG entry
+ * @sg: SG entry
+ * @page: The page
*
* Description:
- * Use this function to set an sg entry pointing at a page, never assign
- * the page directly. We encode sg table information in the lower bits
- * of the page pointer. See sg_page() for looking up the page belonging
- * to an sg entry.
+ * Assign page to sg entry. Also see sg_set_page(), the most commonly used
+ * variant.
*
**/
-static inline void sg_set_page(struct scatterlist *sg, struct page *page)
+static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
{
unsigned long page_link = sg->page_link & 0x3;
@@ -52,6 +50,28 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
sg->page_link = page_link | (unsigned long) page;
}
+/**
+ * sg_set_page - Set sg entry to point at given page
+ * @sg: SG entry
+ * @page: The page
+ * @len: Length of data
+ * @offset: Offset into page
+ *
+ * Description:
+ * Use this function to set an sg entry pointing at a page, never assign
+ * the page directly. We encode sg table information in the lower bits
+ * of the page pointer. See sg_page() for looking up the page belonging
+ * to an sg entry.
+ *
+ **/
+static inline void sg_set_page(struct scatterlist *sg, struct page *page,
+ unsigned int len, unsigned int offset)
+{
+ sg_assign_page(sg, page);
+ sg->offset = offset;
+ sg->length = len;
+}
+
#define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3))
/**
@@ -64,9 +84,7 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
unsigned int buflen)
{
- sg_set_page(sg, virt_to_page(buf));
- sg->offset = offset_in_page(buf);
- sg->length = buflen;
+ sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
}
/*
OpenPOWER on IntegriCloud