aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-01-18 08:45:10 -0500
committerRusty Russell <rusty@rustcorp.com.au>2010-02-23 22:52:48 -0500
commitcfa6d3792550c9eac51887181358954e6515da6b (patch)
tree2ee0ee37ad3289f57c082a3cba496898089ff1c2 /drivers/char
parent4f23c573c0dbebfd193cfb90b003d67929c58b31 (diff)
virtio: console: Separate out console init into a new function
Console ports could be hot-added. Also, with the new multiport support, a port is identified as a console port only if the host sends a control message. Move the console port init into a separate function so it can be invoked from other places. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/virtio_console.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index c6c6f52043b5..11e5fafcca52 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -346,6 +346,43 @@ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
346 return hvc_instantiate(0, 0, &hv_ops); 346 return hvc_instantiate(0, 0, &hv_ops);
347} 347}
348 348
349int __devinit init_port_console(struct port *port)
350{
351 int ret;
352
353 /*
354 * The Host's telling us this port is a console port. Hook it
355 * up with an hvc console.
356 *
357 * To set up and manage our virtual console, we call
358 * hvc_alloc().
359 *
360 * The first argument of hvc_alloc() is the virtual console
361 * number. The second argument is the parameter for the
362 * notification mechanism (like irq number). We currently
363 * leave this as zero, virtqueues have implicit notifications.
364 *
365 * The third argument is a "struct hv_ops" containing the
366 * put_chars() get_chars(), notifier_add() and notifier_del()
367 * pointers. The final argument is the output buffer size: we
368 * can do any size, so we put PAGE_SIZE here.
369 */
370 port->cons.vtermno = pdrvdata.next_vtermno;
371
372 port->cons.hvc = hvc_alloc(port->cons.vtermno, 0, &hv_ops, PAGE_SIZE);
373 if (IS_ERR(port->cons.hvc)) {
374 ret = PTR_ERR(port->cons.hvc);
375 port->cons.hvc = NULL;
376 return ret;
377 }
378 spin_lock_irq(&pdrvdata_lock);
379 pdrvdata.next_vtermno++;
380 list_add_tail(&port->cons.list, &pdrvdata.consoles);
381 spin_unlock_irq(&pdrvdata_lock);
382
383 return 0;
384}
385
349static int __devinit add_port(struct ports_device *portdev) 386static int __devinit add_port(struct ports_device *portdev)
350{ 387{
351 struct port *port; 388 struct port *port;
@@ -367,29 +404,9 @@ static int __devinit add_port(struct ports_device *portdev)
367 goto free_port; 404 goto free_port;
368 } 405 }
369 406
370 /* 407 err = init_port_console(port);
371 * The first argument of hvc_alloc() is the virtual console 408 if (err)
372 * number. The second argument is the parameter for the
373 * notification mechanism (like irq number). We currently
374 * leave this as zero, virtqueues have implicit notifications.
375 *
376 * The third argument is a "struct hv_ops" containing the
377 * put_chars(), get_chars(), notifier_add() and notifier_del()
378 * pointers. The final argument is the output buffer size: we
379 * can do any size, so we put PAGE_SIZE here.
380 */
381 port->cons.vtermno = pdrvdata.next_vtermno;
382 port->cons.hvc = hvc_alloc(port->cons.vtermno, 0, &hv_ops, PAGE_SIZE);
383 if (IS_ERR(port->cons.hvc)) {
384 err = PTR_ERR(port->cons.hvc);
385 goto free_inbuf; 409 goto free_inbuf;
386 }
387
388 /* Add to vtermno list. */
389 spin_lock_irq(&pdrvdata_lock);
390 pdrvdata.next_vtermno++;
391 list_add(&port->cons.list, &pdrvdata.consoles);
392 spin_unlock_irq(&pdrvdata_lock);
393 410
394 /* Register the input buffer the first time. */ 411 /* Register the input buffer the first time. */
395 add_inbuf(port->in_vq, port->inbuf); 412 add_inbuf(port->in_vq, port->inbuf);