Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm
[linux-flexiantxendom0-3.2.10.git] / kernel / kfifo.c
index 02192dd..c744b88 100644 (file)
@@ -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
@@ -20,7 +20,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/log2.h>
@@ -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,11 +362,9 @@ 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)
-               sg_mark_end(sgl + n - 1);
        return n;
 }
 
@@ -504,6 +501,15 @@ unsigned int __kfifo_out_r(struct __kfifo *fifo, void *buf,
 }
 EXPORT_SYMBOL(__kfifo_out_r);
 
+void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize)
+{
+       unsigned int n;
+
+       n = __kfifo_peek_n(fifo, recsize);
+       fifo->out += n + recsize;
+}
+EXPORT_SYMBOL(__kfifo_skip_r);
+
 int __kfifo_from_user_r(struct __kfifo *fifo, const void __user *from,
        unsigned long len, unsigned int *copied, size_t recsize)
 {