Merge tag 'for-4.17/block-20180402' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / include / linux / scatterlist.h
index b6fe1815f5c4affe0fc0b5f3e0b2bba278ead808..51f52020ad5fdd44ab4fdfa6ad2e0063c4780947 100644 (file)
@@ -251,6 +251,24 @@ static inline void *sg_virt(struct scatterlist *sg)
        return page_address(sg_page(sg)) + sg->offset;
 }
 
+/**
+ * sg_init_marker - Initialize markers in sg table
+ * @sgl:          The SG table
+ * @nents:        Number of entries in table
+ *
+ **/
+static inline void sg_init_marker(struct scatterlist *sgl,
+                                 unsigned int nents)
+{
+#ifdef CONFIG_DEBUG_SG
+       unsigned int i;
+
+       for (i = 0; i < nents; i++)
+               sgl[i].sg_magic = SG_MAGIC;
+#endif
+       sg_mark_end(&sgl[nents - 1]);
+}
+
 int sg_nents(struct scatterlist *sg);
 int sg_nents_for_len(struct scatterlist *sg, u64 len);
 struct scatterlist *sg_next(struct scatterlist *);