]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/char/virtio_console.c
Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvar...
[linux.git] / drivers / char / virtio_console.c
index 3259426f01dc9776f5fdcfcebff966192b74616e..4df9b40d63422a79239e3ef4e1b2dc09c644f942 100644 (file)
@@ -919,6 +919,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
                .pos = *ppos,
                .u.data = &sgl,
        };
+       unsigned int occupancy;
 
        /*
         * Rproc_serial does not yet support splice. To support splice
@@ -929,21 +930,18 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
        if (is_rproc_serial(port->out_vq->vdev))
                return -EINVAL;
 
-       /*
-        * pipe->nrbufs == 0 means there are no data to transfer,
-        * so this returns just 0 for no data.
-        */
        pipe_lock(pipe);
-       if (!pipe->nrbufs) {
-               ret = 0;
+       ret = 0;
+       if (pipe_empty(pipe->head, pipe->tail))
                goto error_out;
-       }
 
        ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
        if (ret < 0)
                goto error_out;
 
-       buf = alloc_buf(port->portdev->vdev, 0, pipe->nrbufs);
+       occupancy = pipe_occupancy(pipe->head, pipe->tail);
+       buf = alloc_buf(port->portdev->vdev, 0, occupancy);
+
        if (!buf) {
                ret = -ENOMEM;
                goto error_out;
@@ -951,7 +949,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
 
        sgl.n = 0;
        sgl.len = 0;
-       sgl.size = pipe->nrbufs;
+       sgl.size = occupancy;
        sgl.sg = buf->sg;
        sg_init_table(sgl.sg, sgl.size);
        ret = __splice_from_pipe(pipe, &sd, pipe_to_sg);