diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-09-14 03:36:45 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-11-01 21:11:00 -0400 |
commit | 2d24cdaa6e389f85dad51eda39f1c2684a4f15b0 (patch) | |
tree | 88f02e92c459fa8d768c1ae6fbcfa8a4ccfcdc0e /drivers/char | |
parent | ce072a0cee420782ed0a079ac17c7ca26056fb95 (diff) |
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')
-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 0538425e9a71..105181c1e6be 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) | |||
386 | static void discard_port_data(struct port *port) | 386 | static void discard_port_data(struct port *port) |
387 | { | 387 | { |
388 | struct port_buffer *buf; | 388 | struct port_buffer *buf; |
389 | struct virtqueue *vq; | 389 | unsigned int err; |
390 | unsigned int len, err; | ||
391 | 390 | ||
392 | if (!port->portdev) { | 391 | if (!port->portdev) { |
393 | /* Device has been unplugged. vqs are already gone. */ | 392 | /* Device has been unplugged. vqs are already gone. */ |
394 | return; | 393 | return; |
395 | } | 394 | } |
396 | vq = port->in_vq; | 395 | buf = get_inbuf(port); |
397 | if (port->inbuf) | ||
398 | buf = port->inbuf; | ||
399 | else | ||
400 | buf = virtqueue_get_buf(vq, &len); | ||
401 | 396 | ||
402 | err = 0; | 397 | err = 0; |
403 | while (buf) { | 398 | while (buf) { |
404 | if (add_inbuf(vq, buf) < 0) { | 399 | if (add_inbuf(port->in_vq, buf) < 0) { |
405 | err++; | 400 | err++; |
406 | free_buf(buf); | 401 | free_buf(buf); |
407 | } | 402 | } |
408 | buf = virtqueue_get_buf(vq, &len); | 403 | port->inbuf = NULL; |
404 | buf = get_inbuf(port); | ||
409 | } | 405 | } |
410 | port->inbuf = NULL; | ||
411 | if (err) | 406 | if (err) |
412 | dev_warn(port->dev, "Errors adding %d buffers back to vq\n", | 407 | dev_warn(port->dev, "Errors adding %d buffers back to vq\n", |
413 | err); | 408 | err); |