aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/virtio_console.c15
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)
386static void discard_port_data(struct port *port) 386static 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);