]> err.no Git - linux-2.6/blobdiff - include/linux/scatterlist.h
Merge branch 'for-2.6.24' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerp...
[linux-2.6] / include / linux / scatterlist.h
index d5e1876daf3febe7105646b72b20d74bdbcdcabd..25973504414823b7876d2f34256ea1f103018ddb 100644 (file)
@@ -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]);
 }
 
 /**