summaryrefslogtreecommitdiffstats
path: root/kernel/kfifo.c
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2010-08-11 23:17:27 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-12 17:43:29 +0200
commitd78a3eda6985e74bc21a23362f27526f73e71649 (patch)
treefe395ab0372893e66c8f1375ca8b11a33020d11f /kernel/kfifo.c
parentMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/vir... (diff)
downloadlinux-d78a3eda6985e74bc21a23362f27526f73e71649.tar.xz
linux-d78a3eda6985e74bc21a23362f27526f73e71649.zip
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/kfifo.c')
-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 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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,
buf += PAGE_SIZE;
npage = virt_to_page(buf);
if (page_to_phys(page) != page_to_phys(npage) - l) {
- sgl->page_link = 0;
- sg_set_page(sgl++, page, l - off, off);
- if (++n == nents)
+ sg_set_page(sgl, page, l - off, off);
+ sgl = sg_next(sgl);
+ if (++n == nents || sgl == NULL)
return n;
page = npage;
len -= l - off;
l = off = 0;
}
}
- sgl->page_link = 0;
- sg_set_page(sgl++, page, len, off);
+ sg_set_page(sgl, page, len, off);
return n + 1;
}
@@ -363,7 +362,7 @@ static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl,
}
l = min(len, size - off);
- n = setup_sgl_buf(sgl, fifo->data + off, nents, l);
+ n = setup_sgl_buf(sgl, fifo->data + off, nents, l);
n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l);
if (n)