aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/virtio_console.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/virtio_console.c')
-rw-r--r--drivers/char/virtio_console.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 3516aeb7f06c..cb5edf33bebf 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -351,11 +351,12 @@ fail:
351static struct port_buffer *get_inbuf(struct port *port) 351static struct port_buffer *get_inbuf(struct port *port)
352{ 352{
353 struct port_buffer *buf; 353 struct port_buffer *buf;
354 struct virtqueue *vq;
355 unsigned int len; 354 unsigned int len;
356 355
357 vq = port->in_vq; 356 if (port->inbuf)
358 buf = virtqueue_get_buf(vq, &len); 357 return port->inbuf;
358
359 buf = virtqueue_get_buf(port->in_vq, &len);
359 if (buf) { 360 if (buf) {
360 buf->len = len; 361 buf->len = len;
361 buf->offset = 0; 362 buf->offset = 0;
@@ -418,18 +419,12 @@ static bool port_has_data(struct port *port)
418 unsigned long flags; 419 unsigned long flags;
419 bool ret; 420 bool ret;
420 421
422 ret = false;
421 spin_lock_irqsave(&port->inbuf_lock, flags); 423 spin_lock_irqsave(&port->inbuf_lock, flags);
422 if (port->inbuf) {
423 ret = true;
424 goto out;
425 }
426 port->inbuf = get_inbuf(port); 424 port->inbuf = get_inbuf(port);
427 if (port->inbuf) { 425 if (port->inbuf)
428 ret = true; 426 ret = true;
429 goto out; 427
430 }
431 ret = false;
432out:
433 spin_unlock_irqrestore(&port->inbuf_lock, flags); 428 spin_unlock_irqrestore(&port->inbuf_lock, flags);
434 return ret; 429 return ret;
435} 430}
@@ -1489,8 +1484,7 @@ static void in_intr(struct virtqueue *vq)
1489 return; 1484 return;
1490 1485
1491 spin_lock_irqsave(&port->inbuf_lock, flags); 1486 spin_lock_irqsave(&port->inbuf_lock, flags);
1492 if (!port->inbuf) 1487 port->inbuf = get_inbuf(port);
1493 port->inbuf = get_inbuf(port);
1494 1488
1495 /* 1489 /*
1496 * Don't queue up data when port is closed. This condition 1490 * Don't queue up data when port is closed. This condition