]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
virtio: console: make discard_port_data() use get_inbuf()
authorAmit Shah <amit.shah@redhat.com>
Wed, 14 Sep 2011 07:36:45 +0000 (13:06 +0530)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 24 Oct 2011 20:12:24 +0000 (07:12 +1100)
discard_port_data() used virtqueue_get_buf() directly instead of using
get_inbuf().  Fix this, so that we get accounting for all received
bytes.  This also simplifies the code a lot.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/virtio_console.c

index 0538425e9a71f52d1f7c749a174308b0b1893a47..105181c1e6beb848c1fe73f1c6a60a69959ac687 100644 (file)
@@ -386,28 +386,23 @@ static int add_inbuf(struct virtqueue *vq, struct port_buffer *buf)
 static void discard_port_data(struct port *port)
 {
        struct port_buffer *buf;
-       struct virtqueue *vq;
-       unsigned int len, err;
+       unsigned int err;
 
        if (!port->portdev) {
                /* Device has been unplugged.  vqs are already gone. */
                return;
        }
-       vq = port->in_vq;
-       if (port->inbuf)
-               buf = port->inbuf;
-       else
-               buf = virtqueue_get_buf(vq, &len);
+       buf = get_inbuf(port);
 
        err = 0;
        while (buf) {
-               if (add_inbuf(vq, buf) < 0) {
+               if (add_inbuf(port->in_vq, buf) < 0) {
                        err++;
                        free_buf(buf);
                }
-               buf = virtqueue_get_buf(vq, &len);
+               port->inbuf = NULL;
+               buf = get_inbuf(port);
        }
-       port->inbuf = NULL;
        if (err)
                dev_warn(port->dev, "Errors adding %d buffers back to vq\n",
                         err);