aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2010-08-11 17:17:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-12 11:43:29 -0400
commitd78a3eda6985e74bc21a23362f27526f73e71649 (patch)
treefe395ab0372893e66c8f1375ca8b11a33020d11f /kernel
parent5af568cbd55f60b5a1d174f621b273e4f585dc35 (diff)
kernel/kfifo.c: add handling of chained scatterlists
The current kfifo scatterlist implementation will not work with chained scatterlists. It assumes that struct scatterlist arrays are allocated contiguously, which is not the case when chained scatterlists (struct sg_table) are in use. Signed-off-by: Stefani Seibold <stefani@seibold.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kfifo.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 02192dd905cc..4502604ecadf 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -10,7 +10,7 @@
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
@@ -333,17 +333,16 @@ static int setup_sgl_buf(struct scatterlist *sgl, void *buf,
333 buf += PAGE_SIZE; 333 buf += PAGE_SIZE;
334 npage = virt_to_page(buf); 334 npage = virt_to_page(buf);
335 if (page_to_phys(page) != page_to_phys(npage) - l) { 335 if (page_to_phys(page) != page_to_phys(npage) - l) {
336 sgl->page_link = 0; 336 sg_set_page(sgl, page, l - off, off);
337 sg_set_page(sgl++, page, l - off, off); 337 sgl = sg_next(sgl);
338 if (++n == nents) 338 if (++n == nents || sgl == NULL)
339 return n; 339 return n;
340 page = npage; 340 page = npage;
341 len -= l - off; 341 len -= l - off;
342 l = off = 0; 342 l = off = 0;
343 } 343 }
344 } 344 }
345 sgl->page_link = 0; 345 sg_set_page(sgl, page, len, off);
346 sg_set_page(sgl++, page, len, off);
347 return n + 1; 346 return n + 1;
348} 347}
349 348
@@ -363,7 +362,7 @@ static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl,
363 } 362 }
364 l = min(len, size - off); 363 l = min(len, size - off);
365 364
366 n = setup_sgl_buf(sgl, fifo->data + off, nents, l); 365 n = setup_sgl_buf(sgl, fifo->data + off, nents, l);
367 n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l); 366 n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l);
368 367
369 if (n) 368 if (n)