[PATCH 00/16] Staging: hv: Consolidate driver and device abstractions

2011-03-07 Thread K. Y. Srinivasan
Hyper-V has maintained both its class independent driver and 
device state in two independent data structures:
Driver state: struct driver_context (vmbus.h) and struct hv_driver
(vmbus_api.h)
Device state: struct vm_device (vmbus.h) and struct hv_device (vmbus_api.h)

While sruct driver_context and struct vm_device embed generic 
Linux abstractions of struct device_driver and struct device respectively; 
the lower level hyperv abstraction: struct hv_driver and struct hv_device
have maintained state needed to communicate with the host. This partitioning
made sense at a point in time when it was not clear how much of 
the hypervisor interaction would be open sourced. Given where we are
today, there is no reason to keep this layering. This patchset 
consolidates all the driver state into a single structure: 
struct hv_driver while all the device state is consolidated into
a single structure: struct hv_device. This consolidation simplifies
the code while simultaneously getting rid of redundant state -
for instance in the current code, both struct driver_context and
struct hv_driver both have state to represent the class as well as
instance id. We do this consolidation by moving state from higher
level structures (struct driver_context and struct vm_device) to
lower level structures (struct hv_driver and hv_device) respectively.

While it has not been a goal of this effort to cleanup structure and 
variable names, this consolidation effort has resulted in some cleanup
with regards to structure and variable names: a) Some of the badly
named structures have been eliminated (struct driver_context etc.) 
while hopefully all newly introduced names are acceptable.  

Patches 1 through 11 deal with consolidating the device driver
state while patches 12 through 16  deal with consolidating
device state.


Regards,

K. Y

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


[PATCH 01/16] Staging: hv: Use generic device_driver probe function

2011-03-07 Thread K. Y. Srinivasan
In preparation for moving all the state from struct driver_context
to struct hv_driver, eliminate the probe() function from
struct driver_context and use generic device_driver probe
function.

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

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 36a0adb..0dff557 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -186,7 +186,7 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
memcpy(drv_ctx-class_id, storvsc_drv_obj-base.dev_type,
   sizeof(struct hv_guid));
 
-   drv_ctx-probe = blkvsc_probe;
+   drv_ctx-driver.probe = blkvsc_probe;
drv_ctx-remove = blkvsc_remove;
drv_ctx-shutdown = blkvsc_shutdown;
 
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 1aaaef4..4a25f3b 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -1021,7 +1021,7 @@ static int __init mousevsc_init(void)
memcpy(drv_ctx-class_id, input_drv_obj-Base.dev_type,
   sizeof(struct hv_guid));
 
-   drv_ctx-probe = mousevsc_probe;
+   drv_ctx-driver.probe = mousevsc_probe;
drv_ctx-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 03f9740..083f0d3 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -511,7 +511,7 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
memcpy(drv_ctx-class_id, net_drv_obj-base.dev_type,
   sizeof(struct hv_guid));
 
-   drv_ctx-probe = netvsc_probe;
+   drv_ctx-driver.probe = netvsc_probe;
drv_ctx-remove = netvsc_remove;
 
/* The driver belongs to vmbus */
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index a8427ff..3fe4bdb 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -164,7 +164,7 @@ static int storvsc_drv_init(int (*drv_init)(struct 
hv_driver *drv))
memcpy(drv_ctx-class_id, storvsc_drv_obj-base.dev_type,
   sizeof(struct hv_guid));
 
-   drv_ctx-probe = storvsc_probe;
+   drv_ctx-driver.probe = storvsc_probe;
drv_ctx-remove = storvsc_remove;
 
/* The driver belongs to vmbus */
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 459c707..fee2a8f 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -919,8 +919,9 @@ static int vmbus_probe(struct device *child_device)
device_to_vm_device(child_device);
 
/* Let the specific open-source driver handles the probe if it can */
-   if (driver_ctx-probe) {
-   ret = device_ctx-probe_error = driver_ctx-probe(child_device);
+   if (driver_ctx-driver.probe) {
+   ret = device_ctx-probe_error =
+   driver_ctx-driver.probe(child_device);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV, probe() failed for device %s 
   (%p) on driver %s (%d)...,
-- 
1.5.5.6

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


[PATCH 03/16] Staging: hv: Use generic device_driver shutdown function

2011-03-07 Thread K. Y. Srinivasan
In preparation for moving all the state from struct driver_context
to struct hv_driver, eliminate the shutdown() function from
struct driver_context and use generic device_driver shutdown()
function.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/blkvsc_drv.c |2 +-
 drivers/staging/hv/vmbus_drv.c  |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 3e86a56..9ccd5dc 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -188,7 +188,7 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
 
drv_ctx-driver.probe = blkvsc_probe;
drv_ctx-driver.remove = blkvsc_remove;
-   drv_ctx-shutdown = blkvsc_shutdown;
+   drv_ctx-driver.shutdown = blkvsc_shutdown;
 
/* The driver belongs to vmbus */
ret = vmbus_child_driver_register(drv_ctx);
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 4df2be0..6ef5bee 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -1000,8 +1000,8 @@ static void vmbus_shutdown(struct device *child_device)
driver_ctx = driver_to_driver_context(child_device-driver);
 
/* Let the specific open-source driver handles the removal if it can */
-   if (driver_ctx-shutdown)
-   driver_ctx-shutdown(child_device);
+   if (driver_ctx-driver.shutdown)
+   driver_ctx-driver.shutdown(child_device);
 
return;
 }
-- 
1.5.5.6

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


[PATCH 02/16] Staging: hv: Use generic device_driver remove function

2011-03-07 Thread K. Y. Srinivasan
In preparation for moving all the state from struct driver_context
to struct hv_driver, eliminate the remove() function from
struct driver_context and use generic device_driver remove()
function.

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

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 0dff557..3e86a56 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -187,7 +187,7 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
   sizeof(struct hv_guid));
 
drv_ctx-driver.probe = blkvsc_probe;
-   drv_ctx-remove = blkvsc_remove;
+   drv_ctx-driver.remove = blkvsc_remove;
drv_ctx-shutdown = blkvsc_shutdown;
 
/* The driver belongs to vmbus */
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 4a25f3b..6e2a937 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -1022,7 +1022,7 @@ static int __init mousevsc_init(void)
   sizeof(struct hv_guid));
 
drv_ctx-driver.probe = mousevsc_probe;
-   drv_ctx-remove = mousevsc_remove;
+   drv_ctx-driver.remove = mousevsc_remove;
 
/* The driver belongs to vmbus */
vmbus_child_driver_register(drv_ctx);
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 083f0d3..e2013b5 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -512,7 +512,7 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
   sizeof(struct hv_guid));
 
drv_ctx-driver.probe = netvsc_probe;
-   drv_ctx-remove = netvsc_remove;
+   drv_ctx-driver.remove = netvsc_remove;
 
/* The driver belongs to vmbus */
ret = vmbus_child_driver_register(drv_ctx);
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 3fe4bdb..3855271 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -165,7 +165,7 @@ static int storvsc_drv_init(int (*drv_init)(struct 
hv_driver *drv))
   sizeof(struct hv_guid));
 
drv_ctx-driver.probe = storvsc_probe;
-   drv_ctx-remove = storvsc_remove;
+   drv_ctx-driver.remove = storvsc_remove;
 
/* The driver belongs to vmbus */
ret = vmbus_child_driver_register(drv_ctx);
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index fee2a8f..4df2be0 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -964,8 +964,8 @@ static int vmbus_remove(struct device *child_device)
 * Let the specific open-source driver handles the removal if
 * it can
 */
