diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-09-14 13:06:45 +0530 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-11-02 11:41:00 +1030 |
commit | 2d24cdaa6e389f85dad51eda39f1c2684a4f15b0 (patch) | |
tree | 88f02e92c459fa8d768c1ae6fbcfa8a4ccfcdc0e /drivers/char/virtio_console.c | |
parent | ce072a0cee420782ed0a079ac17c7ca26056fb95 (diff) | |
download | op-kernel-dev-2d24cdaa6e389f85dad51eda39f1c2684a4f15b0.zip op-kernel-dev-2d24cdaa6e389f85dad51eda39f1c2684a4f15b0.tar.gz |
virtio: console: make discard_port_data() use get_inbuf()
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>
Diffstat (limited to 'drivers/char/virtio_console.c')
-rw-r--r-- | drivers/char/virtio_console.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 0538425..105181c 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -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); |