aboutsummaryrefslogtreecommitdiff
path: root/drivers/char/virtio_console.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-01-18 19:15:02 +0530
committerRusty Russell <rusty@rustcorp.com.au>2010-02-24 14:22:37 +1030
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 699fc98ec8d..1dbd46cb1a2 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -78,6 +78,22 @@ fail:
}
/*
+ * Create a scatter-gather list representing our input buffer and put
+ * it in the queue.
+ *
+ * Callers should take appropriate locks.
+ */
+static void add_inbuf(struct virtqueue *vq, struct port_buffer *buf)
+{
+ struct scatterlist sg[1];
+ sg_init_one(sg, buf->buf, buf->size);
+
+ if (vq->vq_ops->add_buf(vq, sg, 0, 1, buf) < 0)
+ BUG();
+ vq->vq_ops->kick(vq);
+}
+
+/*
* The put_chars() callback is pretty straightforward.
*
* 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)
}
/*
- * Create a scatter-gather list representing our input buffer and put
- * it in the queue.
- */
-static void add_inbuf(struct port *port)
-{
- struct scatterlist sg[1];
- sg_init_one(sg, port->inbuf->buf, PAGE_SIZE);
-
- /* Should always be able to add one buffer to an empty queue. */
- if (port->in_vq->vq_ops->add_buf(port->in_vq, sg, 0, 1, port) < 0)
- BUG();
- port->in_vq->vq_ops->kick(port->in_vq);
-}
-
-/*
* get_chars() is the callback from the hvc_console infrastructure
* when an interrupt is received.
*
@@ -162,7 +163,7 @@ static int get_chars(u32 vtermno, char *buf, int count)
/* Finished? Re-register buffer so Host will use it again. */
if (port->inbuf->offset == port->inbuf->len)
- add_inbuf(port);
+ add_inbuf(port->in_vq, port->inbuf);
return count;
}
@@ -294,7 +295,7 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
}
/* Register the input buffer the first time. */
- add_inbuf(port);
+ add_inbuf(port->in_vq, port->inbuf);
/* Start using the new console output. */
early_put_chars = NULL;