aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/virtio_console.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 1dbd46cb1a26..df45e5e9a947 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -77,6 +77,22 @@ fail:
77 return NULL; 77 return NULL;
78} 78}
79 79
80/* Callers should take appropriate locks */
81static void *get_inbuf(struct port *port)
82{
83 struct port_buffer *buf;
84 struct virtqueue *vq;
85 unsigned int len;
86
87 vq = port->in_vq;
88 buf = vq->vq_ops->get_buf(vq, &len);
89 if (buf) {
90 buf->len = len;
91 buf->offset = 0;
92 }
93 return buf;
94}
95
80/* 96/*
81 * Create a scatter-gather list representing our input buffer and put 97 * Create a scatter-gather list representing our input buffer and put
82 * it in the queue. 98 * it in the queue.
@@ -138,7 +154,6 @@ static int put_chars(u32 vtermno, const char *buf, int count)
138static int get_chars(u32 vtermno, char *buf, int count) 154static int get_chars(u32 vtermno, char *buf, int count)
139{ 155{
140 struct port *port; 156 struct port *port;
141 unsigned int len;
142 157
143 port = &console; 158 port = &console;
144 159
@@ -147,10 +162,8 @@ static int get_chars(u32 vtermno, char *buf, int count)
147 162
148 /* No more in buffer? See if they've (re)used it. */ 163 /* No more in buffer? See if they've (re)used it. */
149 if (port->inbuf->offset == port->inbuf->len) { 164 if (port->inbuf->offset == port->inbuf->len) {
150 if (!port->in_vq->vq_ops->get_buf(port->in_vq, &len)) 165 if (!get_inbuf(port))
151 return 0; 166 return 0;
152 port->inbuf->offset = 0;
153 port->inbuf->len = len;
154 } 167 }
155 168
156 /* You want more than we have to give? Well, try wanting less! */ 169 /* You want more than we have to give? Well, try wanting less! */