aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/virtio_console.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-01-18 08:45:02 -0500
committerRusty Russell <rusty@rustcorp.com.au>2010-02-23 22:52:37 -0500
commite27b519807e04d950802cb89f7b22933d8d2f837 (patch)
tree4d79ffc7fb76b35d74a9198553ee7972c52c3ec7 /drivers/char/virtio_console.c
parentfdb9a054554e1e435e927c9a47a999f026abd408 (diff)
virtio: console: ensure add_inbuf can work for multiple ports as well
add_inbuf() assumed one port and one inbuf per port. Remove that assumption. Also move the function so that put_chars and get_chars are together. 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.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 699fc98ec8d9..1dbd46cb1a26 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -78,6 +78,22 @@ fail:
78} 78}
79 79
80/* 80/*
81 * Create a scatter-gather list representing our input buffer and put
82 * it in the queue.
83 *
84 * Callers should take appropriate locks.
85 */
86static void add_inbuf(struct virtqueue *vq, struct port_buffer *buf)
87{
88 struct scatterlist sg[1];
89 sg_init_one(sg, buf->buf, buf->size);
90
91 if (vq->vq_ops->add_buf(vq, sg, 0, 1, buf) < 0)
92 BUG();
93 vq->vq_ops->kick(vq);
94}
95
96/*
81 * The put_chars() callback is pretty straightforward. 97 * The put_chars() callback is pretty straightforward.
82 * 98 *
83 * We turn the characters into a scatter-gather list, add it to the 99 * We turn the characters into a scatter-gather list, add it to the
@@ -112,21 +128,6 @@ static int put_chars(u32 vtermno, const char *buf, int count)
112} 128}
113 129
114/* 130/*
115 * Create a scatter-gather list representing our input buffer and put
116 * it in the queue.
117 */
118static void add_inbuf(struct port *port)
119{
120 struct scatterlist sg[1];
121 sg_init_one(sg, port->inbuf->buf, PAGE_SIZE);
122
123 /* Should always be able to add one buffer to an empty queue. */
124 if (port->in_vq->vq_ops->add_buf(port->in_vq, sg, 0, 1, port) < 0)
125 BUG();
126 port->in_vq->vq_ops->kick(port->in_vq);
127}
128
129/*
130 * get_chars() is the callback from the hvc_console infrastructure 131 * get_chars() is the callback from the hvc_console infrastructure
131 * when an interrupt is received. 132 * when an interrupt is received.
132 * 133 *
@@ -162,7 +163,7 @@ static int get_chars(u32 vtermno, char *buf, int count)
162 163
163 /* Finished? Re-register buffer so Host will use it again. */ 164 /* Finished? Re-register buffer so Host will use it again. */
164 if (port->inbuf->offset == port->inbuf->len) 165 if (port->inbuf->offset == port->inbuf->len)
165 add_inbuf(port); 166 add_inbuf(port->in_vq, port->inbuf);
166 167
167 return count; 168 return count;
168} 169}
@@ -294,7 +295,7 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
294 } 295 }
295 296
296 /* Register the input buffer the first time. */ 297 /* Register the input buffer the first time. */
297 add_inbuf(port); 298 add_inbuf(port->in_vq, port->inbuf);
298 299
299 /* Start using the new console output. */ 300 /* Start using the new console output. */
300 early_put_chars = NULL; 301 early_put_chars = NULL;