From: Jens Axboe Date: Wed, 9 May 2007 07:02:57 +0000 (+0200) Subject: Add sg helpers for iterating over a scatterlist table X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=96b418c960af0d5c7185ff5c4af9376eb37ac9d3;p=openwrt%2Fstaging%2Fblogic.git 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: Jens Axboe --- diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 4efbd9c445f5..bed5ab4d756a 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -20,4 +20,13 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf, 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 */