[PATCH 20/25] Staging: hv: Use the probe function in struct hv_driver

2011-04-26 Thread K. Y. Srinivasan
Use the newly introduced probe function.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/blkvsc_drv.c  |   19 +--
 drivers/staging/hv/hv_mouse.c|   11 +--
 drivers/staging/hv/netvsc_drv.c  |   19 +--
 drivers/staging/hv/storvsc_drv.c |   23 +++
 drivers/staging/hv/vmbus_drv.c   |5 ++---
 5 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index ec6a761..20b9a53 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -140,7 +140,7 @@ MODULE_PARM_DESC(ring_size, Ring buffer size (in bytes));
  * There is a circular dependency involving blkvsc_probe()
  * and block_ops.
  */
-static int blkvsc_probe(struct device *dev);
+static int blkvsc_probe(struct hv_device *dev);
 
 static int blk_vsc_on_device_add(struct hv_device *device,
void *additional_info)
@@ -882,7 +882,7 @@ static int blkvsc_drv_init(void)
 
drv-driver.name = storvsc_drv_obj-base.name;
 
-   drv-driver.probe = blkvsc_probe;
+   drv-probe = blkvsc_probe;
drv-driver.remove = blkvsc_remove;
drv-driver.shutdown = blkvsc_shutdown;
 
@@ -937,11 +937,10 @@ static void blkvsc_drv_exit(void)
 /*
  * blkvsc_probe - Add a new device for this driver
  */
-static int blkvsc_probe(struct device *device)
+static int blkvsc_probe(struct hv_device *dev)
 {
struct storvsc_driver_object *storvsc_drv_obj =
-   drv_to_stordrv(device-driver);
-   struct hv_device *device_obj = device_to_hv_device(device);
+   drv_to_stordrv(dev-device.driver);
 
struct block_device_context *blkdev = NULL;
struct storvsc_device_info device_info;
@@ -961,7 +960,7 @@ static int blkvsc_probe(struct device *device)
spin_lock_init(blkdev-lock);
 
 
-   blkdev-request_pool = kmem_cache_create(dev_name(device_obj-device),
+   blkdev-request_pool = kmem_cache_create(dev_name(dev-device),
sizeof(struct blkvsc_request), 0,
SLAB_HWCACHE_ALIGN, NULL);
if (!blkdev-request_pool) {
@@ -971,17 +970,17 @@ static int blkvsc_probe(struct device *device)
 
 
/* Call to the vsc driver to add the device */
-   ret = storvsc_drv_obj-base.dev_add(device_obj, device_info);
+   ret = storvsc_drv_obj-base.dev_add(dev, device_info);
if (ret != 0)
goto cleanup;
 
-   blkdev-device_ctx = device_obj;
+   blkdev-device_ctx = dev;
/* this identified the device 0 or 1 */
blkdev-target = device_info.target_id;
/* this identified the ide ctrl 0 or 1 */
blkdev-path = device_info.path_id;
 
-   dev_set_drvdata(device, blkdev);
+   dev_set_drvdata(dev-device, blkdev);
 
ret = stor_vsc_get_major_info(device_info, major_info);
 
@@ -1041,7 +1040,7 @@ static int blkvsc_probe(struct device *device)
return ret;
 
 remove:
-   storvsc_drv_obj-base.dev_rm(device_obj);
+   storvsc_drv_obj-base.dev_rm(dev);
 
 cleanup:
if (blkdev) {
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 4333247..e2363b3 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -832,23 +832,22 @@ static void mousevsc_hid_close(struct hid_device *hid)
 {
 }
 
-static int mousevsc_probe(struct device *device)
+static int mousevsc_probe(struct hv_device *dev)
 {
int ret = 0;
 
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;
 
input_dev_ctx = kmalloc(sizeof(struct input_device_context),
GFP_KERNEL);
 
-   dev_set_drvdata(device, input_dev_ctx);
+   dev_set_drvdata(dev-device, input_dev_ctx);
 
/* Call to the vsc driver to add the device */
-   ret = mousevsc_drv_obj-base.dev_add(device_obj, NULL);
+   ret = mousevsc_drv_obj-base.dev_add(dev, NULL);
 
if (ret != 0) {
DPRINT_ERR(INPUTVSC_DRV, unable to add input vsc device);
@@ -1023,7 +1022,7 @@ static int __init mousevsc_init(void)
 
drv-driver.name = input_drv_obj-base.name;
 
-   drv-driver.probe = mousevsc_probe;
+   drv-probe = mousevsc_probe;
drv-driver.remove = mousevsc_remove;
 
/* The driver belongs to vmbus */
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index e61eb7e..685a6f5 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ 

Re: [PATCH 20/25] Staging: hv: Use the probe function in struct hv_driver

2011-04-26 Thread Christoph Hellwig
 @@ -882,7 +882,7 @@ static int blkvsc_drv_init(void)
  
   drv-driver.name = storvsc_drv_obj-base.name;
  
 - drv-driver.probe = blkvsc_probe;
 + drv-probe = blkvsc_probe;
   drv-driver.remove = blkvsc_remove;
   drv-driver.shutdown = blkvsc_shutdown;

Not new in this patch, but you should really declare the driver as a
static object and initialize it at compile time, similar to how it's 
done for PCI and countless other busses, e.g.

struct hv_driver blkvsc_driver {
.name   = blkvsc,
.probe  = blkvsc_probe,
.remove = blkvsc_remove,
.shutdown   = blkvsc_shutdown,
};

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization