diff options
author | K. Y. Srinivasan | 2011-09-18 19:31:34 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2011-09-20 22:00:53 +0200 |
commit | 4e65f6e80593c316c5a65a71191fa480360f165d (patch) | |
tree | 29d3cbe68bd01e7b7cdcecccd70a797ca7eaf889 /drivers/staging/hv/hv_util.c | |
parent | Staging: hv: util: Perform some service specific init/deinit in probe/remove (diff) | |
download | kernel-qcow2-linux-4e65f6e80593c316c5a65a71191fa480360f165d.tar.gz kernel-qcow2-linux-4e65f6e80593c316c5a65a71191fa480360f165d.tar.xz kernel-qcow2-linux-4e65f6e80593c316c5a65a71191fa480360f165d.zip |
Staging: hv: util: Properly handle util services in the util driver
Now, properly handle util services in the util driver and eliminate code
that will not be necessary. In the current code, util services were
all handled not as other vmbus devices (net, block) but rather through
special handling (channel setup etc.). In this patch we handle all
services using the standard Linux Driver Model.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/hv_util.c')
-rw-r--r-- | drivers/staging/hv/hv_util.c | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c index a1539a7814d4..faa66074cc21 100644 --- a/drivers/staging/hv/hv_util.c +++ b/drivers/staging/hv/hv_util.c @@ -269,19 +269,32 @@ static int util_probe(struct hv_device *dev, if (srv->util_init) { ret = srv->util_init(srv); if (ret) { - kfree(srv->recv_buffer); - return -ENODEV; + ret = -ENODEV; + goto error1; } } + ret = vmbus_open(dev->channel, 2 * PAGE_SIZE, 2 * PAGE_SIZE, NULL, 0, + srv->util_cb, dev->channel); + if (ret) + goto error; + hv_set_drvdata(dev, srv); return 0; + +error: + if (srv->util_deinit) + srv->util_deinit(); +error1: + kfree(srv->recv_buffer); + return ret; } static int util_remove(struct hv_device *dev) { struct hv_util_service *srv = hv_get_drvdata(dev); + vmbus_close(dev->channel); if (srv->util_deinit) srv->util_deinit(); kfree(srv->recv_buffer); @@ -321,51 +334,15 @@ static struct hv_driver util_drv = { static int __init init_hyperv_utils(void) { - int ret; pr_info("Registering HyperV Utility Driver\n"); - - ret = vmbus_driver_register(&util_drv); - - if (ret != 0) - return ret; - - hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback; - - hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback; - - hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback; - - hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback; - - return 0; - + return vmbus_driver_register(&util_drv); } static void exit_hyperv_utils(void) { pr_info("De-Registered HyperV Utility Driver\n"); - if (hv_cb_utils[HV_SHUTDOWN_MSG].channel != NULL) - hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_SHUTDOWN_MSG].callback = NULL; - - if (hv_cb_utils[HV_TIMESYNC_MSG].channel != NULL) - hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_TIMESYNC_MSG].callback = NULL; - - if (hv_cb_utils[HV_HEARTBEAT_MSG].channel != NULL) - hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_HEARTBEAT_MSG].callback = NULL; - - if (hv_cb_utils[HV_KVP_MSG].channel != NULL) - hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback = - &chn_cb_negotiate; - hv_cb_utils[HV_KVP_MSG].callback = NULL; - vmbus_driver_unregister(&util_drv); } |