summaryrefslogtreecommitdiffstats
path: root/include/linux/scatterlist.h
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-31 12:06:37 +0100
committerJens Axboe <axboe@carl.home.kernel.dk>2007-11-02 08:47:06 +0100
commitc46f2334c84c2b26baa64d42d75ddc5fab38c3dc (patch)
tree4d7800effffe61bd3eaeae8f13e44466e4818b36 /include/linux/scatterlist.h
parent87ae9afdcada236d0a1b38ce2c465a65916961dc (diff)
downloadop-kernel-dev-c46f2334c84c2b26baa64d42d75ddc5fab38c3dc.zip
op-kernel-dev-c46f2334c84c2b26baa64d42d75ddc5fab38c3dc.tar.gz
[SG] Get rid of __sg_mark_end()
sg_mark_end() overwrites the page_link information, but all users want __sg_mark_end() behaviour where we just set the end bit. That is the most natural way to use the sg list, since you'll fill it in and then mark the end point. So change sg_mark_end() to only set the termination bit. Add a sg_magic debug check as well, and clear a chain pointer if it is set. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux/scatterlist.h')
-rw-r--r--include/linux/scatterlist.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index d5e1876..2597350 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -188,21 +188,23 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
/**
* sg_mark_end - Mark the end of the scatterlist
- * @sgl: Scatterlist
- * @nents: Number of entries in sgl
+ * @sg: SG entryScatterlist
*
* Description:
- * Marks the last entry as the termination point for sg_next()
+ * Marks the passed in sg entry as the termination point for the sg
+ * table. A call to sg_next() on this entry will return NULL.
*
**/
-static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents)
-{
- sgl[nents - 1].page_link = 0x02;
-}
-
-static inline void __sg_mark_end(struct scatterlist *sg)
+static inline void sg_mark_end(struct scatterlist *sg)
{
+#ifdef CONFIG_DEBUG_SG
+ BUG_ON(sg->sg_magic != SG_MAGIC);
+#endif
+ /*
+ * Set termination bit, clear potential chain bit
+ */
sg->page_link |= 0x02;
+ sg->page_link &= ~0x01;
}
/**
@@ -218,7 +220,6 @@ static inline void __sg_mark_end(struct scatterlist *sg)
static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
{
memset(sgl, 0, sizeof(*sgl) * nents);
- sg_mark_end(sgl, nents);
#ifdef CONFIG_DEBUG_SG
{
unsigned int i;
@@ -226,6 +227,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
sgl[i].sg_magic = SG_MAGIC;
}
#endif
+ sg_mark_end(&sgl[nents - 1]);
}
/**
OpenPOWER on IntegriCloud