Commit 415b023a authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: Use the remove() function in struct hv_driver

Use the newly introduced remove() function in struct hv_driver.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarAbhishek Kane <v-abkane@microsoft.com>
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 63e69e01
...@@ -537,19 +537,18 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) ...@@ -537,19 +537,18 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
/* /*
* blkvsc_remove() - Callback when our device is removed * blkvsc_remove() - Callback when our device is removed
*/ */
static int blkvsc_remove(struct device *device) static int blkvsc_remove(struct hv_device *dev)
{ {
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
drv_to_stordrv(device->driver); drv_to_stordrv(dev->device.driver);
struct hv_device *device_obj = device_to_hv_device(device); struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
struct block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags; unsigned long flags;
/* /*
* Call to the vsc driver to let it know that the device is being * Call to the vsc driver to let it know that the device is being
* removed * removed
*/ */
storvsc_drv_obj->base.dev_rm(device_obj); storvsc_drv_obj->base.dev_rm(dev);
/* Get to a known state */ /* Get to a known state */
spin_lock_irqsave(&blkdev->lock, flags); spin_lock_irqsave(&blkdev->lock, flags);
...@@ -883,7 +882,7 @@ static int blkvsc_drv_init(void) ...@@ -883,7 +882,7 @@ static int blkvsc_drv_init(void)
drv->driver.name = storvsc_drv_obj->base.name; drv->driver.name = storvsc_drv_obj->base.name;
drv->probe = blkvsc_probe; drv->probe = blkvsc_probe;
drv->driver.remove = blkvsc_remove; drv->remove = blkvsc_remove;
drv->driver.shutdown = blkvsc_shutdown; drv->driver.shutdown = blkvsc_shutdown;
/* The driver belongs to vmbus */ /* The driver belongs to vmbus */
......
...@@ -858,20 +858,19 @@ static int mousevsc_probe(struct hv_device *dev) ...@@ -858,20 +858,19 @@ static int mousevsc_probe(struct hv_device *dev)
return 0; return 0;
} }
static int mousevsc_remove(struct device *device) static int mousevsc_remove(struct hv_device *dev)
{ {
int ret = 0; int ret = 0;
struct mousevsc_drv_obj *mousevsc_drv_obj = struct mousevsc_drv_obj *mousevsc_drv_obj =
drv_to_mousedrv(device->driver); drv_to_mousedrv(dev->device.driver);
struct hv_device *device_obj = device_to_hv_device(device);
struct input_device_context *input_dev_ctx; struct input_device_context *input_dev_ctx;
input_dev_ctx = kmalloc(sizeof(struct input_device_context), input_dev_ctx = kmalloc(sizeof(struct input_device_context),
GFP_KERNEL); GFP_KERNEL);
dev_set_drvdata(device, input_dev_ctx); dev_set_drvdata(&dev->device, input_dev_ctx);
if (input_dev_ctx->connected) { if (input_dev_ctx->connected) {
hidinput_disconnect(input_dev_ctx->hid_device); hidinput_disconnect(input_dev_ctx->hid_device);
...@@ -885,7 +884,7 @@ static int mousevsc_remove(struct device *device) ...@@ -885,7 +884,7 @@ static int mousevsc_remove(struct device *device)
* Call to the vsc driver to let it know that the device * Call to the vsc driver to let it know that the device
* is being removed * is being removed
*/ */
ret = mousevsc_drv_obj->base.dev_rm(device_obj); ret = mousevsc_drv_obj->base.dev_rm(dev);
if (ret != 0) { if (ret != 0) {
DPRINT_ERR(INPUTVSC_DRV, DPRINT_ERR(INPUTVSC_DRV,
...@@ -1023,7 +1022,7 @@ static int __init mousevsc_init(void) ...@@ -1023,7 +1022,7 @@ static int __init mousevsc_init(void)
drv->driver.name = input_drv_obj->base.name; drv->driver.name = input_drv_obj->base.name;
drv->probe = mousevsc_probe; drv->probe = mousevsc_probe;
drv->driver.remove = mousevsc_remove; drv->remove = mousevsc_remove;
/* The driver belongs to vmbus */ /* The driver belongs to vmbus */
vmbus_child_driver_register(&drv->driver); vmbus_child_driver_register(&drv->driver);
......
...@@ -408,16 +408,15 @@ static int netvsc_probe(struct hv_device *dev) ...@@ -408,16 +408,15 @@ static int netvsc_probe(struct hv_device *dev)
return ret; return ret;
} }
static int netvsc_remove(struct device *device) static int netvsc_remove(struct hv_device *dev)
{ {
struct netvsc_driver *net_drv_obj = struct netvsc_driver *net_drv_obj =
drv_to_netvscdrv(device->driver); drv_to_netvscdrv(dev->device.driver);
struct hv_device *device_obj = device_to_hv_device(device); struct net_device *net = dev_get_drvdata(&dev->device);
struct net_device *net = dev_get_drvdata(&device_obj->device);
int ret; int ret;
if (net == NULL) { if (net == NULL) {
dev_err(device, "No net device to remove\n"); dev_err(&dev->device, "No net device to remove\n");
return 0; return 0;
} }
...@@ -434,7 +433,7 @@ static int netvsc_remove(struct device *device) ...@@ -434,7 +433,7 @@ static int netvsc_remove(struct device *device)
* Call to the vsc driver to let it know that the device is being * Call to the vsc driver to let it know that the device is being
* removed * removed
*/ */
ret = net_drv_obj->base.dev_rm(device_obj); ret = net_drv_obj->base.dev_rm(dev);
if (ret != 0) { if (ret != 0) {
/* TODO: */ /* TODO: */
netdev_err(net, "unable to remove vsc device (ret %d)\n", ret); netdev_err(net, "unable to remove vsc device (ret %d)\n", ret);
...@@ -501,7 +500,7 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) ...@@ -501,7 +500,7 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
drv->driver.name = net_drv_obj->base.name; drv->driver.name = net_drv_obj->base.name;
drv->probe = netvsc_probe; drv->probe = netvsc_probe;
drv->driver.remove = netvsc_remove; drv->remove = netvsc_remove;
/* The driver belongs to vmbus */ /* The driver belongs to vmbus */
ret = vmbus_child_driver_register(&drv->driver); ret = vmbus_child_driver_register(&drv->driver);
......
...@@ -128,7 +128,7 @@ static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd ...@@ -128,7 +128,7 @@ static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd
static int storvsc_device_alloc(struct scsi_device *); static int storvsc_device_alloc(struct scsi_device *);
static int storvsc_device_configure(struct scsi_device *); static int storvsc_device_configure(struct scsi_device *);
static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd); static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
static int storvsc_remove(struct device *dev); static int storvsc_remove(struct hv_device *dev);
static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl, static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
unsigned int sg_count, unsigned int sg_count,
...@@ -214,7 +214,7 @@ static int storvsc_drv_init(void) ...@@ -214,7 +214,7 @@ static int storvsc_drv_init(void)
drv->driver.name = storvsc_drv_obj->base.name; drv->driver.name = storvsc_drv_obj->base.name;
drv->probe = storvsc_probe; drv->probe = storvsc_probe;
drv->driver.remove = storvsc_remove; drv->remove = storvsc_remove;
/* The driver belongs to vmbus */ /* The driver belongs to vmbus */
ret = vmbus_child_driver_register(&drv->driver); ret = vmbus_child_driver_register(&drv->driver);
...@@ -398,12 +398,11 @@ static int storvsc_probe(struct hv_device *device) ...@@ -398,12 +398,11 @@ static int storvsc_probe(struct hv_device *device)
/* /*
* storvsc_remove - Callback when our device is removed * storvsc_remove - Callback when our device is removed
*/ */
static int storvsc_remove(struct device *device) static int storvsc_remove(struct hv_device *dev)
{ {
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
drv_to_stordrv(device->driver); drv_to_stordrv(dev->device.driver);
struct hv_device *device_obj = device_to_hv_device(device); struct Scsi_Host *host = dev_get_drvdata(&dev->device);
struct Scsi_Host *host = dev_get_drvdata(device);
struct host_device_context *host_device_ctx = struct host_device_context *host_device_ctx =
(struct host_device_context *)host->hostdata; (struct host_device_context *)host->hostdata;
...@@ -411,7 +410,7 @@ static int storvsc_remove(struct device *device) ...@@ -411,7 +410,7 @@ static int storvsc_remove(struct device *device)
* Call to the vsc driver to let it know that the device is being * Call to the vsc driver to let it know that the device is being
* removed * removed
*/ */
storvsc_drv_obj->base.dev_rm(device_obj); storvsc_drv_obj->base.dev_rm(dev);
if (host_device_ctx->request_pool) { if (host_device_ctx->request_pool) {
kmem_cache_destroy(host_device_ctx->request_pool); kmem_cache_destroy(host_device_ctx->request_pool);
......
...@@ -343,16 +343,13 @@ static int vmbus_remove(struct device *child_device) ...@@ -343,16 +343,13 @@ static int vmbus_remove(struct device *child_device)
int ret; int ret;
struct hv_driver *drv; struct hv_driver *drv;
struct hv_device *dev = device_to_hv_device(child_device);
if (child_device->driver) { if (child_device->driver) {
drv = drv_to_hv_drv(child_device->driver); drv = drv_to_hv_drv(child_device->driver);
/* if (drv->remove) {
* Let the specific open-source driver handles the removal if ret = drv->remove(dev);
* it can
*/
if (drv->driver.remove) {
ret = drv->driver.remove(child_device);
} else { } else {
pr_err("remove not set for driver %s\n", pr_err("remove not set for driver %s\n",
dev_name(child_device)); dev_name(child_device));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment