From 013fb33972061ac65cdf3e1771267985e59deca1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 30 Oct 2007 10:34:33 +0100 Subject: SG: Make sg_init_one() use general table init functions Don't open code sg_init_one(), make it reuse sg_init_table(). Signed-off-by: Jens Axboe --- include/linux/scatterlist.h | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 32326c293d7..d5e1876daf3 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -205,28 +205,6 @@ static inline void __sg_mark_end(struct scatterlist *sg) sg->page_link |= 0x02; } -/** - * sg_init_one - Initialize a single entry sg list - * @sg: SG entry - * @buf: Virtual address for IO - * @buflen: IO length - * - * Notes: - * This should not be used on a single entry that is part of a larger - * table. Use sg_init_table() for that. - * - **/ -static inline void sg_init_one(struct scatterlist *sg, const void *buf, - unsigned int buflen) -{ - memset(sg, 0, sizeof(*sg)); -#ifdef CONFIG_DEBUG_SG - sg->sg_magic = SG_MAGIC; -#endif - sg_mark_end(sg, 1); - sg_set_buf(sg, buf, buflen); -} - /** * sg_init_table - Initialize SG table * @sgl: The SG table @@ -250,6 +228,24 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) #endif } +/** + * sg_init_one - Initialize a single entry sg list + * @sg: SG entry + * @buf: Virtual address for IO + * @buflen: IO length + * + * Notes: + * This should not be used on a single entry that is part of a larger + * table. Use sg_init_table() for that. + * + **/ +static inline void sg_init_one(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg_init_table(sg, 1); + sg_set_buf(sg, buf, buflen); +} + /** * sg_phys - Return physical address of an sg entry * @sg: SG entry -- cgit v1.2.3 From 87ae9afdcada236d0a1b38ce2c465a65916961dc Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 30 Oct 2007 10:35:04 +0100 Subject: cleanup asm/scatterlist.h includes Not architecture specific code should not #include . This patch therefore either replaces them with #include or simply removes them if they were unused. Signed-off-by: Adrian Bunk Signed-off-by: Jens Axboe --- include/net/esp.h | 2 +- include/rdma/ib_verbs.h | 2 +- include/scsi/libsas.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/net/esp.h b/include/net/esp.h index c1bc529809d..c05f529bff2 100644 --- a/include/net/esp.h +++ b/include/net/esp.h @@ -3,7 +3,7 @@ #include #include -#include +#include #define ESP_NUM_FAST_SG 4 diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 4bea182d711..11f39606e7d 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -48,9 +48,9 @@ #include #include #include +#include #include -#include #include union ib_gid { diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 8dda2d66b5b..a466c2cb895 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include struct block_device; -- cgit v1.2.3 From c46f2334c84c2b26baa64d42d75ddc5fab38c3dc Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 31 Oct 2007 12:06:37 +0100 Subject: [SG] Get rid of __sg_mark_end() sg_mark_end() overwrites the page_link information, but all users want __sg_mark_end() behaviour where we just set the end bit. That is the most natural way to use the sg list, since you'll fill it in and then mark the end point. So change sg_mark_end() to only set the termination bit. Add a sg_magic debug check as well, and clear a chain pointer if it is set. Signed-off-by: Jens Axboe --- include/linux/scatterlist.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index d5e1876daf3..25973504414 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -188,21 +188,23 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, /** * sg_mark_end - Mark the end of the scatterlist - * @sgl: Scatterlist - * @nents: Number of entries in sgl + * @sg: SG entryScatterlist * * Description: - * Marks the last entry as the termination point for sg_next() + * Marks the passed in sg entry as the termination point for the sg + * table. A call to sg_next() on this entry will return NULL. * **/ -static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents) -{ - sgl[nents - 1].page_link = 0x02; -} - -static inline void __sg_mark_end(struct scatterlist *sg) +static inline void sg_mark_end(struct scatterlist *sg) { +#ifdef CONFIG_DEBUG_SG + BUG_ON(sg->sg_magic != SG_MAGIC); +#endif + /* + * Set termination bit, clear potential chain bit + */ sg->page_link |= 0x02; + sg->page_link &= ~0x01; } /** @@ -218,7 +220,6 @@ static inline void __sg_mark_end(struct scatterlist *sg) static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) { memset(sgl, 0, sizeof(*sgl) * nents); - sg_mark_end(sgl, nents); #ifdef CONFIG_DEBUG_SG { unsigned int i; @@ -226,6 +227,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) sgl[i].sg_magic = SG_MAGIC; } #endif + sg_mark_end(&sgl[nents - 1]); } /** -- cgit v1.2.3