Commit 768fa219 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Staging: hv: fix up driver registering mess



Individual drivers should never be touching the 'struct device' field,
so if that is a requirement to pass to the vmbus core, you know
something is wrong.

This patch fixes that all up, and resolves the problem where the module
reference counting was not happening properly for the individual drivers
as well.  Overall, it reduces the lines of code the individual drivers
have to have, which tells you that this is the correct thing to do.

Also, somehow the _GPL marking for the functions got removed on an older
patch.  As the name of the function was changing, properly change the
_GPL marking as well at the same time.

Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c411a598
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ struct block_device_context {
	int users;
};

static const char *drv_name = "blkvsc";

/*
 * There is a circular dependency involving blkvsc_request_completion()
@@ -805,6 +804,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table);

/* The one and only one */
static  struct hv_driver blkvsc_drv = {
	.name = "blkvsc",
	.id_table = id_table,
	.probe =  blkvsc_probe,
	.remove =  blkvsc_remove,
@@ -824,24 +824,13 @@ static const struct block_device_operations block_ops = {
 */
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);
}

/*
+3 −18
Original line number Diff line number Diff line
@@ -176,8 +176,6 @@ struct mousevsc_dev {
};


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);
@@ -921,33 +919,20 @@ static const struct hv_vmbus_device_id id_table[] = {
/* 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);
}

/*
+3 −6
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ static u8 *shut_txf_buf;
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;
@@ -244,6 +242,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table);

/* The one and only one */
static  struct hv_driver util_drv = {
	.name = "hv_util",
	.id_table = id_table,
	.probe =  util_probe,
	.remove =  util_remove,
@@ -277,9 +276,7 @@ static int __init init_hyperv_utils(void)

	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)
@@ -311,7 +308,7 @@ 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);
+6 −2
Original line number Diff line number Diff line
@@ -845,8 +845,12 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)


/* 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
+0 −1
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
				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,
Loading