-   if (driver_ctx-remove) {
-   ret = driver_ctx-remove(child_device);
+   if (driver_ctx-driver.remove) {
+   ret = driver_ctx-driver.remove(child_device);
} else {
DPRINT_ERR(VMBUS_DRV,
   remove() method not set for driver - %s,
-- 
1.5.5.6

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


[PATCH 05/16] Staging: hv: Change the signature for vmbus_child_driver_register

2011-03-07 Thread K. Y. Srinivasan
In preparation for moving the element driver from the
struct driver_context to struct hv_driver, change the
signature for the function vmbus_child_driver_register()
to take a pointer to struct device_driver.

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

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 9ccd5dc..d5e1881 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -191,7 +191,7 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
drv_ctx-driver.shutdown = blkvsc_shutdown;
 
/* The driver belongs to vmbus */
-   ret = vmbus_child_driver_register(drv_ctx);
+   ret = vmbus_child_driver_register(drv_ctx-driver);
 
return ret;
 }
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6e2a937..d2290f8 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -1025,7 +1025,7 @@ static int __init mousevsc_init(void)
drv_ctx-driver.remove = mousevsc_remove;
 
/* The driver belongs to vmbus */
-   vmbus_child_driver_register(drv_ctx);
+   vmbus_child_driver_register(drv_ctx-driver);
 
return 0;
 }
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index e2013b5..a50a9a6 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -515,7 +515,7 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver 
*drv))
drv_ctx-driver.remove = netvsc_remove;
 
/* The driver belongs to vmbus */
-   ret = vmbus_child_driver_register(drv_ctx);
+   ret = vmbus_child_driver_register(drv_ctx-driver);
 
return ret;
 }
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 3855271..8ab8df5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -168,7 +168,7 @@ static int storvsc_drv_init(int (*drv_init)(struct 
hv_driver *drv))
drv_ctx-driver.remove = storvsc_remove;
 
/* The driver belongs to vmbus */
-   ret = vmbus_child_driver_register(drv_ctx);
+   ret = vmbus_child_driver_register(drv_ctx-driver);
 
return ret;
 }
diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index 8bcfb40..2295fe2 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -61,7 +61,7 @@ static inline struct driver_context 
*driver_to_driver_context(struct device_driv
 
 
 /* Vmbus interface */
-int vmbus_child_driver_register(struct driver_context *driver_ctx);
+int vmbus_child_driver_register(struct device_driver *drv);
 void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
 
 extern struct completion hv_channel_ready;
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 6ef5bee..685376b 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -617,9 +617,8 @@ static void vmbus_bus_exit(void)
 
 /**
  * vmbus_child_driver_register() - Register a vmbus's child driver
- * @driver_ctx:Pointer to driver structure you want to register
+ * @drv:Pointer to driver structure you want to register
  *
- * @driver_ctx is of type struct driver_context
  *
  * Registers the given driver with Linux through the 'driver_register()' call
  * And sets up the hyper-v vmbus handling for this driver.
@@ -627,17 +626,17 @@ static void vmbus_bus_exit(void)
  *
  * Mainly used by Hyper-V drivers.
  */
-int vmbus_child_driver_register(struct driver_context *driver_ctx)
+int vmbus_child_driver_register(struct device_driver *drv)
 {
int ret;
 
DPRINT_INFO(VMBUS_DRV, child driver (%p) registering - name %s,
-   driver_ctx, driver_ctx-driver.name);
+   drv, drv-name);
 
/* The child driver on this vmbus */
-   driver_ctx-driver.bus = vmbus_drv.bus;
+   drv-bus = vmbus_drv.bus;
 
-   ret = driver_register(driver_ctx-driver);
+   ret = driver_register(drv);
 
vmbus_request_offers();
 
-- 
1.5.5.6

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


[PATCH 04/16] Staging: hv: Remove unnecessary function pointers in driver_context

2011-03-07 Thread K. Y. Srinivasan
Get rid of the unnecessary function pointers for probe(),
remove() and shutdown() from struct driver_context.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/vmbus.h |8 
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index 42f2adb..8bcfb40 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -33,14 +33,6 @@ struct driver_context {
 
struct device_driver driver;
 
-   /*
-* Use these methods instead of the struct device_driver so 2.6 kernel
-* stops complaining
-* TODO - fix this!
-*/
-   int (*probe)(struct device *);
-   int (*remove)(struct device *);
-   void (*shutdown)(struct device *);
 };
 
 struct vm_device {
-- 
1.5.5.6

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


[PATCH 08/16] Staging: hv: Eliminate blkvsc_driver_context structure

2011-03-07 Thread K. Y. Srinivasan
With the consolidation of all driver state into one data structure;
blkvsc_driver_context structure is not needed; get rid of it.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/blkvsc_drv.c |   26 --
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index af0a529..0f9fb05 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -115,10 +115,6 @@ struct block_device_context {
int users;
 };
 
-/* Per driver */
-struct blkvsc_driver_context {
-   struct storvsc_driver_object drv_obj;
-};
 
 /* Static decl */
 static DEFINE_MUTEX(blkvsc_mutex);
@@ -153,7 +149,7 @@ module_param(blkvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, Ring buffer size (in bytes));
 
 /* The one and only one */
-static struct blkvsc_driver_context g_blkvsc_drv;
+static  struct storvsc_driver_object g_blkvsc_drv;
 
 static const struct block_device_operations block_ops = {
.owner = THIS_MODULE,
@@ -170,8 +166,8 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
 {
-   struct storvsc_driver_object *storvsc_drv_obj = g_blkvsc_drv.drv_obj;
-   struct hv_driver *drv = g_blkvsc_drv.drv_obj.base;
+   struct storvsc_driver_object *storvsc_drv_obj = g_blkvsc_drv;
+   struct hv_driver *drv = g_blkvsc_drv.base;
int ret;
 
storvsc_drv_obj-ring_buffer_size = blkvsc_ringbuffer_size;
@@ -202,8 +198,8 @@ static int blkvsc_drv_exit_cb(struct device *dev, void 
*data)
 
 static void blkvsc_drv_exit(void)
 {
-   struct storvsc_driver_object *storvsc_drv_obj = g_blkvsc_drv.drv_obj;
-   struct hv_driver *drv = g_blkvsc_drv.drv_obj.base;
+   struct storvsc_driver_object *storvsc_drv_obj = g_blkvsc_drv;
+   struct hv_driver *drv = g_blkvsc_drv.base;
struct device *current_dev;
int ret;
 
@@ -242,10 +238,8 @@ static int blkvsc_probe(struct device *device)
 {
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct blkvsc_driver_context *blkvsc_drv_ctx =
-   (struct blkvsc_driver_context *)drv-priv;
struct storvsc_driver_object *storvsc_drv_obj =
-   blkvsc_drv_ctx-drv_obj;
+   drv-priv;
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
 
@@ -727,10 +721,8 @@ static int blkvsc_remove(struct device *device)
 {
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct blkvsc_driver_context *blkvsc_drv_ctx =
-   (struct blkvsc_driver_context *)drv-priv;
struct storvsc_driver_object *storvsc_drv_obj =
-   blkvsc_drv_ctx-drv_obj;
+   drv-priv;
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
struct block_device_context *blkdev = dev_get_drvdata(device);
@@ -850,10 +842,8 @@ static int blkvsc_submit_request(struct blkvsc_request 
*blkvsc_req,
struct vm_device *device_ctx = blkdev-device_ctx;
struct hv_driver *drv =
drv_to_hv_drv(device_ctx-device.driver);
-   struct blkvsc_driver_context *blkvsc_drv_ctx =
-   (struct blkvsc_driver_context *)drv-priv;
struct storvsc_driver_object *storvsc_drv_obj =
-   blkvsc_drv_ctx-drv_obj;
+   drv-priv;
struct hv_storvsc_request *storvsc_req;
int ret;
 
-- 
1.5.5.6

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


[PATCH 10/16] Staging: hv: Eliminate netvsc_driver_context

2011-03-07 Thread K. Y. Srinivasan
With the consolidation of all driver state into one data structure;
netvsc_driver_context structure is not needed; get rid of it.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/netvsc_drv.c |   25 -
 1 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index fdcc8aa..f0d258c 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -48,9 +48,6 @@ struct net_device_context {
unsigned long avail;
 };
 
-struct netvsc_driver_context {
-   struct netvsc_driver drv_obj;
-};
 
 #define PACKET_PAGES_LOWATER  8
 /* Need this many pages to handle worst case fragmented packet */
@@ -61,7 +58,7 @@ module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, Ring buffer size (# of pages));
 
 /* The one and only one */
-static struct netvsc_driver_context g_netvsc_drv;
+static struct  netvsc_driver g_netvsc_drv;
 
 /* no-op so the netdev core doesn't return -EINVAL when modifying the the
  * multicast address list in SIOCADDMULTI. hv is setup to get all multicast
@@ -134,9 +131,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct 
net_device *net)
struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_driver *drv =
drv_to_hv_drv(net_device_ctx-device_ctx-device.driver);
-   struct netvsc_driver_context *net_drv_ctx =
-   (struct netvsc_driver_context *)drv-priv;
-   struct netvsc_driver *net_drv_obj = net_drv_ctx-drv_obj;
+   struct netvsc_driver *net_drv_obj = drv-priv;
struct hv_netvsc_packet *packet;
int ret;
unsigned int i, num_pages;
@@ -339,9 +334,7 @@ static int netvsc_probe(struct device *device)
 {
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct netvsc_driver_context *net_drv_ctx =
-   (struct netvsc_driver_context *)drv-priv;
-   struct netvsc_driver *net_drv_obj = net_drv_ctx-drv_obj;
+   struct netvsc_driver *net_drv_obj = drv-priv;
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
struct net_device *net = NULL;
@@ -411,9 +404,7 @@ static int netvsc_remove(struct device *device)
 {
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct netvsc_driver_context *net_drv_ctx =
-   (struct netvsc_driver_context *)drv-priv;
-   struct netvsc_driver *net_drv_obj = net_drv_ctx-drv_obj;
+   struct netvsc_driver *net_drv_obj = drv-priv;
struct vm_device *device_ctx = device_to_vm_device(device);
struct net_device *net = dev_get_drvdata(device_ctx-device);
struct hv_device *device_obj = device_ctx-device_obj;
@@ -458,8 +449,8 @@ static int netvsc_drv_exit_cb(struct device *dev, void 
*data)
 
 static void netvsc_drv_exit(void)
 {
-   struct netvsc_driver *netvsc_drv_obj = g_netvsc_drv.drv_obj;
-   struct hv_driver *drv = g_netvsc_drv.drv_obj.base;
+   struct netvsc_driver *netvsc_drv_obj = g_netvsc_drv;
+   struct hv_driver *drv = g_netvsc_drv.base;
struct device *current_dev;
int ret;
 
@@ -493,8 +484,8 @@ static void netvsc_drv_exit(void)
 
 static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
 {
-   struct netvsc_driver *net_drv_obj = g_netvsc_drv.drv_obj;
-   struct hv_driver *drv = g_netvsc_drv.drv_obj.base;
+   struct netvsc_driver *net_drv_obj = g_netvsc_drv;
+   struct hv_driver *drv = g_netvsc_drv.base;
int ret;
 
net_drv_obj-ring_buf_size = ring_size * PAGE_SIZE;
-- 
1.5.5.6

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


[PATCH 11/16] Staging: hv: Eliminate storvsc_driver_context structure

2011-03-07 Thread K. Y. Srinivasan
With the consolidation of all driver state into one data structure;
storvsc_driver_context structure is not needed; get rid of it.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/storvsc_drv.c |   28 
 1 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 3300993..9722734 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -63,9 +63,6 @@ struct storvsc_cmd_request {
 * Which sounds like a very bad design... */
 };
 
-struct storvsc_driver_context {
-   struct storvsc_driver_object drv_obj;
-};
 
 /* Static decl */
 static int storvsc_probe(struct device *dev);
@@ -97,7 +94,7 @@ module_param(storvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_ringbuffer_size, Ring buffer size (bytes));
 
 /* The one and only one */
-static struct storvsc_driver_context g_storvsc_drv;
+static struct storvsc_driver_object g_storvsc_drv;
 
 /* Scsi driver */
 static struct scsi_host_template scsi_driver = {
@@ -134,8 +131,8 @@ static struct scsi_host_template scsi_driver = {
 static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
 {
int ret;
-   struct storvsc_driver_object *storvsc_drv_obj = g_storvsc_drv.drv_obj;
-   struct hv_driver *drv = g_storvsc_drv.drv_obj.base;
+   struct storvsc_driver_object *storvsc_drv_obj = g_storvsc_drv;
+   struct hv_driver *drv = g_storvsc_drv.base;
 
storvsc_drv_obj-ring_buffer_size = storvsc_ringbuffer_size;
 
@@ -179,8 +176,8 @@ static int storvsc_drv_exit_cb(struct device *dev, void 
*data)
 
 static void storvsc_drv_exit(void)
 {
-   struct storvsc_driver_object *storvsc_drv_obj = g_storvsc_drv.drv_obj;
-   struct hv_driver *drv = g_storvsc_drv.drv_obj.base;
+   struct storvsc_driver_object *storvsc_drv_obj = g_storvsc_drv;
+   struct hv_driver *drv = g_storvsc_drv.base;
struct device *current_dev = NULL;
int ret;
 
@@ -218,10 +215,7 @@ static int storvsc_probe(struct device *device)
int ret;
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct storvsc_driver_context *storvsc_drv_ctx =
-   (struct storvsc_driver_context *)drv-priv;
-   struct storvsc_driver_object *storvsc_drv_obj =
-   storvsc_drv_ctx-drv_obj;
+   struct storvsc_driver_object *storvsc_drv_obj = drv-priv;
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
struct Scsi_Host *host;
@@ -303,10 +297,7 @@ static int storvsc_remove(struct device *device)
int ret;
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct storvsc_driver_context *storvsc_drv_ctx =
-   (struct storvsc_driver_context *)drv-priv;
-   struct storvsc_driver_object *storvsc_drv_obj =
-   storvsc_drv_ctx-drv_obj;
+   struct storvsc_driver_object *storvsc_drv_obj = drv-priv;
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
struct Scsi_Host *host = dev_get_drvdata(device);
@@ -601,10 +592,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd 
*scmnd,
struct vm_device *device_ctx = host_device_ctx-device_ctx;
struct hv_driver *drv =
drv_to_hv_drv(device_ctx-device.driver);
-   struct storvsc_driver_context *storvsc_drv_ctx =
-   (struct storvsc_driver_context *)drv-priv;
-   struct storvsc_driver_object *storvsc_drv_obj =
-   storvsc_drv_ctx-drv_obj;
+   struct storvsc_driver_object *storvsc_drv_obj = drv-priv;
struct hv_storvsc_request *request;
struct storvsc_cmd_request *cmd_request;
unsigned int request_size = 0;
-- 
1.5.5.6

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


[PATCH 14/16] Staging: hv: Get rid of class_id from vm_device

2011-03-07 Thread K. Y. Srinivasan
Both device abstractions: vm_device and hv_device maintain state
to reperesent the device type (and they refer to them by different
names - class_id in vm_device and dev_type in hv_device). 
In preparation for consolidating all device state in
struct hv_device; eliminate class_id from struct vm_device.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/vmbus.h |1 -
 drivers/staging/hv/vmbus_drv.c |   60 +++
 2 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index ecd2d2f..a809f00 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -30,7 +30,6 @@
 
 
 struct vm_device {
-   struct hv_guid class_id;
struct hv_guid device_id;
struct hv_device device_obj;
struct device device;
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 0fcf377..d9d138d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -546,8 +546,6 @@ static int vmbus_bus_init(void)
}
/* strcpy(dev_ctx-device.bus_id, dev_ctx-device_obj.name); */
dev_set_name(dev_ctx-device, vmbus_0_0);
-   memcpy(dev_ctx-class_id, dev_ctx-device_obj.dev_type,
-   sizeof(struct hv_guid));
memcpy(dev_ctx-device_id, dev_ctx-device_obj.dev_instance,
sizeof(struct hv_guid));
 
@@ -704,7 +702,6 @@ struct hv_device *vmbus_child_device_create(struct hv_guid 
*type,
memcpy(child_device_obj-dev_instance, instance,
   sizeof(struct hv_guid));
 
-   memcpy(child_device_ctx-class_id, type, sizeof(struct hv_guid));
memcpy(child_device_ctx-device_id, instance, sizeof(struct hv_guid));
 
return child_device_obj;
@@ -785,42 +782,43 @@ void vmbus_child_device_unregister(struct hv_device 
*device_obj)
 static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 {
struct vm_device *device_ctx = device_to_vm_device(device);
+   struct hv_device *dev = device_ctx-device_obj;
int ret;
 
DPRINT_INFO(VMBUS_DRV, generating uevent - VMBUS_DEVICE_CLASS_GUID={
%02x%02x%02x%02x-%02x%02x-%02x%02x-
%02x%02x%02x%02x%02x%02x%02x%02x},
-   device_ctx-class_id.data[3], device_ctx-class_id.data[2],
-   device_ctx-class_id.data[1], device_ctx-class_id.data[0],
-   device_ctx-class_id.data[5], device_ctx-class_id.data[4],
-   device_ctx-class_id.data[7], device_ctx-class_id.data[6],
-   device_ctx-class_id.data[8], device_ctx-class_id.data[9],
-   device_ctx-class_id.data[10],
-   device_ctx-class_id.data[11],
-   device_ctx-class_id.data[12],
-   device_ctx-class_id.data[13],
-   device_ctx-class_id.data[14],
-   device_ctx-class_id.data[15]);
+   dev-dev_type.data[3], dev-dev_type.data[2],
+   dev-dev_type.data[1], dev-dev_type.data[0],
+   dev-dev_type.data[5], dev-dev_type.data[4],
+   dev-dev_type.data[7], dev-dev_type.data[6],
+   dev-dev_type.data[8], dev-dev_type.data[9],
+   dev-dev_type.data[10],
+   dev-dev_type.data[11],
+   dev-dev_type.data[12],
+   dev-dev_type.data[13],
+   dev-dev_type.data[14],
+   dev-dev_type.data[15]);
 
ret = add_uevent_var(env, VMBUS_DEVICE_CLASS_GUID={
 %02x%02x%02x%02x-%02x%02x-%02x%02x-
 %02x%02x%02x%02x%02x%02x%02x%02x},
-device_ctx-class_id.data[3],
-device_ctx-class_id.data[2],
-device_ctx-class_id.data[1],
-device_ctx-class_id.data[0],
-device_ctx-class_id.data[5],
-device_ctx-class_id.data[4],
-device_ctx-class_id.data[7],
-device_ctx-class_id.data[6],
-device_ctx-class_id.data[8],
-device_ctx-class_id.data[9],
-device_ctx-class_id.data[10],
-device_ctx-class_id.data[11],
-device_ctx-class_id.data[12],
-device_ctx-class_id.data[13],
-device_ctx-class_id.data[14],
-device_ctx-class_id.data[15]);
+dev-dev_type.data[3],
+dev-dev_type.data[2],
+   

[PATCH 12/16] Staging: hv: Move probe_failed_work_item from vm_device

2011-03-07 Thread K. Y. Srinivasan
In preparation for consolidating all device related state into
struct hv_device, move probe_failed_work_item from vm_device to
hv_device.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/vmbus.h |1 -
 drivers/staging/hv/vmbus_api.h |3 +++
 drivers/staging/hv/vmbus_drv.c |5 +++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index a6be405..a12e9e5 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -30,7 +30,6 @@
 
 
 struct vm_device {
-   struct work_struct probe_failed_work_item;
struct hv_guid class_id;
struct hv_guid device_id;
int probe_error;
diff --git a/drivers/staging/hv/vmbus_api.h b/drivers/staging/hv/vmbus_api.h
index 7f891fb..60e4000 100644
--- a/drivers/staging/hv/vmbus_api.h
+++ b/drivers/staging/hv/vmbus_api.h
@@ -26,6 +26,7 @@
 #define _VMBUS_API_H_
 
 #include linux/device.h
+#include linux/workqueue.h
 
 #define MAX_PAGE_BUFFER_COUNT  16
 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
@@ -117,6 +118,8 @@ struct hv_device {
 
char name[64];
 
+   struct work_struct probe_failed_work_item;
+
/* the device type id of this device */
struct hv_guid dev_type;
 
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 9a9e426..36c4ec8 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -904,6 +904,7 @@ static int vmbus_probe(struct device *child_device)
drv_to_hv_drv(child_device-driver);
struct vm_device *device_ctx =
device_to_vm_device(child_device);
+   struct hv_device *dev = device_ctx-device_obj;
 
/* Let the specific open-source driver handles the probe if it can */
if (drv-driver.probe) {
@@ -915,9 +916,9 @@ static int vmbus_probe(struct device *child_device)
   dev_name(child_device), child_device,
   child_device-driver-name, ret);
 
-   INIT_WORK(device_ctx-probe_failed_work_item,
+   INIT_WORK(dev-probe_failed_work_item,
  vmbus_probe_failed_cb);
-   schedule_work(device_ctx-probe_failed_work_item);
+   schedule_work(dev-probe_failed_work_item);
}
} else {
DPRINT_ERR(VMBUS_DRV, probe() method not set for driver - %s,
-- 
1.5.5.6

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


[PATCH 13/16] Staging: hv: Remove probe_error from vm_device

2011-03-07 Thread K. Y. Srinivasan
In preparation for consolidating all device related state into
struct hv_device, move probe_error from vm_device to
hv_device.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/vmbus.h |1 -
 drivers/staging/hv/vmbus_api.h |2 ++
 drivers/staging/hv/vmbus_drv.c |4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index a12e9e5..ecd2d2f 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -32,7 +32,6 @@
 struct vm_device {
struct hv_guid class_id;
struct hv_guid device_id;
-   int probe_error;
struct hv_device device_obj;
struct device device;
 };
diff --git a/drivers/staging/hv/vmbus_api.h b/drivers/staging/hv/vmbus_api.h
index 60e4000..4c5a38e 100644
--- a/drivers/staging/hv/vmbus_api.h
+++ b/drivers/staging/hv/vmbus_api.h
@@ -120,6 +120,8 @@ struct hv_device {
 
struct work_struct probe_failed_work_item;
 
+   int probe_error;
+
/* the device type id of this device */
struct hv_guid dev_type;
 
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 36c4ec8..0fcf377 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -742,7 +742,7 @@ int vmbus_child_device_register(struct hv_device 
*root_device_obj,
ret = device_register(child_device_ctx-device);
 
/* vmbus_probe() error does not get propergate to device_register(). */
-   ret = child_device_ctx-probe_error;
+   ret = child_device_ctx-device_obj.probe_error;
 
if (ret)
DPRINT_ERR(VMBUS_DRV, unable to register child device (%p),
@@ -908,7 +908,7 @@ static int vmbus_probe(struct device *child_device)
 
/* Let the specific open-source driver handles the probe if it can */
if (drv-driver.probe) {
-   ret = device_ctx-probe_error =
+   ret = device_ctx-device_obj.probe_error =
drv-driver.probe(child_device);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV, probe() failed for device %s 
-- 
1.5.5.6

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


[PATCH 15/16] Staging: hv: Eliminate device_id from vm_device

2011-03-07 Thread K. Y. Srinivasan
Both device abstractions: vm_device and hv_device maintain state
to reperesent the device instance (and they refer to them by different
names - device_id in vm_device and dev_instance in hv_device). 
In preparation for consolidating all device state in
struct hv_device; eliminate device_id from struct vm_device.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/vmbus.h |1 -
 drivers/staging/hv/vmbus_drv.c |   35 ---
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index a809f00..ab296bb 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -30,7 +30,6 @@
 
 
 struct vm_device {
-   struct hv_guid device_id;
struct hv_device device_obj;
struct device device;
 };
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index d9d138d..8193662 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -546,8 +546,6 @@ static int vmbus_bus_init(void)
}
/* strcpy(dev_ctx-device.bus_id, dev_ctx-device_obj.name); */
dev_set_name(dev_ctx-device, vmbus_0_0);
-   memcpy(dev_ctx-device_id, dev_ctx-device_obj.dev_instance,
-   sizeof(struct hv_guid));
 
/* No need to bind a driver to the root device. */
dev_ctx-device.parent = NULL;
@@ -702,7 +700,6 @@ struct hv_device *vmbus_child_device_create(struct hv_guid 
*type,
memcpy(child_device_obj-dev_instance, instance,
   sizeof(struct hv_guid));
 
-   memcpy(child_device_ctx-device_id, instance, sizeof(struct hv_guid));
 
return child_device_obj;
 }
@@ -826,22 +823,22 @@ static int vmbus_uevent(struct device *device, struct 
kobj_uevent_env *env)
ret = add_uevent_var(env, VMBUS_DEVICE_DEVICE_GUID={
 %02x%02x%02x%02x-%02x%02x-%02x%02x-
 %02x%02x%02x%02x%02x%02x%02x%02x},
-device_ctx-device_id.data[3],
-device_ctx-device_id.data[2],
-device_ctx-device_id.data[1],
-device_ctx-device_id.data[0],
-device_ctx-device_id.data[5],
-device_ctx-device_id.data[4],
-device_ctx-device_id.data[7],
-device_ctx-device_id.data[6],
-device_ctx-device_id.data[8],
-device_ctx-device_id.data[9],
-device_ctx-device_id.data[10],
-device_ctx-device_id.data[11],
-device_ctx-device_id.data[12],
-device_ctx-device_id.data[13],
-device_ctx-device_id.data[14],
-device_ctx-device_id.data[15]);
+dev-dev_instance.data[3],
+dev-dev_instance.data[2],
+dev-dev_instance.data[1],
+dev-dev_instance.data[0],
+dev-dev_instance.data[5],
+dev-dev_instance.data[4],
+dev-dev_instance.data[7],
+dev-dev_instance.data[6],
+dev-dev_instance.data[8],
+dev-dev_instance.data[9],
+dev-dev_instance.data[10],
+dev-dev_instance.data[11],
+dev-dev_instance.data[12],
+dev-dev_instance.data[13],
+dev-dev_instance.data[14],
+dev-dev_instance.data[15]);
if (ret)
return ret;
 
-- 
1.5.5.6

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


[PATCH 16/16] Staging: hv: Remove the vm_device structure

2011-03-07 Thread K. Y. Srinivasan
Consolidate all device related state in struct hv_device by
moving the device field from struct vm_device to
struct hv_device. As part of this, also get rid of struct
vm_device since the consolidation is complete.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/blkvsc_drv.c  |   16 +++
 drivers/staging/hv/hv_mouse.c|   19 +++--
 drivers/staging/hv/netvsc_drv.c  |   24 +---
 drivers/staging/hv/storvsc_drv.c |   24 +--
 drivers/staging/hv/vmbus.h   |   12 +-
 drivers/staging/hv/vmbus_api.h   |2 +
 drivers/staging/hv/vmbus_drv.c   |   77 +-
 7 files changed, 73 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 0f9fb05..6e02f1b 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -95,7 +95,7 @@ struct blkvsc_request {
 /* Per device structure */
 struct block_device_context {
/* point back to our device context */
-   struct vm_device *device_ctx;
+   struct hv_device *device_ctx;
struct kmem_cache *request_pool;
spinlock_t lock;
struct gendisk *gd;
@@ -240,8 +240,7 @@ static int blkvsc_probe(struct device *device)
drv_to_hv_drv(device-driver);
struct storvsc_driver_object *storvsc_drv_obj =
drv-priv;
-   struct vm_device *device_ctx = device_to_vm_device(device);
-   struct hv_device *device_obj = device_ctx-device_obj;
+   struct hv_device *device_obj = device_to_hv_device(device);
 
struct block_device_context *blkdev = NULL;
struct storvsc_device_info device_info;
@@ -273,7 +272,7 @@ static int blkvsc_probe(struct device *device)
/* ASSERT(sizeof(struct blkvsc_request_group) = */
/*  sizeof(struct blkvsc_request)); */
 
-   blkdev-request_pool = kmem_cache_create(dev_name(device_ctx-device),
+   blkdev-request_pool = kmem_cache_create(dev_name(device_obj-device),
sizeof(struct blkvsc_request) +
storvsc_drv_obj-request_ext_size, 0,
SLAB_HWCACHE_ALIGN, NULL);
@@ -290,7 +289,7 @@ static int blkvsc_probe(struct device *device)
goto Cleanup;
}
 
-   blkdev-device_ctx = device_ctx;
+   blkdev-device_ctx = device_obj;
/* this identified the device 0 or 1 */
blkdev-target = device_info.target_id;
/* this identified the ide ctrl 0 or 1 */
@@ -723,8 +722,7 @@ static int blkvsc_remove(struct device *device)
drv_to_hv_drv(device-driver);
struct storvsc_driver_object *storvsc_drv_obj =
drv-priv;
-   struct vm_device *device_ctx = device_to_vm_device(device);
-   struct hv_device *device_obj = device_ctx-device_obj;
+   struct hv_device *device_obj = device_to_hv_device(device);
struct block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags;
int ret;
@@ -839,7 +837,7 @@ static int blkvsc_submit_request(struct blkvsc_request 
*blkvsc_req,
void (*request_completion)(struct hv_storvsc_request *))
 {
struct block_device_context *blkdev = blkvsc_req-dev;
-   struct vm_device *device_ctx = blkdev-device_ctx;
+   struct hv_device *device_ctx = blkdev-device_ctx;
struct hv_driver *drv =
drv_to_hv_drv(device_ctx-device.driver);
struct storvsc_driver_object *storvsc_drv_obj =
@@ -884,7 +882,7 @@ static int blkvsc_submit_request(struct blkvsc_request 
*blkvsc_req,
storvsc_req-sense_buffer = blkvsc_req-sense_buffer;
storvsc_req-sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
 
-   ret = storvsc_drv_obj-on_io_request(blkdev-device_ctx-device_obj,
+   ret = storvsc_drv_obj-on_io_request(blkdev-device_ctx,
   blkvsc_req-request);
if (ret == 0)
blkdev-num_outstanding_reqs++;
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 6c5c00d..8f94f43 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -771,7 +771,7 @@ static void MousevscOnCleanup(struct hv_driver *drv)
  * Data types
  */
 struct input_device_context {
-   struct vm_device*device_ctx;
+   struct hv_device*device_ctx;
struct hid_device   *hid_device;
struct hv_input_dev_info device_info;
int connected;
@@ -782,9 +782,8 @@ static struct  mousevsc_drv_obj g_mousevsc_drv;
 
 static void deviceinfo_callback(struct hv_device *dev, struct 
hv_input_dev_info *info)
 {
-   

[PATCH 06/16] Staging: hv: Change the signature for vmbus_child_driver_unregister

2011-03-07 Thread K. Y. Srinivasan
In preperation for moving the element driver from the
struct driver_context to struct hv_driver, change the
signature for the function vmbus_child_driver_unregister()
to take a pointer to struct device_driver.

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

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index d5e1881..dee38d5 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -233,7 +233,7 @@ static void blkvsc_drv_exit(void)
if (storvsc_drv_obj-base.cleanup)
storvsc_drv_obj-base.cleanup(storvsc_drv_obj-base);
 
-   vmbus_child_driver_unregister(drv_ctx);
+   vmbus_child_driver_unregister(drv_ctx-driver);
 
return;
 }
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index d2290f8..4ab08ae 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -983,7 +983,7 @@ static void mousevsc_drv_exit(void)
if (mousevsc_drv_obj-Base.cleanup)
mousevsc_drv_obj-Base.cleanup(mousevsc_drv_obj-Base);
 
-   vmbus_child_driver_unregister(drv_ctx);
+   vmbus_child_driver_unregister(drv_ctx-driver);
 
return;
 }
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index a50a9a6..333586e 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -489,7 +489,7 @@ static void netvsc_drv_exit(void)
if (netvsc_drv_obj-base.cleanup)
netvsc_drv_obj-base.cleanup(netvsc_drv_obj-base);
 
-   vmbus_child_driver_unregister(drv_ctx);
+   vmbus_child_driver_unregister(drv_ctx-driver);
 
return;
 }
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 8ab8df5..ced611a 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -209,7 +209,7 @@ static void storvsc_drv_exit(void)
if (storvsc_drv_obj-base.cleanup)
storvsc_drv_obj-base.cleanup(storvsc_drv_obj-base);
 
-   vmbus_child_driver_unregister(drv_ctx);
+   vmbus_child_driver_unregister(drv_ctx-driver);
return;
 }
 
diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index 2295fe2..7a5e708 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -62,7 +62,7 @@ static inline struct driver_context 
*driver_to_driver_context(struct device_driv
 
 /* Vmbus interface */
 int vmbus_child_driver_register(struct device_driver *drv);
-void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
+void vmbus_child_driver_unregister(struct device_driver *drv);
 
 extern struct completion hv_channel_ready;
 
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 685376b..1473809 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -646,23 +646,22 @@ EXPORT_SYMBOL(vmbus_child_driver_register);
 
 /**
  * vmbus_child_driver_unregister() - Unregister a vmbus's child driver
- * @driver_ctx:Pointer to driver structure you want to un-register
+ * @drv:Pointer to driver structure you want to un-register
  *
- * @driver_ctx is of type struct driver_context
  *
  * Un-register the given driver with Linux through the 'driver_unregister()'
  * call. And ungegisters the driver from the Hyper-V vmbus handler.
  *
  * Mainly used by Hyper-V drivers.
  */
-void vmbus_child_driver_unregister(struct driver_context *driver_ctx)
+void vmbus_child_driver_unregister(struct device_driver *drv)
 {
DPRINT_INFO(VMBUS_DRV, child driver (%p) unregistering - name %s,
-   driver_ctx, driver_ctx-driver.name);
+   drv, drv-name);
 
-   driver_unregister(driver_ctx-driver);
+   driver_unregister(drv);
 
-   driver_ctx-driver.bus = NULL;
+   drv-bus = NULL;
 }
 EXPORT_SYMBOL(vmbus_child_driver_unregister);
 
-- 
1.5.5.6

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


[PATCH 07/16] Staging: hv: Eliminate driver_context structure

2011-03-07 Thread K. Y. Srinivasan
We need to move the following elements from struct driver_context:
class_id and driver in one step. As part of this operation get rid of
the struct driver_context. With this patch we will have
consolidated all driver state into one data structure:
struct hv_driver.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/blkvsc_drv.c  |   43 +
 drivers/staging/hv/hv_mouse.c|   32 +---
 drivers/staging/hv/netvsc_drv.c  |   40 +++---
 drivers/staging/hv/storvsc_drv.c |   41 ---
 drivers/staging/hv/vmbus.h   |   10 +---
 drivers/staging/hv/vmbus_api.h   |   14 
 drivers/staging/hv/vmbus_drv.c   |   41 +---
 7 files changed, 103 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index dee38d5..af0a529 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -117,9 +117,6 @@ struct block_device_context {
 
 /* Per driver */
 struct blkvsc_driver_context {
-   /* !! These must be the first 2 fields !! */
-   /* FIXME this is a bug! */
-   struct driver_context drv_ctx;
struct storvsc_driver_object drv_obj;
 };
 
@@ -174,24 +171,24 @@ static const struct block_device_operations block_ops = {
 static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
 {
struct storvsc_driver_object *storvsc_drv_obj = g_blkvsc_drv.drv_obj;
-   struct driver_context *drv_ctx = g_blkvsc_drv.drv_ctx;
+   struct hv_driver *drv = g_blkvsc_drv.drv_obj.base;
int ret;
 
storvsc_drv_obj-ring_buffer_size = blkvsc_ringbuffer_size;
 
+   drv-priv = storvsc_drv_obj;
+
/* Callback to client driver to complete the initialization */
drv_init(storvsc_drv_obj-base);
 
-   drv_ctx-driver.name = storvsc_drv_obj-base.name;
-   memcpy(drv_ctx-class_id, storvsc_drv_obj-base.dev_type,
-  sizeof(struct hv_guid));
+   drv-driver.name = storvsc_drv_obj-base.name;
 
-   drv_ctx-driver.probe = blkvsc_probe;
-   drv_ctx-driver.remove = blkvsc_remove;
-   drv_ctx-driver.shutdown = blkvsc_shutdown;
+   drv-driver.probe = blkvsc_probe;
+   drv-driver.remove = blkvsc_remove;
+   drv-driver.shutdown = blkvsc_shutdown;
 
/* The driver belongs to vmbus */
-   ret = vmbus_child_driver_register(drv_ctx-driver);
+   ret = vmbus_child_driver_register(drv-driver);
 
return ret;
 }
@@ -206,7 +203,7 @@ static int blkvsc_drv_exit_cb(struct device *dev, void 
*data)
 static void blkvsc_drv_exit(void)
 {
struct storvsc_driver_object *storvsc_drv_obj = g_blkvsc_drv.drv_obj;
-   struct driver_context *drv_ctx = g_blkvsc_drv.drv_ctx;
+   struct hv_driver *drv = g_blkvsc_drv.drv_obj.base;
struct device *current_dev;
int ret;
 
@@ -214,7 +211,7 @@ static void blkvsc_drv_exit(void)
current_dev = NULL;
 
/* Get the device */
-   ret = driver_for_each_device(drv_ctx-driver, NULL,
+   ret = driver_for_each_device(drv-driver, NULL,
 (void *) current_dev,
 blkvsc_drv_exit_cb);
 
@@ -233,7 +230,7 @@ static void blkvsc_drv_exit(void)
if (storvsc_drv_obj-base.cleanup)
storvsc_drv_obj-base.cleanup(storvsc_drv_obj-base);
 
-   vmbus_child_driver_unregister(drv_ctx-driver);
+   vmbus_child_driver_unregister(drv-driver);
 
return;
 }
@@ -243,10 +240,10 @@ static void blkvsc_drv_exit(void)
  */
 static int blkvsc_probe(struct device *device)
 {
-   struct driver_context *driver_ctx =
-   driver_to_driver_context(device-driver);
+   struct hv_driver *drv =
+   drv_to_hv_drv(device-driver);
struct blkvsc_driver_context *blkvsc_drv_ctx =
-   (struct blkvsc_driver_context *)driver_ctx;
+   (struct blkvsc_driver_context *)drv-priv;
struct storvsc_driver_object *storvsc_drv_obj =
blkvsc_drv_ctx-drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
@@ -728,10 +725,10 @@ static int blkvsc_do_read_capacity16(struct 
block_device_context *blkdev)
  */
 static int blkvsc_remove(struct device *device)
 {
-   struct driver_context *driver_ctx =
-   driver_to_driver_context(device-driver);
+   struct hv_driver *drv =
+   drv_to_hv_drv(device-driver);
struct blkvsc_driver_context *blkvsc_drv_ctx =
-   (struct blkvsc_driver_context 

[PATCH 00/16] Staging: hv: Consolidate driver and device abstractions

2011-03-07 Thread K. Y. Srinivasan
Hyper-V has maintained both its class independent driver and 
device state in two independent data structures:
Driver state: struct driver_context (vmbus.h) and struct hv_driver
(vmbus_api.h)
Device state: struct vm_device (vmbus.h) and struct hv_device (vmbus_api.h)

While sruct driver_context and struct vm_device embed generic 
Linux abstractions of struct device_driver and struct device respectively; 
the lower level hyperv abstraction: struct hv_driver and struct hv_device
have maintained state needed to communicate with the host. This partitioning
made sense at a point in time when it was not clear how much of 
the hypervisor interaction would be open sourced. Given where we are
today, there is no reason to keep this layering. This patchset 
consolidates all the driver state into a single structure: 
struct hv_driver while all the device state is consolidated into
a single structure: struct hv_device. This consolidation simplifies
the code while simultaneously getting rid of redundant state -
for instance in the current code, both struct driver_context and
struct hv_driver both have state to represent the class as well as
instance id. We do this consolidation by moving state from higher
level structures (struct driver_context and struct vm_device) to
lower level structures (struct hv_driver and hv_device) respectively.

While it has not been a goal of this effort to cleanup structure and 
variable names, this consolidation effort has resulted in some cleanup
with regards to structure and variable names: a) Some of the badly
named structures have been eliminated (struct driver_context etc.) 
while hopefully all newly introduced names are acceptable.  

Patches 1 through 11 deal with consolidating the device driver
state while patches 12 through 16  deal with consolidating
device state.


Regards,

K. Y

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


[PATCH 09/16] Staging: hv: Eliminate mousevsc_driver_context

2011-03-07 Thread K. Y. Srinivasan
With the consolidation of all driver state into one data structure;
mousevsc_driver_context structure is not needed; get rid of it.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/hv_mouse.c |   21 +++--
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index f762a8a..6c5c00d 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -777,11 +777,8 @@ struct input_device_context {
int connected;
 };
 
-struct mousevsc_driver_context {
-   struct mousevsc_drv_obj drv_obj;
-};
 
-static struct mousevsc_driver_context g_mousevsc_drv;
+static struct  mousevsc_drv_obj g_mousevsc_drv;
 
 static void deviceinfo_callback(struct hv_device *dev, struct 
hv_input_dev_info *info)
 {
@@ -824,9 +821,7 @@ static int mousevsc_probe(struct device *device)
 
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct mousevsc_driver_context *mousevsc_drv_ctx =
-   (struct mousevsc_driver_context *)drv-priv;
-   struct mousevsc_drv_obj *mousevsc_drv_obj = mousevsc_drv_ctx-drv_obj;
+   struct mousevsc_drv_obj *mousevsc_drv_obj = drv-priv;
 
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
@@ -855,9 +850,7 @@ static int mousevsc_remove(struct device *device)
 
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct mousevsc_driver_context *mousevsc_drv_ctx =
-   (struct mousevsc_driver_context *)drv-priv;
-   struct mousevsc_drv_obj *mousevsc_drv_obj = mousevsc_drv_ctx-drv_obj;
+   struct mousevsc_drv_obj *mousevsc_drv_obj = drv-priv;
 
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
@@ -956,8 +949,8 @@ static int mousevsc_drv_exit_cb(struct device *dev, void 
*data)
 
 static void mousevsc_drv_exit(void)
 {
-   struct mousevsc_drv_obj *mousevsc_drv_obj = g_mousevsc_drv.drv_obj;
-   struct hv_driver *drv = g_mousevsc_drv.drv_obj.Base;
+   struct mousevsc_drv_obj *mousevsc_drv_obj = g_mousevsc_drv;
+   struct hv_driver *drv = g_mousevsc_drv.Base;
int ret;
 
struct device *current_dev = NULL;
@@ -1008,8 +1001,8 @@ static int mouse_vsc_initialize(struct hv_driver *Driver)
 
 static int __init mousevsc_init(void)
 {
-   struct mousevsc_drv_obj *input_drv_obj = g_mousevsc_drv.drv_obj;
-   struct hv_driver *drv = g_mousevsc_drv.drv_obj.Base;
+   struct mousevsc_drv_obj *input_drv_obj = g_mousevsc_drv;
+   struct hv_driver *drv = g_mousevsc_drv.Base;
 
DPRINT_INFO(INPUTVSC_DRV, Hyper-V Mouse driver initializing.);
 
-- 
1.5.5.6

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


[PATCH 09/16] Staging: hv: Eliminate mousevsc_driver_context

2011-03-07 Thread K. Y. Srinivasan
With the consolidation of all driver state into one data structure;
mousevsc_driver_context structure is not needed; get rid of it.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Abhishek Kane v-abk...@microsoft.com
Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Signed-off-by: Hank Janssen hjans...@microsoft.com
---
 drivers/staging/hv/hv_mouse.c |   21 +++--
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index f762a8a..6c5c00d 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -777,11 +777,8 @@ struct input_device_context {
int connected;
 };
 
-struct mousevsc_driver_context {
-   struct mousevsc_drv_obj drv_obj;
-};
 
-static struct mousevsc_driver_context g_mousevsc_drv;
+static struct  mousevsc_drv_obj g_mousevsc_drv;
 
 static void deviceinfo_callback(struct hv_device *dev, struct 
hv_input_dev_info *info)
 {
@@ -824,9 +821,7 @@ static int mousevsc_probe(struct device *device)
 
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct mousevsc_driver_context *mousevsc_drv_ctx =
-   (struct mousevsc_driver_context *)drv-priv;
-   struct mousevsc_drv_obj *mousevsc_drv_obj = mousevsc_drv_ctx-drv_obj;
+   struct mousevsc_drv_obj *mousevsc_drv_obj = drv-priv;
 
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
@@ -855,9 +850,7 @@ static int mousevsc_remove(struct device *device)
 
struct hv_driver *drv =
drv_to_hv_drv(device-driver);
-   struct mousevsc_driver_context *mousevsc_drv_ctx =
-   (struct mousevsc_driver_context *)drv-priv;
-   struct mousevsc_drv_obj *mousevsc_drv_obj = mousevsc_drv_ctx-drv_obj;
+   struct mousevsc_drv_obj *mousevsc_drv_obj = drv-priv;
 
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = device_ctx-device_obj;
@@ -956,8 +949,8 @@ static int mousevsc_drv_exit_cb(struct device *dev, void 
*data)
 
 static void mousevsc_drv_exit(void)
 {
-   struct mousevsc_drv_obj *mousevsc_drv_obj = g_mousevsc_drv.drv_obj;
-   struct hv_driver *drv = g_mousevsc_drv.drv_obj.Base;
+   struct mousevsc_drv_obj *mousevsc_drv_obj = g_mousevsc_drv;
+   struct hv_driver *drv = g_mousevsc_drv.Base;
int ret;
 
struct device *current_dev = NULL;
@@ -1008,8 +1001,8 @@ static int mouse_vsc_initialize(struct hv_driver *Driver)
 
 static int __init mousevsc_init(void)
 {
-   struct mousevsc_drv_obj *input_drv_obj = g_mousevsc_drv.drv_obj;
-   struct hv_driver *drv = g_mousevsc_drv.drv_obj.Base;
+   struct mousevsc_drv_obj *input_drv_obj = g_mousevsc_drv;
+   struct hv_driver *drv = g_mousevsc_drv.Base;
 
DPRINT_INFO(INPUTVSC_DRV, Hyper-V Mouse driver initializing.);
 
-- 
1.5.5.6

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


RE: [PATCH 00/16] Staging: hv: Consolidate driver and device abstractions

2011-03-07 Thread KY Srinivasan


 -Original Message-
 From: Greg KH [mailto:g...@kroah.com]
 Sent: Monday, March 07, 2011 5:24 PM
 To: KY Srinivasan
 Cc: gre...@suse.de; linux-ker...@vger.kernel.org;
 de...@linuxdriverproject.org; virtualizat...@lists.osdl.org
 Subject: Re: [PATCH 00/16] Staging: hv: Consolidate driver and device
 abstractions
 
 On Mon, Mar 07, 2011 at 01:01:35PM -0800, K. Y. Srinivasan wrote:
  Hyper-V has maintained both its class independent driver and
  device state in two independent data structures:
  Driver state: struct driver_context (vmbus.h) and struct hv_driver
  (vmbus_api.h)
  Device state: struct vm_device (vmbus.h) and struct hv_device (vmbus_api.h)
 
  While sruct driver_context and struct vm_device embed generic
  Linux abstractions of struct device_driver and struct device respectively;
  the lower level hyperv abstraction: struct hv_driver and struct hv_device
  have maintained state needed to communicate with the host. This partitioning
  made sense at a point in time when it was not clear how much of
  the hypervisor interaction would be open sourced. Given where we are
  today, there is no reason to keep this layering. This patchset
  consolidates all the driver state into a single structure:
  struct hv_driver while all the device state is consolidated into
  a single structure: struct hv_device. This consolidation simplifies
  the code while simultaneously getting rid of redundant state -
  for instance in the current code, both struct driver_context and
  struct hv_driver both have state to represent the class as well as
  instance id. We do this consolidation by moving state from higher
  level structures (struct driver_context and struct vm_device) to
  lower level structures (struct hv_driver and hv_device) respectively.
 
  While it has not been a goal of this effort to cleanup structure and
  variable names, this consolidation effort has resulted in some cleanup
  with regards to structure and variable names: a) Some of the badly
  named structures have been eliminated (struct driver_context etc.)
  while hopefully all newly introduced names are acceptable.
 
  Patches 1 through 11 deal with consolidating the device driver
  state while patches 12 through 16  deal with consolidating
  device state.
 
 Very nice job, now that's the way to break up and send a patch series.
 
 I've queued them all up now.


Thanks Greg; coming from you it means a lot to me.

 
 I'm guessing that you will have follow-on patches now to complete the
 migration to the correct driver core use (i.e. proper driver and device
 usage?)  Or do you want me to look into doing this?

My immediate goal is to get the vmbus driver to exit staging. To that
end I am working on a patch-set to cleanup vmbus_drv.c. I should have this
patch-set fairly soon.  Once that is
done, I think we would have addressed all the structural/architectural issues
of the vmbus driver that is preventing us from exiting staging. 
We are planning to address the issues with other drivers after we are done
with the vmbus driver. As always, your help is greatly appreciated.

Regards,

K. Y   

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


Re: [PATCH 00/16] Staging: hv: Consolidate driver and device abstractions

2011-03-07 Thread Greg KH
On Mon, Mar 07, 2011 at 10:45:15PM +, KY Srinivasan wrote:
  I'm guessing that you will have follow-on patches now to complete the
  migration to the correct driver core use (i.e. proper driver and device
  usage?)  Or do you want me to look into doing this?
 
 My immediate goal is to get the vmbus driver to exit staging. To that
 end I am working on a patch-set to cleanup vmbus_drv.c. I should have this
 patch-set fairly soon.  Once that is
 done, I think we would have addressed all the structural/architectural issues
 of the vmbus driver that is preventing us from exiting staging. 

Well, perhaps, let's not get ahead of ourselves here :)

 We are planning to address the issues with other drivers after we are done
 with the vmbus driver. As always, your help is greatly appreciated.

The issue I am referring to above still has to do with the vmbus core.

The goal is to have the vmbus work like all other busses in the kernel.
You register a hv_driver with some probe and disconnect callbacks, and
the vmbus calls into the drivers when it needs to.

You are almost there, using the struct device pointers directly, but a
few more steps remain.

I'll look into the details after your remaining cleanups, I don't want
to get in the way of them.

thanks,

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


RE: [PATCH 00/16] Staging: hv: Consolidate driver and device abstractions

2011-03-07 Thread KY Srinivasan


 -Original Message-
 From: Greg KH [mailto:g...@kroah.com]
 Sent: Monday, March 07, 2011 6:00 PM
 To: KY Srinivasan
 Cc: gre...@suse.de; linux-ker...@vger.kernel.org;
 de...@linuxdriverproject.org; virtualizat...@lists.osdl.org
 Subject: Re: [PATCH 00/16] Staging: hv: Consolidate driver and device
 abstractions
 
 On Mon, Mar 07, 2011 at 10:45:15PM +, KY Srinivasan wrote:
   I'm guessing that you will have follow-on patches now to complete the
   migration to the correct driver core use (i.e. proper driver and device
   usage?)  Or do you want me to look into doing this?
 
  My immediate goal is to get the vmbus driver to exit staging. To that
  end I am working on a patch-set to cleanup vmbus_drv.c. I should have this
  patch-set fairly soon.  Once that is
  done, I think we would have addressed all the structural/architectural 
  issues
  of the vmbus driver that is preventing us from exiting staging.
 
 Well, perhaps, let's not get ahead of ourselves here :)

Certainly. I was being presumptuous when I said  we would have
addressed all the structural/architectural issues ...  What I meant 
to say was that I would have addressed  the problems that I know about.
After I am done with the current cleanup, I will work on the remaining 
issues.

 
  We are planning to address the issues with other drivers after we are done
  with the vmbus driver. As always, your help is greatly appreciated.
 
 The issue I am referring to above still has to do with the vmbus core.
 
 The goal is to have the vmbus work like all other busses in the kernel.
 You register a hv_driver with some probe and disconnect callbacks, and
 the vmbus calls into the drivers when it needs to.
 
 You are almost there, using the struct device pointers directly, but a
 few more steps remain.
 
 I'll look into the details after your remaining cleanups, I don't want
 to get in the way of them.

Thank you. You should have my patches fairly soon. Hopefully, I would 
have addressed the issues you have raised.  

Regards,

K. Y

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