diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-02-12 00:02:16 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-02-23 22:53:04 -0500 |
commit | 7177876fea8306a6f49400d11f5913bf9b3b5e5f (patch) | |
tree | e9354be211c692f59bc61fcb72c4dd638f06dffa /drivers/char/virtio_console.c | |
parent | a9cdd4855738906043b8131cfe8055d6cde88ffe (diff) |
virtio: console: Add ability to remove module
Add the ability to remove the virtio_console module.
This aids debugging.
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.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 69d2e616dd0c..0057bae2036f 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -1448,6 +1448,36 @@ fail: | |||
1448 | return err; | 1448 | return err; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | static void virtcons_remove(struct virtio_device *vdev) | ||
1452 | { | ||
1453 | struct ports_device *portdev; | ||
1454 | struct port *port, *port2; | ||
1455 | struct port_buffer *buf; | ||
1456 | unsigned int len; | ||
1457 | |||
1458 | portdev = vdev->priv; | ||
1459 | |||
1460 | cancel_work_sync(&portdev->control_work); | ||
1461 | cancel_work_sync(&portdev->config_work); | ||
1462 | |||
1463 | list_for_each_entry_safe(port, port2, &portdev->ports, list) | ||
1464 | remove_port(port); | ||
1465 | |||
1466 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); | ||
1467 | |||
1468 | while ((buf = portdev->c_ivq->vq_ops->get_buf(portdev->c_ivq, &len))) | ||
1469 | free_buf(buf); | ||
1470 | |||
1471 | while ((buf = portdev->c_ivq->vq_ops->detach_unused_buf(portdev->c_ivq))) | ||
1472 | free_buf(buf); | ||
1473 | |||
1474 | vdev->config->del_vqs(vdev); | ||
1475 | kfree(portdev->in_vqs); | ||
1476 | kfree(portdev->out_vqs); | ||
1477 | |||
1478 | kfree(portdev); | ||
1479 | } | ||
1480 | |||
1451 | static struct virtio_device_id id_table[] = { | 1481 | static struct virtio_device_id id_table[] = { |
1452 | { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, | 1482 | { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, |
1453 | { 0 }, | 1483 | { 0 }, |
@@ -1465,6 +1495,7 @@ static struct virtio_driver virtio_console = { | |||
1465 | .driver.owner = THIS_MODULE, | 1495 | .driver.owner = THIS_MODULE, |
1466 | .id_table = id_table, | 1496 | .id_table = id_table, |
1467 | .probe = virtcons_probe, | 1497 | .probe = virtcons_probe, |
1498 | .remove = virtcons_remove, | ||
1468 | .config_changed = config_intr, | 1499 | .config_changed = config_intr, |
1469 | }; | 1500 | }; |
1470 | 1501 | ||
@@ -1488,7 +1519,17 @@ static int __init init(void) | |||
1488 | 1519 | ||
1489 | return register_virtio_driver(&virtio_console); | 1520 | return register_virtio_driver(&virtio_console); |
1490 | } | 1521 | } |
1522 | |||
1523 | static void __exit fini(void) | ||
1524 | { | ||
1525 | unregister_virtio_driver(&virtio_console); | ||
1526 | |||
1527 | class_destroy(pdrvdata.class); | ||
1528 | if (pdrvdata.debugfs_dir) | ||
1529 | debugfs_remove_recursive(pdrvdata.debugfs_dir); | ||
1530 | } | ||
1491 | module_init(init); | 1531 | module_init(init); |
1532 | module_exit(fini); | ||
1492 | 1533 | ||
1493 | MODULE_DEVICE_TABLE(virtio, id_table); | 1534 | MODULE_DEVICE_TABLE(virtio, id_table); |
1494 | MODULE_DESCRIPTION("Virtio console driver"); | 1535 | MODULE_DESCRIPTION("Virtio console driver"); |