diff options
| -rw-r--r-- | include/linux/scatterlist.h | 1 | ||||
| -rw-r--r-- | lib/scatterlist.c | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 7b600da9a635..4bd6c06eb28e 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h | |||
| @@ -201,6 +201,7 @@ static inline void *sg_virt(struct scatterlist *sg) | |||
| 201 | return page_address(sg_page(sg)) + sg->offset; | 201 | return page_address(sg_page(sg)) + sg->offset; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | int sg_nents(struct scatterlist *sg); | ||
| 204 | struct scatterlist *sg_next(struct scatterlist *); | 205 | struct scatterlist *sg_next(struct scatterlist *); |
| 205 | struct scatterlist *sg_last(struct scatterlist *s, unsigned int); | 206 | struct scatterlist *sg_last(struct scatterlist *s, unsigned int); |
| 206 | void sg_init_table(struct scatterlist *, unsigned int); | 207 | void sg_init_table(struct scatterlist *, unsigned int); |
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index fadae774a20c..1bf60efb5e02 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c | |||
| @@ -39,6 +39,28 @@ struct scatterlist *sg_next(struct scatterlist *sg) | |||
| 39 | EXPORT_SYMBOL(sg_next); | 39 | EXPORT_SYMBOL(sg_next); |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * sg_nents - return total count of entries in scatterlist | ||
| 43 | * @sg: The scatterlist | ||
| 44 | * | ||
| 45 | * Description: | ||
| 46 | * Allows to know how many entries are in sg, taking into acount | ||
| 47 | * chaining as well | ||
| 48 | * | ||
| 49 | **/ | ||
| 50 | int sg_nents(struct scatterlist *sg) | ||
| 51 | { | ||
| 52 | int nents = 0; | ||
| 53 | while (sg) { | ||
| 54 | nents++; | ||
| 55 | sg = sg_next(sg); | ||
| 56 | } | ||
| 57 | |||
| 58 | return nents; | ||
| 59 | } | ||
| 60 | EXPORT_SYMBOL(sg_nents); | ||
| 61 | |||
| 62 | |||
| 63 | /** | ||
| 42 | * sg_last - return the last scatterlist entry in a list | 64 | * sg_last - return the last scatterlist entry in a list |
| 43 | * @sgl: First entry in the scatterlist | 65 | * @sgl: First entry in the scatterlist |
| 44 | * @nents: Number of entries in the scatterlist | 66 | * @nents: Number of entries in the scatterlist |
