]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/scatterlist.c
scatterlist: add sg_nents
[karo-tx-linux.git] / lib / scatterlist.c
index fadae774a20cc6abb0226ee4c3bfbc6cb4cd4eeb..1bf60efb5e02424368d0847af2894f900a3ad5d2 100644 (file)
@@ -38,6 +38,28 @@ struct scatterlist *sg_next(struct scatterlist *sg)
 }
 EXPORT_SYMBOL(sg_next);
 
+/**
+ * sg_nents - return total count of entries in scatterlist
+ * @sg:                The scatterlist
+ *
+ * Description:
+ * Allows to know how many entries are in sg, taking into acount
+ * chaining as well
+ *
+ **/
+int sg_nents(struct scatterlist *sg)
+{
+       int nents = 0;
+       while (sg) {
+               nents++;
+               sg = sg_next(sg);
+       }
+
+       return nents;
+}
+EXPORT_SYMBOL(sg_nents);
+
+
 /**
  * sg_last - return the last scatterlist entry in a list
  * @sgl:       First entry in the scatterlist