diff options
Diffstat (limited to 'include/linux/scatterlist.h')
-rw-r--r-- | include/linux/scatterlist.h | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 457123171389..259735044148 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h | |||
@@ -150,7 +150,7 @@ static inline struct scatterlist *sg_last(struct scatterlist *sgl, | |||
150 | struct scatterlist *ret = &sgl[nents - 1]; | 150 | struct scatterlist *ret = &sgl[nents - 1]; |
151 | #else | 151 | #else |
152 | struct scatterlist *sg, *ret = NULL; | 152 | struct scatterlist *sg, *ret = NULL; |
153 | int i; | 153 | unsigned int i; |
154 | 154 | ||
155 | for_each_sg(sgl, sg, nents, i) | 155 | for_each_sg(sgl, sg, nents, i) |
156 | ret = sg; | 156 | ret = sg; |
@@ -179,48 +179,32 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, | |||
179 | #ifndef ARCH_HAS_SG_CHAIN | 179 | #ifndef ARCH_HAS_SG_CHAIN |
180 | BUG(); | 180 | BUG(); |
181 | #endif | 181 | #endif |
182 | prv[prv_nents - 1].page_link = (unsigned long) sgl | 0x01; | 182 | /* |
183 | * Set lowest bit to indicate a link pointer, and make sure to clear | ||
184 | * the termination bit if it happens to be set. | ||
185 | */ | ||
186 | prv[prv_nents - 1].page_link = ((unsigned long) sgl | 0x01) & ~0x02; | ||
183 | } | 187 | } |
184 | 188 | ||
185 | /** | 189 | /** |
186 | * sg_mark_end - Mark the end of the scatterlist | 190 | * sg_mark_end - Mark the end of the scatterlist |
187 | * @sgl: Scatterlist | 191 | * @sg: SG entryScatterlist |
188 | * @nents: Number of entries in sgl | ||
189 | * | 192 | * |
190 | * Description: | 193 | * Description: |
191 | * Marks the last entry as the termination point for sg_next() | 194 | * Marks the passed in sg entry as the termination point for the sg |
192 | * | 195 | * table. A call to sg_next() on this entry will return NULL. |
193 | **/ | ||
194 | static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents) | ||
195 | { | ||
196 | sgl[nents - 1].page_link = 0x02; | ||
197 | } | ||
198 | |||
199 | static inline void __sg_mark_end(struct scatterlist *sg) | ||
200 | { | ||
201 | sg->page_link |= 0x02; | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * sg_init_one - Initialize a single entry sg list | ||
206 | * @sg: SG entry | ||
207 | * @buf: Virtual address for IO | ||
208 | * @buflen: IO length | ||
209 | * | ||
210 | * Notes: | ||
211 | * This should not be used on a single entry that is part of a larger | ||
212 | * table. Use sg_init_table() for that. | ||
213 | * | 196 | * |
214 | **/ | 197 | **/ |
215 | static inline void sg_init_one(struct scatterlist *sg, const void *buf, | 198 | static inline void sg_mark_end(struct scatterlist *sg) |
216 | unsigned int buflen) | ||
217 | { | 199 | { |
218 | memset(sg, 0, sizeof(*sg)); | ||
219 | #ifdef CONFIG_DEBUG_SG | 200 | #ifdef CONFIG_DEBUG_SG |
220 | sg->sg_magic = SG_MAGIC; | 201 | BUG_ON(sg->sg_magic != SG_MAGIC); |
221 | #endif | 202 | #endif |
222 | sg_mark_end(sg, 1); | 203 | /* |
223 | sg_set_buf(sg, buf, buflen); | 204 | * Set termination bit, clear potential chain bit |
205 | */ | ||
206 | sg->page_link |= 0x02; | ||
207 | sg->page_link &= ~0x01; | ||
224 | } | 208 | } |
225 | 209 | ||
226 | /** | 210 | /** |
@@ -236,14 +220,32 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf, | |||
236 | static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) | 220 | static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) |
237 | { | 221 | { |
238 | memset(sgl, 0, sizeof(*sgl) * nents); | 222 | memset(sgl, 0, sizeof(*sgl) * nents); |
239 | sg_mark_end(sgl, nents); | ||
240 | #ifdef CONFIG_DEBUG_SG | 223 | #ifdef CONFIG_DEBUG_SG |
241 | { | 224 | { |
242 | int i; | 225 | unsigned int i; |
243 | for (i = 0; i < nents; i++) | 226 | for (i = 0; i < nents; i++) |
244 | sgl[i].sg_magic = SG_MAGIC; | 227 | sgl[i].sg_magic = SG_MAGIC; |
245 | } | 228 | } |
246 | #endif | 229 | #endif |
230 | sg_mark_end(&sgl[nents - 1]); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * sg_init_one - Initialize a single entry sg list | ||
235 | * @sg: SG entry | ||
236 | * @buf: Virtual address for IO | ||
237 | * @buflen: IO length | ||
238 | * | ||
239 | * Notes: | ||
240 | * This should not be used on a single entry that is part of a larger | ||
241 | * table. Use sg_init_table() for that. | ||
242 | * | ||
243 | **/ | ||
244 | static inline void sg_init_one(struct scatterlist *sg, const void *buf, | ||
245 | unsigned int buflen) | ||
246 | { | ||
247 | sg_init_table(sg, 1); | ||
248 | sg_set_buf(sg, buf, buflen); | ||
247 | } | 249 | } |
248 | 250 | ||
249 | /** | 251 | /** |