aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv/vmbus_drv.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hv/vmbus_drv.c')
-rw-r--r--drivers/hv/vmbus_drv.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 0c048dd8013f..a220e5746d67 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -62,6 +62,14 @@ struct hv_device_info {
62 struct hv_dev_port_info outbound; 62 struct hv_dev_port_info outbound;
63}; 63};
64 64
65static int vmbus_exists(void)
66{
67 if (hv_acpi_dev == NULL)
68 return -ENODEV;
69
70 return 0;
71}
72
65 73
66static void get_channel_info(struct hv_device *device, 74static void get_channel_info(struct hv_device *device,
67 struct hv_device_info *info) 75 struct hv_device_info *info)
@@ -590,6 +598,10 @@ int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, c
590 598
591 pr_info("registering driver %s\n", hv_driver->name); 599 pr_info("registering driver %s\n", hv_driver->name);
592 600
601 ret = vmbus_exists();
602 if (ret < 0)
603 return ret;
604
593 hv_driver->driver.name = hv_driver->name; 605 hv_driver->driver.name = hv_driver->name;
594 hv_driver->driver.owner = owner; 606 hv_driver->driver.owner = owner;
595 hv_driver->driver.mod_name = mod_name; 607 hv_driver->driver.mod_name = mod_name;
@@ -614,8 +626,8 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver)
614{ 626{
615 pr_info("unregistering driver %s\n", hv_driver->name); 627 pr_info("unregistering driver %s\n", hv_driver->name);
616 628
617 driver_unregister(&hv_driver->driver); 629 if (!vmbus_exists())
618 630 driver_unregister(&hv_driver->driver);
619} 631}
620EXPORT_SYMBOL_GPL(vmbus_driver_unregister); 632EXPORT_SYMBOL_GPL(vmbus_driver_unregister);
621 633
@@ -776,11 +788,23 @@ static int __init hv_acpi_init(void)
776 788
777cleanup: 789cleanup:
778 acpi_bus_unregister_driver(&vmbus_acpi_driver); 790 acpi_bus_unregister_driver(&vmbus_acpi_driver);
791 hv_acpi_dev = NULL;
779 return ret; 792 return ret;
780} 793}
781 794
795static void __exit vmbus_exit(void)
796{
797
798 free_irq(irq, hv_acpi_dev);
799 vmbus_free_channels();
800 bus_unregister(&hv_bus);
801 hv_cleanup();
802 acpi_bus_unregister_driver(&vmbus_acpi_driver);
803}
804
782 805
783MODULE_LICENSE("GPL"); 806MODULE_LICENSE("GPL");
784MODULE_VERSION(HV_DRV_VERSION); 807MODULE_VERSION(HV_DRV_VERSION);
785 808
786module_init(hv_acpi_init); 809subsys_initcall(hv_acpi_init);
810module_exit(vmbus_exit);