diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/scatterlist.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index fadae77..1bf60ef 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -39,6 +39,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 * @nents: Number of entries in the scatterlist |