int users;
};
-static const char *drv_name = "blkvsc";
/*
* There is a circular dependency involving blkvsc_request_completion()
/* The one and only one */
static struct hv_driver blkvsc_drv = {
+ .name = "blkvsc",
.id_table = id_table,
.probe = blkvsc_probe,
.remove = blkvsc_remove,
*/
static int blkvsc_drv_init(void)
{
- struct hv_driver *drv = &blkvsc_drv;
- int ret;
-
BUILD_BUG_ON(sizeof(sector_t) != 8);
-
- drv->driver.name = drv_name;
-
- /* The driver belongs to vmbus */
- ret = vmbus_child_driver_register(&drv->driver);
-
- return ret;
+ return vmbus_driver_register(&blkvsc_drv);
}
-
static void blkvsc_drv_exit(void)
{
-
- vmbus_child_driver_unregister(&blkvsc_drv.driver);
+ vmbus_driver_unregister(&blkvsc_drv);
}
/*
};
-static const char *driver_name = "mousevsc";
-
static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
/* MODULE_DEVICE_TABLE(vmbus, id_table); */
static struct hv_driver mousevsc_drv = {
+ .name = "mousevsc",
.id_table = id_table,
.probe = mousevsc_probe,
.remove = mousevsc_remove,
};
-static void mousevsc_drv_exit(void)
-{
- vmbus_child_driver_unregister(&mousevsc_drv.driver);
-}
-
static int __init mousevsc_init(void)
{
- struct hv_driver *drv = &mousevsc_drv;
-
- DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
-
- drv->driver.name = driver_name;
-
- /* The driver belongs to vmbus */
- vmbus_child_driver_register(&drv->driver);
-
- return 0;
+ return vmbus_driver_register(&mousevsc_drv);
}
static void __exit mousevsc_exit(void)
{
- mousevsc_drv_exit();
+ vmbus_driver_unregister(&mousevsc_drv);
}
/*
static u8 *time_txf_buf;
static u8 *hbeat_txf_buf;
-static const char *driver_name = "hv_util";
-
static void shutdown_onchannelcallback(void *context)
{
struct vmbus_channel *channel = context;
/* The one and only one */
static struct hv_driver util_drv = {
+ .name = "hv_util",
.id_table = id_table,
.probe = util_probe,
.remove = util_remove,
hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
- util_drv.driver.name = driver_name;
-
- return vmbus_child_driver_register(&util_drv.driver);
+ return vmbus_driver_register(&util_drv);
}
static void exit_hyperv_utils(void)
kfree(shut_txf_buf);
kfree(time_txf_buf);
kfree(hbeat_txf_buf);
- vmbus_child_driver_unregister(&util_drv.driver);
+ vmbus_driver_unregister(&util_drv);
}
module_init(init_hyperv_utils);
/* Vmbus interface */
-int vmbus_child_driver_register(struct device_driver *drv);
-void vmbus_child_driver_unregister(struct device_driver *drv);
+#define vmbus_driver_register(driver) \
+ __vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
+int __must_check __vmbus_driver_register(struct hv_driver *hv_driver,
+ struct module *owner,
+ const char *mod_name);
+void vmbus_driver_unregister(struct hv_driver *hv_driver);
/**
* VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device
unsigned int status);
int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet);
-int netvsc_initialize(struct hv_driver *drv);
int rndis_filter_open(struct hv_device *dev);
int rndis_filter_close(struct hv_device *dev);
int rndis_filter_device_add(struct hv_device *dev,
#include "hyperv_net.h"
-/* Globals */
-static const char *driver_name = "netvsc";
-
static struct netvsc_device *alloc_net_device(struct hv_device *device)
{
struct netvsc_device *net_device;
return ret;
}
-
-/*
- * netvsc_initialize - Main entry point
- */
-int netvsc_initialize(struct hv_driver *drv)
-{
-
- drv->name = driver_name;
-
- return 0;
-}
/* The one and only one */
static struct hv_driver netvsc_drv = {
+ .name = "netvsc",
.id_table = id_table,
.probe = netvsc_probe,
.remove = netvsc_remove,
static void __exit netvsc_drv_exit(void)
{
- vmbus_child_driver_unregister(&netvsc_drv.driver);
+ vmbus_driver_unregister(&netvsc_drv);
}
-
static int __init netvsc_drv_init(void)
{
- struct hv_driver *drv = &netvsc_drv;
- int ret;
-
- pr_info("initializing....");
-
- /* Callback to client driver to complete the initialization */
- netvsc_initialize(drv);
-
- drv->driver.name = drv->name;
-
- /* The driver belongs to vmbus */
- ret = vmbus_child_driver_register(&drv->driver);
-
- return ret;
+ return vmbus_driver_register(&netvsc_drv);
}
MODULE_LICENSE("GPL");
module_param(storvsc_ringbuffer_size, int, S_IRUGO);
MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
-static const char *driver_name = "storvsc";
-
struct hv_host_device {
struct hv_device *dev;
struct kmem_cache *request_pool;
/* The one and only one */
static struct hv_driver storvsc_drv = {
+ .name = "storvsc",
.id_table = id_table,
.probe = storvsc_probe,
.remove = storvsc_remove,
static int __init storvsc_drv_init(void)
{
- int ret;
- struct hv_driver *drv = &storvsc_drv;
u32 max_outstanding_req_per_channel;
/*
* the ring buffer indices) by the max request size (which is
* vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
*/
-
max_outstanding_req_per_channel =
- ((storvsc_ringbuffer_size - PAGE_SIZE) /
- ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
- sizeof(struct vstor_packet) + sizeof(u64),
- sizeof(u64)));
+ ((storvsc_ringbuffer_size - PAGE_SIZE) /
+ ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
+ sizeof(struct vstor_packet) + sizeof(u64),
+ sizeof(u64)));
if (max_outstanding_req_per_channel <
STORVSC_MAX_IO_REQUESTS)
return -1;
- drv->driver.name = driver_name;
-
-
- /* The driver belongs to vmbus */
- ret = vmbus_child_driver_register(&drv->driver);
-
- return ret;
+ return vmbus_driver_register(&storvsc_drv);
}
static void __exit storvsc_drv_exit(void)
{
- vmbus_child_driver_unregister(&storvsc_drv.driver);
+ vmbus_driver_unregister(&storvsc_drv);
}
MODULE_LICENSE("GPL");
}
/**
- * vmbus_child_driver_register() - Register a vmbus's child driver
- * @drv: Pointer to driver structure you want to register
- *
+ * __vmbus_child_driver_register - Register a vmbus's driver
+ * @drv: Pointer to driver structure you want to register
+ * @owner: owner module of the drv
+ * @mod_name: module name string
*
* Registers the given driver with Linux through the 'driver_register()' call
- * And sets up the hyper-v vmbus handling for this driver.
+ * and sets up the hyper-v vmbus handling for this driver.
* It will return the state of the 'driver_register()' call.
*
- * Mainly used by Hyper-V drivers.
*/
-int vmbus_child_driver_register(struct device_driver *drv)
+int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, const char *mod_name)
{
int ret;
- pr_info("child driver registering - name %s\n", drv->name);
+ pr_info("registering driver %s\n", hv_driver->name);
- /* The child driver on this vmbus */
- drv->bus = &hv_bus;
+ hv_driver->driver.name = hv_driver->name;
+ hv_driver->driver.owner = owner;
+ hv_driver->driver.mod_name = mod_name;
+ hv_driver->driver.bus = &hv_bus;
- ret = driver_register(drv);
+ ret = driver_register(&hv_driver->driver);
vmbus_request_offers();
return ret;
}
-EXPORT_SYMBOL(vmbus_child_driver_register);
+EXPORT_SYMBOL_GPL(__vmbus_driver_register);
/**
- * vmbus_child_driver_unregister() - Unregister a vmbus's child driver
- * @drv: Pointer to driver structure you want to un-register
- *
- *
- * Un-register the given driver with Linux through the 'driver_unregister()'
- * call. And ungegisters the driver from the Hyper-V vmbus handler.
+ * vmbus_driver_unregister() - Unregister a vmbus's driver
+ * @drv: Pointer to driver structure you want to un-register
*
- * Mainly used by Hyper-V drivers.
+ * Un-register the given driver that was previous registered with a call to
+ * vmbus_driver_register()
*/
-void vmbus_child_driver_unregister(struct device_driver *drv)
+void vmbus_driver_unregister(struct hv_driver *hv_driver)
{
- pr_info("child driver unregistering - name %s\n", drv->name);
+ pr_info("unregistering driver %s\n", hv_driver->name);
- driver_unregister(drv);
+ driver_unregister(&hv_driver->driver);
}
-EXPORT_SYMBOL(vmbus_child_driver_unregister);
+EXPORT_SYMBOL_GPL(vmbus_driver_unregister);
/*
* vmbus_child_device_create - Creates and registers a new child device