Commit 96b418c9 authored by Jens Axboe's avatar Jens Axboe

Add sg helpers for iterating over a scatterlist table

First step to being able to change the scatterlist setup without
having to modify drivers (a lot :-)
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent ab83407e
...@@ -20,4 +20,13 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf, ...@@ -20,4 +20,13 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf,
sg_set_buf(sg, buf, buflen); sg_set_buf(sg, buf, buflen);
} }
#define sg_next(sg) ((sg) + 1)
#define sg_last(sg, nents) (&(sg[(nents) - 1]))
/*
* Loop over each sg element, following the pointer to a new list if necessary
*/
#define for_each_sg(sglist, sg, nr, __i) \
for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
#endif /* _LINUX_SCATTERLIST_H */ #endif /* _LINUX_SCATTERLIST_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment