]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Add sg helpers for iterating over a scatterlist table
authorJens Axboe <jens.axboe@oracle.com>
Wed, 9 May 2007 07:02:57 +0000 (09:02 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 16 Oct 2007 09:07:10 +0000 (11:07 +0200)
First step to being able to change the scatterlist setup without
having to modify drivers (a lot :-)

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
include/linux/scatterlist.h

index 4efbd9c445f5b3828590478cca2a3dac9c023d75..bed5ab4d756afa3728ee093766e6186287583368 100644 (file)
@@ -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 */