* [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: Haiyang Zhang @ 2011-02-23 20:19 UTC (permalink / raw)
To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
vir
The patch fixed the code depending on the exact order of fields in the
struct vmbus_driver_context, so the unused field drv_ctx can be removed,
and drv_obj doesn't have to be the second field in this structure.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.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 | 14 +-------------
5 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 36a0adb..293ab8e 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -177,6 +177,8 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
int ret;
+ drv_ctx->hv_drv = &storvsc_drv_obj->base;
+
storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
/* Callback to client driver to complete the initialization */
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 03f9740..364b6c7 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -500,6 +500,8 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
int ret;
+ drv_ctx->hv_drv = &net_drv_obj->base;
+
net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
net_drv_obj->recv_cb = netvsc_recv_callback;
net_drv_obj->link_status_change = netvsc_linkstatus_callback;
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index a8427ff..33acee5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -140,6 +140,8 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
+ drv_ctx->hv_drv = &storvsc_drv_obj->base;
+
storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
/* Callback to client driver to complete the initialization */
diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index 42f2adb..fd9d00f 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -30,8 +30,8 @@
struct driver_context {
struct hv_guid class_id;
-
struct device_driver driver;
+ struct hv_driver *hv_drv;
/*
* Use these methods instead of the struct device_driver so 2.6 kernel
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 459c707..1f4e46d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -42,11 +42,6 @@
/* Main vmbus driver data structure */
struct vmbus_driver_context {
- /* !! These must be the first 2 fields !! */
- /* FIXME, this is a bug */
- /* The driver field is not used in here. Instead, the bus field is */
- /* used to represent the driver */
- struct driver_context drv_ctx;
struct hv_driver drv_obj;
struct bus_type bus;
@@ -869,14 +864,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
/* We found our driver ? */
if (memcmp(&device_ctx->class_id, &driver_ctx->class_id,
sizeof(struct hv_guid)) == 0) {
- /*
- * !! NOTE: The driver_ctx is not a vmbus_drv_ctx. We typecast
- * it here to access the struct hv_driver field
- */
- struct vmbus_driver_context *vmbus_drv_ctx =
- (struct vmbus_driver_context *)driver_ctx;
-
- device_ctx->device_obj.drv = &vmbus_drv_ctx->drv_obj;
+ device_ctx->device_obj.drv = driver_ctx->hv_drv;
DPRINT_INFO(VMBUS_DRV,
"device object (%p) set to driver object (%p)",
&device_ctx->device_obj,
--
1.6.3.2
^ permalink raw reply related
* [PATCH 2/4] staging: hv: Fix the code depending on struct netvsc_driver_context data order
From: Haiyang Zhang @ 2011-02-23 20:19 UTC (permalink / raw)
To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
vir
In-Reply-To: <1298492398-16522-1-git-send-email-haiyangz@microsoft.com>
The patch fixed the code depending on the exact order of fields in the
struct netvsc_driver_context. Now, we use container_of() instead of type
casting from the first field to the container struct.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/netvsc_drv.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 364b6c7..c78624c 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -49,8 +49,6 @@ struct net_device_context {
};
struct netvsc_driver_context {
- /* !! These must be the first 2 fields !! */
- /* Which is a bug FIXME! */
struct driver_context drv_ctx;
struct netvsc_driver drv_obj;
};
@@ -137,8 +135,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
struct net_device_context *net_device_ctx = netdev_priv(net);
struct driver_context *driver_ctx =
driver_to_driver_context(net_device_ctx->device_ctx->device.driver);
- struct netvsc_driver_context *net_drv_ctx =
- (struct netvsc_driver_context *)driver_ctx;
+ struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
+ struct netvsc_driver_context, drv_ctx);
struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
struct hv_netvsc_packet *packet;
int ret;
@@ -342,8 +340,8 @@ static int netvsc_probe(struct device *device)
{
struct driver_context *driver_ctx =
driver_to_driver_context(device->driver);
- struct netvsc_driver_context *net_drv_ctx =
- (struct netvsc_driver_context *)driver_ctx;
+ struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
+ struct netvsc_driver_context, drv_ctx);
struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
@@ -414,8 +412,8 @@ static int netvsc_remove(struct device *device)
{
struct driver_context *driver_ctx =
driver_to_driver_context(device->driver);
- struct netvsc_driver_context *net_drv_ctx =
- (struct netvsc_driver_context *)driver_ctx;
+ struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
+ struct netvsc_driver_context, drv_ctx);
struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
struct net_device *net = dev_get_drvdata(&device_ctx->device);
--
1.6.3.2
^ permalink raw reply related
* [PATCH 3/4] staging: hv: Fix the code depending on struct blkvsc_driver_context data order
From: Haiyang Zhang @ 2011-02-23 20:19 UTC (permalink / raw)
To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
vir
In-Reply-To: <1298492398-16522-2-git-send-email-haiyangz@microsoft.com>
The patch fixed the code depending on the exact order of fields in the
struct blkvsc_driver_context. Now, we use container_of() instead of type
casting from the first field to the container struct.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc_drv.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 293ab8e..8f38895 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -117,8 +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;
};
@@ -248,7 +246,7 @@ static int blkvsc_probe(struct device *device)
struct driver_context *driver_ctx =
driver_to_driver_context(device->driver);
struct blkvsc_driver_context *blkvsc_drv_ctx =
- (struct blkvsc_driver_context *)driver_ctx;
+ container_of(driver_ctx, struct blkvsc_driver_context, drv_ctx);
struct storvsc_driver_object *storvsc_drv_obj =
&blkvsc_drv_ctx->drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
@@ -733,7 +731,7 @@ static int blkvsc_remove(struct device *device)
struct driver_context *driver_ctx =
driver_to_driver_context(device->driver);
struct blkvsc_driver_context *blkvsc_drv_ctx =
- (struct blkvsc_driver_context *)driver_ctx;
+ container_of(driver_ctx, struct blkvsc_driver_context, drv_ctx);
struct storvsc_driver_object *storvsc_drv_obj =
&blkvsc_drv_ctx->drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
@@ -856,7 +854,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
struct driver_context *driver_ctx =
driver_to_driver_context(device_ctx->device.driver);
struct blkvsc_driver_context *blkvsc_drv_ctx =
- (struct blkvsc_driver_context *)driver_ctx;
+ container_of(driver_ctx, struct blkvsc_driver_context, drv_ctx);
struct storvsc_driver_object *storvsc_drv_obj =
&blkvsc_drv_ctx->drv_obj;
struct hv_storvsc_request *storvsc_req;
--
1.6.3.2
^ permalink raw reply related
* [PATCH 4/4] staging: hv: Fix the code depending on struct storvsc_driver_context data order
From: Haiyang Zhang @ 2011-02-23 20:19 UTC (permalink / raw)
To: haiyangz, hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
vir
In-Reply-To: <1298492398-16522-3-git-send-email-haiyangz@microsoft.com>
The patch fixed the code depending on the exact order of fields in the
struct storvsc_driver_context. Now, we use container_of() instead of type
casting from the first field to the container struct.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/storvsc_drv.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 33acee5..a364627 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -64,8 +64,6 @@ struct storvsc_cmd_request {
};
struct storvsc_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;
};
@@ -223,8 +221,8 @@ static int storvsc_probe(struct device *device)
int ret;
struct driver_context *driver_ctx =
driver_to_driver_context(device->driver);
- struct storvsc_driver_context *storvsc_drv_ctx =
- (struct storvsc_driver_context *)driver_ctx;
+ struct storvsc_driver_context *storvsc_drv_ctx = container_of(
+ driver_ctx, struct storvsc_driver_context, drv_ctx);
struct storvsc_driver_object *storvsc_drv_obj =
&storvsc_drv_ctx->drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
@@ -308,8 +306,8 @@ static int storvsc_remove(struct device *device)
int ret;
struct driver_context *driver_ctx =
driver_to_driver_context(device->driver);
- struct storvsc_driver_context *storvsc_drv_ctx =
- (struct storvsc_driver_context *)driver_ctx;
+ struct storvsc_driver_context *storvsc_drv_ctx = container_of(
+ driver_ctx, struct storvsc_driver_context, drv_ctx);
struct storvsc_driver_object *storvsc_drv_obj =
&storvsc_drv_ctx->drv_obj;
struct vm_device *device_ctx = device_to_vm_device(device);
@@ -606,8 +604,8 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
struct vm_device *device_ctx = host_device_ctx->device_ctx;
struct driver_context *driver_ctx =
driver_to_driver_context(device_ctx->device.driver);
- struct storvsc_driver_context *storvsc_drv_ctx =
- (struct storvsc_driver_context *)driver_ctx;
+ struct storvsc_driver_context *storvsc_drv_ctx = container_of(
+ driver_ctx, struct storvsc_driver_context, drv_ctx);
struct storvsc_driver_object *storvsc_drv_obj =
&storvsc_drv_ctx->drv_obj;
struct hv_storvsc_request *request;
--
1.6.3.2
^ permalink raw reply related
* RE: [PATCH 1/6] Staging: hv: vmbus_drv.c Replaced DPRINT with native pr_XXX
From: Hank Janssen @ 2011-02-23 20:20 UTC (permalink / raw)
To: Greg KH
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
virtualization@lists.osdl.org, devel@linuxdriverproject.org
In-Reply-To: <20110223191135.GA1030@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, February 23, 2011 11:12 AM
> To: Hank Janssen
> Why say this in the 1/6 patch? It should be in the 0/6 introduction.
>
> >
> > All DPRINT calls have been removed, and where needed have been
> > replaced with pr_XX native calls. Many debug DPRINT calls have
> > been removed outright.
>
> I think a lot of these pr_XX calls can be switched to dev_XX calls
> instead, right?
Not in this case, this patch set is for vmbus only. The next patch
set will use netdev_* and dev* for netvsc, scsi and IDE.
> How about you break this up into a different series of patches to make
> it more readable:
> - remove unneeded DPRINT calls
> - convert remaining DPRINT calls to pr_XX or dev_XX as needed
>
> That would make it easier to review, as it is, it's quite difficult.
Will do.
Hank.
^ permalink raw reply
* Re: [PATCH 2/4] staging: hv: Fix the code depending on struct netvsc_driver_context data order
From: Thomas Gleixner @ 2011-02-23 20:53 UTC (permalink / raw)
To: Haiyang Zhang; +Cc: v-abkane, gregkh, linux-kernel, virtualization, devel
In-Reply-To: <1298492398-16522-2-git-send-email-haiyangz@microsoft.com>
On Wed, 23 Feb 2011, Haiyang Zhang wrote:
> @@ -137,8 +135,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
> struct net_device_context *net_device_ctx = netdev_priv(net);
> struct driver_context *driver_ctx =
> driver_to_driver_context(net_device_ctx->device_ctx->device.driver);
> - struct netvsc_driver_context *net_drv_ctx =
> - (struct netvsc_driver_context *)driver_ctx;
> + struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
> + struct netvsc_driver_context, drv_ctx);
While the code is correct, it's still horrible to read.
struct net_device_context *dev_ctx = netdev_priv(net);
struct netvsc_drv_ctx *net_drv_ctx;
struct netvsc_driver *net_drv_obj;
struct driver_context *drv_ctx;
struct hv_netvsc_packet *packet;
int ret;
drv_ctx = driver_to_driver_context(dev_ctx->device_ctx->device.driver);
net_drv_ctx = container_of(driver_ctx, struct netvsc_drv_ctx, drv_ctx);
net_drv_obj = &net_drv_ctx->drv_obj;
Line breaking code just to fulfil the 80 chars requirement is a
horrible idea.
I just explained somewhere else, that these line breaks are equaly
inefficient to parse by the human eye as the extra wide lines. Have
you ever seen a newspaper which uses a column width which spawns the
whole size of the paper? Probably not, simply because nobody can read
it fluently and fast.
So just mechanically converting existing code which was written based
on that horrible though popular codingstyle which requires wide screen
monitors is not going to result in readable code.
You need to do more than just inserting random line breaks as you see fit.
struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
struct netvsc_driver_context, drv_ctx);
is a total horrible construct.
So
struct netvsc_driver_context *net_drv_ctx;
net_drv_ctx = container_of(driver_ctx, struct netvsc_driver_context,
drv_ctx);
is way better, as you can cleary see, that the extra line belongs to
the arguments of container_of(). Try to decode that in the above
original code w/o looking twice or more.
It's still not perfect but way better to read. So when converting (or
writing new) code think whether your struct names or variable names
need to be that long
struct netvsc_driver_context *net_drv_ctx;
vs.
struct netsvc_drv_ctx *net_drv_ctx;
carries exact the same amount of information, but more condensed and lets
net_drv_ctx = container_of(driver_ctx, struct netvsc_drv_ctx, drv_ctx);
fit into one line.
So yes, it's more work for you in the first place, but in the end it's
better readable code and you make it way easier for those who are
spending their (quality) time to review it.
Thanks,
tglx
^ permalink raw reply
* Re: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: Greg KH @ 2011-02-23 21:26 UTC (permalink / raw)
To: Haiyang Zhang
Cc: hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
virtualization
In-Reply-To: <1298492398-16522-1-git-send-email-haiyangz@microsoft.com>
On Wed, Feb 23, 2011 at 12:19:55PM -0800, Haiyang Zhang wrote:
> The patch fixed the code depending on the exact order of fields in the
> struct vmbus_driver_context, so the unused field drv_ctx can be removed,
> and drv_obj doesn't have to be the second field in this structure.
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
>
> ---
> drivers/staging/hv/blkvsc_drv.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 | 14 +-------------
> 5 files changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 36a0adb..293ab8e 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -177,6 +177,8 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
> struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
> int ret;
>
> + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> +
> storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
>
> /* Callback to client driver to complete the initialization */
> diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
> index 03f9740..364b6c7 100644
> --- a/drivers/staging/hv/netvsc_drv.c
> +++ b/drivers/staging/hv/netvsc_drv.c
> @@ -500,6 +500,8 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
> struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
> int ret;
>
> + drv_ctx->hv_drv = &net_drv_obj->base;
> +
> net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
> net_drv_obj->recv_cb = netvsc_recv_callback;
> net_drv_obj->link_status_change = netvsc_linkstatus_callback;
> diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
> index a8427ff..33acee5 100644
> --- a/drivers/staging/hv/storvsc_drv.c
> +++ b/drivers/staging/hv/storvsc_drv.c
> @@ -140,6 +140,8 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
> struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
> struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
>
> + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> +
> storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
>
> /* Callback to client driver to complete the initialization */
> diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
> index 42f2adb..fd9d00f 100644
> --- a/drivers/staging/hv/vmbus.h
> +++ b/drivers/staging/hv/vmbus.h
> @@ -30,8 +30,8 @@
>
> struct driver_context {
> struct hv_guid class_id;
> -
> struct device_driver driver;
> + struct hv_driver *hv_drv;
If you have a pointer to hv_driver, why do you need a full 'struct
device_driver' here? That sounds really wrong.
Actually, having 'struct device_driver' within a structure called
"driver_context" seems wrong, this should be what 'struct hv_driver'
really is, right?
So no, I can't take this patch, as it isn't solving the root problem
here.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 2/4] staging: hv: Fix the code depending on struct netvsc_driver_context data order
From: Greg KH @ 2011-02-23 21:27 UTC (permalink / raw)
To: Haiyang Zhang
Cc: hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
virtualization
In-Reply-To: <1298492398-16522-2-git-send-email-haiyangz@microsoft.com>
On Wed, Feb 23, 2011 at 12:19:56PM -0800, Haiyang Zhang wrote:
> The patch fixed the code depending on the exact order of fields in the
> struct netvsc_driver_context. Now, we use container_of() instead of type
> casting from the first field to the container struct.
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
>
> ---
> drivers/staging/hv/netvsc_drv.c | 14 ++++++--------
> 1 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
> index 364b6c7..c78624c 100644
> --- a/drivers/staging/hv/netvsc_drv.c
> +++ b/drivers/staging/hv/netvsc_drv.c
> @@ -49,8 +49,6 @@ struct net_device_context {
> };
>
> struct netvsc_driver_context {
> - /* !! These must be the first 2 fields !! */
> - /* Which is a bug FIXME! */
> struct driver_context drv_ctx;
> struct netvsc_driver drv_obj;
> };
> @@ -137,8 +135,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
> struct net_device_context *net_device_ctx = netdev_priv(net);
> struct driver_context *driver_ctx =
> driver_to_driver_context(net_device_ctx->device_ctx->device.driver);
> - struct netvsc_driver_context *net_drv_ctx =
> - (struct netvsc_driver_context *)driver_ctx;
> + struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
> + struct netvsc_driver_context, drv_ctx);
> struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
> struct hv_netvsc_packet *packet;
> int ret;
> @@ -342,8 +340,8 @@ static int netvsc_probe(struct device *device)
> {
> struct driver_context *driver_ctx =
> driver_to_driver_context(device->driver);
> - struct netvsc_driver_context *net_drv_ctx =
> - (struct netvsc_driver_context *)driver_ctx;
> + struct netvsc_driver_context *net_drv_ctx = container_of(driver_ctx,
> + struct netvsc_driver_context, drv_ctx);
container_of calls should be turned into either a macro, or an inline
function, to make them smaller and easier to understand what is going
on. Do that and you will solve the line-length problems as well.
Please do that here.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 3/4] staging: hv: Fix the code depending on struct blkvsc_driver_context data order
From: Greg KH @ 2011-02-23 21:28 UTC (permalink / raw)
To: Haiyang Zhang
Cc: hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
virtualization
In-Reply-To: <1298492398-16522-3-git-send-email-haiyangz@microsoft.com>
On Wed, Feb 23, 2011 at 12:19:57PM -0800, Haiyang Zhang wrote:
> The patch fixed the code depending on the exact order of fields in the
> struct blkvsc_driver_context. Now, we use container_of() instead of type
> casting from the first field to the container struct.
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
>
> ---
> drivers/staging/hv/blkvsc_drv.c | 8 +++-----
> 1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 293ab8e..8f38895 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -117,8 +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;
> };
> @@ -248,7 +246,7 @@ static int blkvsc_probe(struct device *device)
> struct driver_context *driver_ctx =
> driver_to_driver_context(device->driver);
> struct blkvsc_driver_context *blkvsc_drv_ctx =
> - (struct blkvsc_driver_context *)driver_ctx;
> + container_of(driver_ctx, struct blkvsc_driver_context, drv_ctx);
Same container_of() complaint here, make it a macro or inline function.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 4/4] staging: hv: Fix the code depending on struct storvsc_driver_context data order
From: Greg KH @ 2011-02-23 21:28 UTC (permalink / raw)
To: Haiyang Zhang
Cc: hjanssen, kys, v-abkane, gregkh, linux-kernel, devel,
virtualization
In-Reply-To: <1298492398-16522-4-git-send-email-haiyangz@microsoft.com>
On Wed, Feb 23, 2011 at 12:19:58PM -0800, Haiyang Zhang wrote:
> The patch fixed the code depending on the exact order of fields in the
> struct storvsc_driver_context. Now, we use container_of() instead of type
> casting from the first field to the container struct.
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
>
> ---
> drivers/staging/hv/storvsc_drv.c | 14 ++++++--------
> 1 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
> index 33acee5..a364627 100644
> --- a/drivers/staging/hv/storvsc_drv.c
> +++ b/drivers/staging/hv/storvsc_drv.c
> @@ -64,8 +64,6 @@ struct storvsc_cmd_request {
> };
>
> struct storvsc_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;
> };
> @@ -223,8 +221,8 @@ static int storvsc_probe(struct device *device)
> int ret;
> struct driver_context *driver_ctx =
> driver_to_driver_context(device->driver);
> - struct storvsc_driver_context *storvsc_drv_ctx =
> - (struct storvsc_driver_context *)driver_ctx;
> + struct storvsc_driver_context *storvsc_drv_ctx = container_of(
> + driver_ctx, struct storvsc_driver_context, drv_ctx);
Same container_of() macro/inline function issue.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 2/6] Staging: hv: hv.c Removed all DPRINT and debug - using pr_err now
From: Greg KH @ 2011-02-23 21:56 UTC (permalink / raw)
To: Hank Janssen
Cc: Haiyang Zhang, gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
KY Srinivasan
In-Reply-To: <8AFC7968D54FB448A30D8F38F259C56233FADA94@TK5EX14MBXC118.redmond.corp.microsoft.com>
On Wed, Feb 23, 2011 at 07:41:28PM +0000, Hank Janssen wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Wednesday, February 23, 2011 11:16 AM
> >
> > On Tue, Feb 22, 2011 at 03:32:41PM -0800, Hank Janssen wrote:
> > > This group of patches removes all DPRINT from hv_vmbus.ko.
> > > It is divided in several patches due to size.
> > >
> > > All DPRINT calls have been removed, and where needed have been
> > > replaced with pr_XX native calls. Many debug DPRINT calls have
> > > been removed outright.
> > >
> > > The amount of clutter this driver prints has been
> > > significantly reduced.
> > >
> > > Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > >
> > > ---
> > > drivers/staging/hv/hv.c | 88 +++++++++++--------------------------
> > ---------
> > > 1 files changed, 21 insertions(+), 67 deletions(-)
>
> > > - DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",\
> > > - eax,
> > > - ebx >> 16,
> > > - ebx & 0xFFFF,
> > > - ecx,
> > > - edx >> 24,
> > > - edx & 0xFFFFFF);
> > > +
> > > + pr_info("%s: Hyper-V Host OS Build:%d-%d.%d-%d-%d.%d",
> > > + VMBUS_MOD,
> > > + eax,
> > > + ebx >> 16,
> > > + ebx & 0xFFFF,
> > > + ecx,
> > > + edx >> 24,
> > > + edx & 0xFFFFFF);
> >
> > Why did you keep this one? Why is it needed?
>
> This tells me what version the host is running. I frequently ask customers if
> they are running on Host version X or Y. This tells me that with certainty
> what they are running. The number of times I got from a customer that
> they are running X while I knew that would not be possible has been pretty
> high.
Ok, fair enough.
> > > if (!query_hypervisor_presence()) {
> > > - DPRINT_ERR(VMBUS, "No Windows hypervisor detected!!");
> > > + pr_err("%s: %s No Hyper-V detected", VMBUS_MOD, __func__);
> >
> > Why the __func__? That should never be needed as it is trivial to see
> > what is happening, the user doesn't need to know the function name,
> > right?
> >
> > Please remove them from all of these calls.
>
> The new patch will have these removed. When I checked other drivers
> in the drivers subdirectory the __func__ is used 15455 times most
> of these are in print, debug or error lines. The __func__ in this
> case only shows up if an error occurs.
>
> But as requested, I will remove them.
Thanks.
> > Oh, and you obviously didn't test these patches as your syslog would be
> > a mess if you did. Which is NOT ok, and makes me grumpy:
> > http://www.kroah.com/log/linux/maintainer-05.html
> >
> > bah, I should just make a numbered list and just start saying: "This
> > patch fails point #4" or something like that, it would save me in
> > typing...
> >
>
> They where compile and run tested. And syslog was not a mess. What did
> I mess up here? The amount of printouts now are a fraction of what they
> where before.
You forgot to put '\n' at the end of all of your pr_XXX lines, so they
will be merged with the next one, messing up your syslog. Joe also
pointed this problem out.
Take a look at your syslog to see what I am talking about...
thanks,
greg k-h
^ permalink raw reply
* RE: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: KY Srinivasan @ 2011-02-23 22:44 UTC (permalink / raw)
To: Greg KH, Haiyang Zhang
Cc: Hank Janssen, Abhishek Kane (Mindtree Consulting PVT LTD),
gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
In-Reply-To: <20110223212644.GC23766@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, February 23, 2011 4:27 PM
> To: Haiyang Zhang
> Cc: Hank Janssen; KY Srinivasan; Abhishek Kane (Mindtree Consulting PVT LTD);
> gregkh@suse.de; linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: [PATCH 1/4] staging: hv: Fix the code depending on struct
> vmbus_driver_context data order
>
> On Wed, Feb 23, 2011 at 12:19:55PM -0800, Haiyang Zhang wrote:
> > The patch fixed the code depending on the exact order of fields in the
> > struct vmbus_driver_context, so the unused field drv_ctx can be removed,
> > and drv_obj doesn't have to be the second field in this structure.
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
> >
> > ---
> > drivers/staging/hv/blkvsc_drv.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 | 14 +-------------
> > 5 files changed, 8 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> > index 36a0adb..293ab8e 100644
> > --- a/drivers/staging/hv/blkvsc_drv.c
> > +++ b/drivers/staging/hv/blkvsc_drv.c
> > @@ -177,6 +177,8 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver
> *drv))
> > struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
> > int ret;
> >
> > + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> > +
> > storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
> >
> > /* Callback to client driver to complete the initialization */
> > diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
> > index 03f9740..364b6c7 100644
> > --- a/drivers/staging/hv/netvsc_drv.c
> > +++ b/drivers/staging/hv/netvsc_drv.c
> > @@ -500,6 +500,8 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver
> *drv))
> > struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
> > int ret;
> >
> > + drv_ctx->hv_drv = &net_drv_obj->base;
> > +
> > net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
> > net_drv_obj->recv_cb = netvsc_recv_callback;
> > net_drv_obj->link_status_change = netvsc_linkstatus_callback;
> > diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
> > index a8427ff..33acee5 100644
> > --- a/drivers/staging/hv/storvsc_drv.c
> > +++ b/drivers/staging/hv/storvsc_drv.c
> > @@ -140,6 +140,8 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver
> *drv))
> > struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
> > struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
> >
> > + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> > +
> > storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
> >
> > /* Callback to client driver to complete the initialization */
> > diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
> > index 42f2adb..fd9d00f 100644
> > --- a/drivers/staging/hv/vmbus.h
> > +++ b/drivers/staging/hv/vmbus.h
> > @@ -30,8 +30,8 @@
> >
> > struct driver_context {
> > struct hv_guid class_id;
> > -
> > struct device_driver driver;
> > + struct hv_driver *hv_drv;
>
> If you have a pointer to hv_driver, why do you need a full 'struct
> device_driver' here? That sounds really wrong.
>
> Actually, having 'struct device_driver' within a structure called
> "driver_context" seems wrong, this should be what 'struct hv_driver'
> really is, right?
We could certainly use better names to describe the layering here:
Think of driver_context as a representation of a generic hyperV device
driver. So, this structure will embed the generic struct device_driver.
The pointer to hv_drv allows for further specialization based on
the device type. For instance the block driver has its own hv_driver while
the network driver has its own instance of hv_driver. I am not defending
this layering, and I agree we could name these abstractions to be more
intuitive and also considerably improve the layering.
Regards,
K. Y
>
> So no, I can't take this patch, as it isn't solving the root problem
> here.
>
> thanks,
>
> greg k-h
^ permalink raw reply
* RE: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: Haiyang Zhang @ 2011-02-23 22:48 UTC (permalink / raw)
To: Greg KH
Cc: Hank Janssen, KY Srinivasan,
Abhishek Kane (Mindtree Consulting PVT LTD), gregkh@suse.de,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <20110223212644.GC23766@kroah.com>
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, February 23, 2011 4:27 PM
> > struct driver_context {
> > struct hv_guid class_id;
> > -
> > struct device_driver driver;
> > + struct hv_driver *hv_drv;
>
> If you have a pointer to hv_driver, why do you need a full 'struct
> device_driver' here? That sounds really wrong.
>
> Actually, having 'struct device_driver' within a structure called
> "driver_context" seems wrong, this should be what 'struct hv_driver'
> really is, right?
The hv_driver contains Hyper-V specific data, like hv_guid. But the
struct driver_context contains data and functions related to Linux
kernel side, such as the struct device_driver defined by kernel. So,
they are kept separately.
(just saw Ky's email, which further explained the layering.)
Thanks,
- Haiyang
^ permalink raw reply
* Re: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: Greg KH @ 2011-02-23 22:48 UTC (permalink / raw)
To: KY Srinivasan
Cc: Haiyang Zhang, Hank Janssen,
Abhishek Kane (Mindtree Consulting PVT LTD), gregkh@suse.de,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <6E21E5352C11B742B20C142EB499E048014F2C@TK5EX14MBXC128.redmond.corp.microsoft.com>
On Wed, Feb 23, 2011 at 10:44:37PM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Wednesday, February 23, 2011 4:27 PM
> > To: Haiyang Zhang
> > Cc: Hank Janssen; KY Srinivasan; Abhishek Kane (Mindtree Consulting PVT LTD);
> > gregkh@suse.de; linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > virtualization@lists.osdl.org
> > Subject: Re: [PATCH 1/4] staging: hv: Fix the code depending on struct
> > vmbus_driver_context data order
> >
> > On Wed, Feb 23, 2011 at 12:19:55PM -0800, Haiyang Zhang wrote:
> > > The patch fixed the code depending on the exact order of fields in the
> > > struct vmbus_driver_context, so the unused field drv_ctx can be removed,
> > > and drv_obj doesn't have to be the second field in this structure.
> > >
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
> > >
> > > ---
> > > drivers/staging/hv/blkvsc_drv.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 | 14 +-------------
> > > 5 files changed, 8 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> > > index 36a0adb..293ab8e 100644
> > > --- a/drivers/staging/hv/blkvsc_drv.c
> > > +++ b/drivers/staging/hv/blkvsc_drv.c
> > > @@ -177,6 +177,8 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver
> > *drv))
> > > struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
> > > int ret;
> > >
> > > + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> > > +
> > > storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
> > >
> > > /* Callback to client driver to complete the initialization */
> > > diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
> > > index 03f9740..364b6c7 100644
> > > --- a/drivers/staging/hv/netvsc_drv.c
> > > +++ b/drivers/staging/hv/netvsc_drv.c
> > > @@ -500,6 +500,8 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver
> > *drv))
> > > struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
> > > int ret;
> > >
> > > + drv_ctx->hv_drv = &net_drv_obj->base;
> > > +
> > > net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
> > > net_drv_obj->recv_cb = netvsc_recv_callback;
> > > net_drv_obj->link_status_change = netvsc_linkstatus_callback;
> > > diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
> > > index a8427ff..33acee5 100644
> > > --- a/drivers/staging/hv/storvsc_drv.c
> > > +++ b/drivers/staging/hv/storvsc_drv.c
> > > @@ -140,6 +140,8 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver
> > *drv))
> > > struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
> > > struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
> > >
> > > + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> > > +
> > > storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
> > >
> > > /* Callback to client driver to complete the initialization */
> > > diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
> > > index 42f2adb..fd9d00f 100644
> > > --- a/drivers/staging/hv/vmbus.h
> > > +++ b/drivers/staging/hv/vmbus.h
> > > @@ -30,8 +30,8 @@
> > >
> > > struct driver_context {
> > > struct hv_guid class_id;
> > > -
> > > struct device_driver driver;
> > > + struct hv_driver *hv_drv;
> >
> > If you have a pointer to hv_driver, why do you need a full 'struct
> > device_driver' here? That sounds really wrong.
> >
> > Actually, having 'struct device_driver' within a structure called
> > "driver_context" seems wrong, this should be what 'struct hv_driver'
> > really is, right?
>
> We could certainly use better names to describe the layering here:
> Think of driver_context as a representation of a generic hyperV device
> driver. So, this structure will embed the generic struct device_driver.
That's fine, and is what all other driver subsystems do. But they name
it correctly, unlike this subsystem :)
> The pointer to hv_drv allows for further specialization based on
> the device type. For instance the block driver has its own hv_driver while
> the network driver has its own instance of hv_driver. I am not defending
> this layering, and I agree we could name these abstractions to be more
> intuitive and also considerably improve the layering.
The layering is almost ok, there is still one more layer here than is
needed, and it should be removed (I already removed lots of layers that
were not needed, just didn't get to this one.) But the naming also
needs to be fixed up as it is wrong from a "driver model" standpoint
with the rest of the kernel.
thanks,
greg k-h
^ permalink raw reply
* RE: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: Haiyang Zhang @ 2011-02-23 22:55 UTC (permalink / raw)
To: Greg KH, KY Srinivasan
Cc: Hank Janssen, Abhishek Kane (Mindtree Consulting PVT LTD),
gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
In-Reply-To: <20110223224829.GA7175@kroah.com>
> From: Greg KH [mailto:greg@kroah.com]
> The layering is almost ok, there is still one more layer here than is
> needed, and it should be removed (I already removed lots of layers that
> were not needed, just didn't get to this one.) But the naming also
> needs to be fixed up as it is wrong from a "driver model" standpoint
> with the rest of the kernel.
So, how about rename the "struct driver_context" to "struct gen_drv_ctx"
in this patch? We can deal with the layering in next round of patches.
Thanks,
- Haiyang
^ permalink raw reply
* RE: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: KY Srinivasan @ 2011-02-23 22:58 UTC (permalink / raw)
To: Greg KH
Cc: Haiyang Zhang, Hank Janssen,
Abhishek Kane (Mindtree Consulting PVT LTD), gregkh@suse.de,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <20110223224829.GA7175@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, February 23, 2011 5:48 PM
> To: KY Srinivasan
> Cc: Haiyang Zhang; Hank Janssen; Abhishek Kane (Mindtree Consulting PVT LTD);
> gregkh@suse.de; linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: [PATCH 1/4] staging: hv: Fix the code depending on struct
> vmbus_driver_context data order
>
> On Wed, Feb 23, 2011 at 10:44:37PM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Wednesday, February 23, 2011 4:27 PM
> > > To: Haiyang Zhang
> > > Cc: Hank Janssen; KY Srinivasan; Abhishek Kane (Mindtree Consulting PVT
> LTD);
> > > gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org;
> > > virtualization@lists.osdl.org
> > > Subject: Re: [PATCH 1/4] staging: hv: Fix the code depending on struct
> > > vmbus_driver_context data order
> > >
> > > On Wed, Feb 23, 2011 at 12:19:55PM -0800, Haiyang Zhang wrote:
> > > > The patch fixed the code depending on the exact order of fields in the
> > > > struct vmbus_driver_context, so the unused field drv_ctx can be removed,
> > > > and drv_obj doesn't have to be the second field in this structure.
> > > >
> > > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
> > > >
> > > > ---
> > > > drivers/staging/hv/blkvsc_drv.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 | 14 +-------------
> > > > 5 files changed, 8 insertions(+), 14 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/hv/blkvsc_drv.c
> b/drivers/staging/hv/blkvsc_drv.c
> > > > index 36a0adb..293ab8e 100644
> > > > --- a/drivers/staging/hv/blkvsc_drv.c
> > > > +++ b/drivers/staging/hv/blkvsc_drv.c
> > > > @@ -177,6 +177,8 @@ static int blkvsc_drv_init(int (*drv_init)(struct
> hv_driver
> > > *drv))
> > > > struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
> > > > int ret;
> > > >
> > > > + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> > > > +
> > > > storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
> > > >
> > > > /* Callback to client driver to complete the initialization */
> > > > diff --git a/drivers/staging/hv/netvsc_drv.c
> b/drivers/staging/hv/netvsc_drv.c
> > > > index 03f9740..364b6c7 100644
> > > > --- a/drivers/staging/hv/netvsc_drv.c
> > > > +++ b/drivers/staging/hv/netvsc_drv.c
> > > > @@ -500,6 +500,8 @@ static int netvsc_drv_init(int (*drv_init)(struct
> hv_driver
> > > *drv))
> > > > struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
> > > > int ret;
> > > >
> > > > + drv_ctx->hv_drv = &net_drv_obj->base;
> > > > +
> > > > net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
> > > > net_drv_obj->recv_cb = netvsc_recv_callback;
> > > > net_drv_obj->link_status_change = netvsc_linkstatus_callback;
> > > > diff --git a/drivers/staging/hv/storvsc_drv.c
> b/drivers/staging/hv/storvsc_drv.c
> > > > index a8427ff..33acee5 100644
> > > > --- a/drivers/staging/hv/storvsc_drv.c
> > > > +++ b/drivers/staging/hv/storvsc_drv.c
> > > > @@ -140,6 +140,8 @@ static int storvsc_drv_init(int (*drv_init)(struct
> hv_driver
> > > *drv))
> > > > struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
> > > > struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
> > > >
> > > > + drv_ctx->hv_drv = &storvsc_drv_obj->base;
> > > > +
> > > > storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
> > > >
> > > > /* Callback to client driver to complete the initialization */
> > > > diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
> > > > index 42f2adb..fd9d00f 100644
> > > > --- a/drivers/staging/hv/vmbus.h
> > > > +++ b/drivers/staging/hv/vmbus.h
> > > > @@ -30,8 +30,8 @@
> > > >
> > > > struct driver_context {
> > > > struct hv_guid class_id;
> > > > -
> > > > struct device_driver driver;
> > > > + struct hv_driver *hv_drv;
> > >
> > > If you have a pointer to hv_driver, why do you need a full 'struct
> > > device_driver' here? That sounds really wrong.
> > >
> > > Actually, having 'struct device_driver' within a structure called
> > > "driver_context" seems wrong, this should be what 'struct hv_driver'
> > > really is, right?
> >
> > We could certainly use better names to describe the layering here:
> > Think of driver_context as a representation of a generic hyperV device
> > driver. So, this structure will embed the generic struct device_driver.
>
> That's fine, and is what all other driver subsystems do. But they name
> it correctly, unlike this subsystem :)
>
We will get there!
> > The pointer to hv_drv allows for further specialization based on
> > the device type. For instance the block driver has its own hv_driver while
> > the network driver has its own instance of hv_driver. I am not defending
> > this layering, and I agree we could name these abstractions to be more
> > intuitive and also considerably improve the layering.
>
> The layering is almost ok, there is still one more layer here than is
> needed, and it should be removed (I already removed lots of layers that
> were not needed, just didn't get to this one.) But the naming also
> needs to be fixed up as it is wrong from a "driver model" standpoint
> with the rest of the kernel.
We will get rid of this additional layering. We could just as well embed the
needed information.
Regards,
K. Y
>
> thanks,
>
> greg k-h
^ permalink raw reply
* Re: [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order
From: Greg KH @ 2011-02-23 23:06 UTC (permalink / raw)
To: Haiyang Zhang
Cc: KY Srinivasan, Hank Janssen,
Abhishek Kane (Mindtree Consulting PVT LTD), gregkh@suse.de,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
In-Reply-To: <A1F3067C9B68744AA19F6802BAB8FFDC060EE9@TK5EX14MBXC227.redmond.corp.microsoft.com>
On Wed, Feb 23, 2011 at 10:55:12PM +0000, Haiyang Zhang wrote:
> > From: Greg KH [mailto:greg@kroah.com]
> > The layering is almost ok, there is still one more layer here than is
> > needed, and it should be removed (I already removed lots of layers that
> > were not needed, just didn't get to this one.) But the naming also
> > needs to be fixed up as it is wrong from a "driver model" standpoint
> > with the rest of the kernel.
>
> So, how about rename the "struct driver_context" to "struct gen_drv_ctx"
> in this patch? We can deal with the layering in next round of patches.
No, it's not a "driver context" at all. It is a "hyperv driver", so
name it as such.
A "context" is a void pointer or something that the driver uses
privately. And you already have a pointer to the context in the base
structure so you don't need your own.
You should work on removing the layering now, that will clean this all
up.
thanks,
greg k-h
^ permalink raw reply
* RE: [PATCH 2/6] Staging: hv: hv.c Removed all DPRINT and debug - using pr_err now
From: Hank Janssen @ 2011-02-23 23:17 UTC (permalink / raw)
To: Greg KH
Cc: Haiyang Zhang, gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
KY Srinivasan
In-Reply-To: <20110223215658.GB16908@kroah.com>
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Wednesday, February 23, 2011 1:57 PM
> They where compile and run tested. And syslog was not a mess. What did
> > I mess up here? The amount of printouts now are a fraction of what
> > they where before.
>
> You forgot to put '\n' at the end of all of your pr_XXX lines, so they will be
> merged with the next one, messing up your syslog. Joe also pointed this
> problem out.
>
> Take a look at your syslog to see what I am talking about...
I am trying to get some of these patches corrected and out today, but it might
be tomorrow. So far I have lost power for a minutes or so twice this afternoon.
It seems that the threat of snow is enough to lose power where I am in the PNW.
Sigh......
Hank.
^ permalink raw reply
* Re: [PATCH 2/6] Staging: hv: hv.c Removed all DPRINT and debug - using pr_err now
From: Greg KH @ 2011-02-23 23:48 UTC (permalink / raw)
To: Hank Janssen
Cc: Haiyang Zhang, gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
KY Srinivasan
In-Reply-To: <8AFC7968D54FB448A30D8F38F259C56233FAE0E8@TK5EX14MBXC118.redmond.corp.microsoft.com>
On Wed, Feb 23, 2011 at 11:17:54PM +0000, Hank Janssen wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Wednesday, February 23, 2011 1:57 PM
> > They where compile and run tested. And syslog was not a mess. What did
> > > I mess up here? The amount of printouts now are a fraction of what
> > > they where before.
> >
> > You forgot to put '\n' at the end of all of your pr_XXX lines, so they will be
> > merged with the next one, messing up your syslog. Joe also pointed this
> > problem out.
> >
> > Take a look at your syslog to see what I am talking about...
>
> I am trying to get some of these patches corrected and out today, but it might
> be tomorrow. So far I have lost power for a minutes or so twice this afternoon.
No rush, I've flushed out all of my staging tree patches today, so it
will be a number of days before I revisit them again.
thanks,
greg k-h
^ permalink raw reply
* RE: [PATCH 2/6] Staging: hv: hv.c Removed all DPRINT and debug - using pr_err now
From: Joe Perches @ 2011-02-24 0:57 UTC (permalink / raw)
To: Hank Janssen
Cc: Greg KH, gregkh@suse.de, linux-kernel@vger.kernel.org,
virtualization@lists.osdl.org, devel@linuxdriverproject.org
In-Reply-To: <8AFC7968D54FB448A30D8F38F259C56233FAE0E8@TK5EX14MBXC118.redmond.corp.microsoft.com>
On Wed, 2011-02-23 at 23:17 +0000, Hank Janssen wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Wednesday, February 23, 2011 1:57 PM
> > They where compile and run tested. And syslog was not a mess. What did
> > > I mess up here? The amount of printouts now are a fraction of what
> > > they where before.
> > You forgot to put '\n' at the end of all of your pr_XXX lines, so they will be
> > merged with the next one, messing up your syslog. Joe also pointed this
> > problem out.
> > Take a look at your syslog to see what I am talking about...
Greg, there probably isn't any problem with his syslog.
Running together of messages without terminating newlines
did used to happen though until commit
5fd29d6ccbc98884569d6f3105aeca70858b3e0f
("printk: clean up handling of log-levels and newlines")
changed behavior so that newlines are emitted if necessary
before every "<.>" loglevel but "<c>".
That means that adding trailing newlines to pr_<level>
calls aren't _really_ necessary unless the pr_<level>
is followed by a bare printk without KERN_<LEVEL>.
I still think it's better from a style perspective to keep
adding terminating newlines until most all of the printks
are converted to pr_<level>.
^ permalink raw reply
* Re: [PATCH 2/6] Staging: hv: hv.c Removed all DPRINT and debug - using pr_err now
From: Greg KH @ 2011-02-24 1:29 UTC (permalink / raw)
To: Joe Perches
Cc: Hank Janssen, gregkh@suse.de, linux-kernel@vger.kernel.org,
virtualization@lists.osdl.org, devel@linuxdriverproject.org
In-Reply-To: <1298509049.32283.21.camel@Joe-Laptop>
On Wed, Feb 23, 2011 at 04:57:29PM -0800, Joe Perches wrote:
> On Wed, 2011-02-23 at 23:17 +0000, Hank Janssen wrote:
> > > -----Original Message-----
> > > From: Greg KH [mailto:greg@kroah.com]
> > > Sent: Wednesday, February 23, 2011 1:57 PM
> > > They where compile and run tested. And syslog was not a mess. What did
> > > > I mess up here? The amount of printouts now are a fraction of what
> > > > they where before.
> > > You forgot to put '\n' at the end of all of your pr_XXX lines, so they will be
> > > merged with the next one, messing up your syslog. Joe also pointed this
> > > problem out.
> > > Take a look at your syslog to see what I am talking about...
>
> Greg, there probably isn't any problem with his syslog.
>
> Running together of messages without terminating newlines
> did used to happen though until commit
> 5fd29d6ccbc98884569d6f3105aeca70858b3e0f
> ("printk: clean up handling of log-levels and newlines")
> changed behavior so that newlines are emitted if necessary
> before every "<.>" loglevel but "<c>".
>
> That means that adding trailing newlines to pr_<level>
> calls aren't _really_ necessary unless the pr_<level>
> is followed by a bare printk without KERN_<LEVEL>.
Ah, I didn't realize that this had changed, my mistake, nevermind :)
> I still think it's better from a style perspective to keep
> adding terminating newlines until most all of the printks
> are converted to pr_<level>.
Yes, that would be good to have done.
thanks,
greg k-h
^ permalink raw reply
* Can't build in the virtio console driver on x86_64 when the other virtio drivers are modular
From: Chuck Ebbert @ 2011-02-24 16:28 UTC (permalink / raw)
To: virtualization; +Cc: Amit Shah, linux-kernel
The virtio configuration options are inconsistent. According to this,
every options that needs virtio will select it:
# Virtio always gets selected by whoever wants it.
config VIRTIO
tristate
Note that it's not user-selectable, so any config file that tries to
set it will be ignored when kconfig loads those options. And yet we
have a whole set of options that depend on VIRTIO, like VIRTIO_CONSOLE
for example. This makes it impossible to have VIRTIO_PCI modular and
VIRTIO_CONSOLE built-in on x86_64, because:
1. VIRTIO_PCI selects VIRTIO and sets it to M
2. VIRTIO_CONSOLE gets forced to M because one of its dependencies is M
So either VIRTIO (and VIRTIO_RING) need to be user-selectable, or all
of the options that depend on VIRTIO need to be changed to select it
instead.
(For even more fun, LGUEST_GUEST on i386 forces VIRTIO, VIRTIO_RING and
VIRTIO_CONSOLE all to Y.)
^ permalink raw reply
* [PATCH ] Staging: hv: Hyper-V driver cleanup
From: K. Y. Srinivasan @ 2011-02-24 23:20 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang, Hank Janssen
This patch cleans up (a lot of the) naming issues that
various reviewers have noted. It also gets rid of
some unnecessary layering in the code. At the lowest
level, we have one abstraction for representing
a hyperv device (struct hyperv_device) and one
abstraction for representing a hyperv driver
(struct hyperv_driver). This collapses an unnecessary
layering that existed in the code for historical reasons.
While the patch is large, it was generated by a very
mechanical process (global search and replace). The code
compiles cleanly and I have tested this code on a 2.6.38
kernel.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/blkvsc.c | 19 +-
drivers/staging/hv/blkvsc_drv.c | 76 ++++----
drivers/staging/hv/channel_mgmt.c | 1 +
drivers/staging/hv/channel_mgmt.h | 2 +-
drivers/staging/hv/netvsc.c | 65 ++++---
drivers/staging/hv/netvsc.h | 2 +-
drivers/staging/hv/netvsc_api.h | 16 +-
drivers/staging/hv/netvsc_drv.c | 108 +++++------
drivers/staging/hv/rndis_filter.c | 23 ++-
drivers/staging/hv/storvsc.c | 43 +++--
drivers/staging/hv/storvsc_api.h | 10 +-
drivers/staging/hv/storvsc_drv.c | 106 +++++------
drivers/staging/hv/vmbus.h | 38 +++--
drivers/staging/hv/vmbus_api.h | 37 +----
drivers/staging/hv/vmbus_drv.c | 364 +++++++++++++++++-------------------
drivers/staging/hv/vmbus_private.h | 13 +-
16 files changed, 439 insertions(+), 484 deletions(-)
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
index 7c8729b..2d1d0bd 100644
--- a/drivers/staging/hv/blkvsc.c
+++ b/drivers/staging/hv/blkvsc.c
@@ -35,7 +35,8 @@ static const struct hv_guid g_blk_device_type = {
}
};
-static int blk_vsc_on_device_add(struct hv_device *device, void *additional_info)
+static int blk_vsc_on_device_add(struct hyperv_device *device,
+ void *additional_info)
{
struct storvsc_device_info *device_info;
int ret = 0;
@@ -51,18 +52,18 @@ static int blk_vsc_on_device_add(struct hv_device *device, void *additional_info
* id. For IDE devices, the device instance id is formatted as
* <bus id> * - <device id> - 8899 - 000000000000.
*/
- device_info->path_id = device->dev_instance.data[3] << 24 |
- device->dev_instance.data[2] << 16 |
- device->dev_instance.data[1] << 8 |
- device->dev_instance.data[0];
+ device_info->path_id = device->device_id.data[3] << 24 |
+ device->device_id.data[2] << 16 |
+ device->device_id.data[1] << 8 |
+ device->device_id.data[0];
- device_info->target_id = device->dev_instance.data[5] << 8 |
- device->dev_instance.data[4];
+ device_info->target_id = device->device_id.data[5] << 8 |
+ device->device_id.data[4];
return ret;
}
-int blk_vsc_initialize(struct hv_driver *driver)
+int blk_vsc_initialize(struct hyperv_driver *driver)
{
struct storvsc_driver_object *stor_driver;
int ret = 0;
@@ -73,7 +74,7 @@ int blk_vsc_initialize(struct hv_driver *driver)
/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
driver->name = g_blk_driver_name;
- memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
+ memcpy(&driver->class_id, &g_blk_device_type, sizeof(struct hv_guid));
stor_driver->request_ext_size = sizeof(struct storvsc_request_extension);
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index 36a0adb..194f648 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 hyperv_device *hyperv_dev;
struct kmem_cache *request_pool;
spinlock_t lock;
struct gendisk *gd;
@@ -116,10 +116,10 @@ struct block_device_context {
};
/* Per driver */
-struct blkvsc_driver_context {
+struct blkvsc_hyperv_driver {
/* !! These must be the first 2 fields !! */
/* FIXME this is a bug! */
- struct driver_context drv_ctx;
+ struct hyperv_driver drv;
struct storvsc_driver_object drv_obj;
};
@@ -156,7 +156,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 blkvsc_hyperv_driver g_blkvsc_drv;
static const struct block_device_operations block_ops = {
.owner = THIS_MODULE,
@@ -171,10 +171,10 @@ static const struct block_device_operations block_ops = {
/*
* blkvsc_drv_init - BlkVsc driver initialization.
*/
-static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
+static int blkvsc_drv_init(int (*drv_init)(struct hyperv_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 hyperv_driver *drv = &g_blkvsc_drv.drv;
int ret;
storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
@@ -182,16 +182,16 @@ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
/* 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,
+ drv->driver.name = storvsc_drv_obj->base.name;
+ memcpy(&drv->class_id, &storvsc_drv_obj->base.class_id,
sizeof(struct hv_guid));
- drv_ctx->probe = blkvsc_probe;
- drv_ctx->remove = blkvsc_remove;
- drv_ctx->shutdown = blkvsc_shutdown;
+ drv->probe = blkvsc_probe;
+ drv->remove = blkvsc_remove;
+ drv->shutdown = blkvsc_shutdown;
/* The driver belongs to vmbus */
- ret = vmbus_child_driver_register(drv_ctx);
+ ret = vmbus_child_driver_register(drv);
return ret;
}
@@ -206,7 +206,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 hyperv_driver *drv = &g_blkvsc_drv.drv;
struct device *current_dev;
int ret;
@@ -214,7 +214,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 *) ¤t_dev,
blkvsc_drv_exit_cb);
@@ -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);
return;
}
@@ -243,14 +243,13 @@ 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 blkvsc_driver_context *blkvsc_drv_ctx =
- (struct blkvsc_driver_context *)driver_ctx;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(device->driver);
+ struct blkvsc_hyperv_driver *blkvsc_drv =
+ (struct blkvsc_hyperv_driver *)drv;
struct storvsc_driver_object *storvsc_drv_obj =
- &blkvsc_drv_ctx->drv_obj;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ &blkvsc_drv->drv_obj;
+ struct hyperv_device *device_obj = device_to_hyperv_device(device);
struct block_device_context *blkdev = NULL;
struct storvsc_device_info device_info;
@@ -282,7 +281,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);
@@ -299,7 +298,7 @@ static int blkvsc_probe(struct device *device)
goto Cleanup;
}
- blkdev->device_ctx = device_ctx;
+ blkdev->hyperv_dev = device_obj;
/* this identified the device 0 or 1 */
blkdev->target = device_info.target_id;
/* this identified the ide ctrl 0 or 1 */
@@ -368,7 +367,7 @@ static int blkvsc_probe(struct device *device)
blkdev->gd->first_minor = 0;
blkdev->gd->fops = &block_ops;
blkdev->gd->private_data = blkdev;
- blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device);
+ blkdev->gd->driverfs_dev = &(blkdev->hyperv_dev->device);
sprintf(blkdev->gd->disk_name, "hd%c", 'a' + devnum);
blkvsc_do_inquiry(blkdev);
@@ -728,14 +727,13 @@ 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 blkvsc_driver_context *blkvsc_drv_ctx =
- (struct blkvsc_driver_context *)driver_ctx;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(device->driver);
+ struct blkvsc_hyperv_driver *blkvsc_drv =
+ (struct blkvsc_hyperv_driver *)drv;
struct storvsc_driver_object *storvsc_drv_obj =
- &blkvsc_drv_ctx->drv_obj;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ &blkvsc_drv->drv_obj;
+ struct hyperv_device *device_obj = device_to_hyperv_device(device);
struct block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags;
int ret;
@@ -850,13 +848,13 @@ 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 driver_context *driver_ctx =
- driver_to_driver_context(device_ctx->device.driver);
- struct blkvsc_driver_context *blkvsc_drv_ctx =
- (struct blkvsc_driver_context *)driver_ctx;
+ struct hyperv_device *hyperv_dev = blkdev->hyperv_dev;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(hyperv_dev->device.driver);
+ struct blkvsc_hyperv_driver *blkvsc_drv =
+ (struct blkvsc_hyperv_driver *)drv;
struct storvsc_driver_object *storvsc_drv_obj =
- &blkvsc_drv_ctx->drv_obj;
+ &blkvsc_drv->drv_obj;
struct hv_storvsc_request *storvsc_req;
int ret;
@@ -897,7 +895,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->hyperv_dev,
&blkvsc_req->request);
if (ret == 0)
blkdev->num_outstanding_reqs++;
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 0781c0e..8d81288 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -28,6 +28,7 @@
#include <linux/completion.h>
#include "hv_api.h"
#include "logging.h"
+#include "vmbus.h"
#include "vmbus_private.h"
#include "utils.h"
diff --git a/drivers/staging/hv/channel_mgmt.h b/drivers/staging/hv/channel_mgmt.h
index 3368bf1..7b42883 100644
--- a/drivers/staging/hv/channel_mgmt.h
+++ b/drivers/staging/hv/channel_mgmt.h
@@ -228,7 +228,7 @@ enum vmbus_channel_state {
struct vmbus_channel {
struct list_head listentry;
- struct hv_device *device_obj;
+ struct hyperv_device *device_obj;
struct timer_list poll_timer; /* SA-111 workaround */
struct work_struct work;
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 20b1597..8cf4f9c 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -26,6 +26,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include "hv_api.h"
+#include "vmbus.h"
#include "logging.h"
#include "netvsc.h"
#include "rndis_filter.h"
@@ -43,40 +44,41 @@ static const struct hv_guid netvsc_device_type = {
}
};
-static int netvsc_device_add(struct hv_device *device, void *additional_info);
+static int netvsc_device_add(struct hyperv_device *device,
+ void *additional_info);
-static int netvsc_device_remove(struct hv_device *device);
+static int netvsc_device_remove(struct hyperv_device *device);
-static void netvsc_cleanup(struct hv_driver *driver);
+static void netvsc_cleanup(struct hyperv_driver *driver);
static void netvsc_channel_cb(void *context);
-static int netvsc_init_send_buf(struct hv_device *device);
+static int netvsc_init_send_buf(struct hyperv_device *device);
-static int netvsc_init_recv_buf(struct hv_device *device);
+static int netvsc_init_recv_buf(struct hyperv_device *device);
static int netvsc_destroy_send_buf(struct netvsc_device *net_device);
static int netvsc_destroy_recv_buf(struct netvsc_device *net_device);
-static int netvsc_connect_vsp(struct hv_device *device);
+static int netvsc_connect_vsp(struct hyperv_device *device);
-static void netvsc_send_completion(struct hv_device *device,
+static void netvsc_send_completion(struct hyperv_device *device,
struct vmpacket_descriptor *packet);
-static int netvsc_send(struct hv_device *device,
+static int netvsc_send(struct hyperv_device *device,
struct hv_netvsc_packet *packet);
-static void netvsc_receive(struct hv_device *device,
+static void netvsc_receive(struct hyperv_device *device,
struct vmpacket_descriptor *packet);
static void netvsc_receive_completion(void *context);
-static void netvsc_send_recv_completion(struct hv_device *device,
+static void netvsc_send_recv_completion(struct hyperv_device *device,
u64 transaction_id);
-static struct netvsc_device *alloc_net_device(struct hv_device *device)
+static struct netvsc_device *alloc_net_device(struct hyperv_device *device)
{
struct netvsc_device *net_device;
@@ -102,7 +104,8 @@ static void free_net_device(struct netvsc_device *device)
/* Get the net device object iff exists and its refcount > 1 */
-static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
+static struct netvsc_device *
+get_outbound_net_device(struct hyperv_device *device)
{
struct netvsc_device *net_device;
@@ -116,7 +119,8 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
}
/* Get the net device object iff exists and its refcount > 0 */
-static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
+static struct netvsc_device *
+get_inbound_net_device(struct hyperv_device *device)
{
struct netvsc_device *net_device;
@@ -129,7 +133,7 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
return net_device;
}
-static void put_net_device(struct hv_device *device)
+static void put_net_device(struct hyperv_device *device)
{
struct netvsc_device *net_device;
@@ -139,7 +143,7 @@ static void put_net_device(struct hv_device *device)
}
static struct netvsc_device *release_outbound_net_device(
- struct hv_device *device)
+ struct hyperv_device *device)
{
struct netvsc_device *net_device;
@@ -155,7 +159,7 @@ static struct netvsc_device *release_outbound_net_device(
}
static struct netvsc_device *release_inbound_net_device(
- struct hv_device *device)
+ struct hyperv_device *device)
{
struct netvsc_device *net_device;
@@ -174,7 +178,7 @@ static struct netvsc_device *release_inbound_net_device(
/*
* netvsc_initialize - Main entry point
*/
-int netvsc_initialize(struct hv_driver *drv)
+int netvsc_initialize(struct hyperv_driver *drv)
{
struct netvsc_driver *driver = (struct netvsc_driver *)drv;
@@ -186,7 +190,7 @@ int netvsc_initialize(struct hv_driver *drv)
sizeof(struct vmtransfer_page_packet_header));
drv->name = driver_name;
- memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
+ memcpy(&drv->class_id, &netvsc_device_type, sizeof(struct hv_guid));
/* Setup the dispatch table */
driver->base.dev_add = netvsc_device_add;
@@ -199,7 +203,7 @@ int netvsc_initialize(struct hv_driver *drv)
return 0;
}
-static int netvsc_init_recv_buf(struct hv_device *device)
+static int netvsc_init_recv_buf(struct hyperv_device *device)
{
int ret = 0;
struct netvsc_device *net_device;
@@ -329,7 +333,7 @@ exit:
return ret;
}
-static int netvsc_init_send_buf(struct hv_device *device)
+static int netvsc_init_send_buf(struct hyperv_device *device)
{
int ret = 0;
struct netvsc_device *net_device;
@@ -571,7 +575,7 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
}
-static int netvsc_connect_vsp(struct hv_device *device)
+static int netvsc_connect_vsp(struct hyperv_device *device)
{
int ret;
struct netvsc_device *net_device;
@@ -687,7 +691,8 @@ static void NetVscDisconnectFromVsp(struct netvsc_device *net_device)
* netvsc_device_add - Callback when the device belonging to this
* driver is added
*/
-static int netvsc_device_add(struct hv_device *device, void *additional_info)
+static int netvsc_device_add(struct hyperv_device *device,
+ void *additional_info)
{
int ret = 0;
int i;
@@ -780,7 +785,7 @@ cleanup:
/*
* netvsc_device_remove - Callback when the root bus device is removed
*/
-static int netvsc_device_remove(struct hv_device *device)
+static int netvsc_device_remove(struct hyperv_device *device)
{
struct netvsc_device *net_device;
struct hv_netvsc_packet *netvsc_packet, *pos;
@@ -832,11 +837,11 @@ static int netvsc_device_remove(struct hv_device *device)
/*
* netvsc_cleanup - Perform any cleanup when the driver is removed
*/
-static void netvsc_cleanup(struct hv_driver *drv)
+static void netvsc_cleanup(struct hyperv_driver *drv)
{
}
-static void netvsc_send_completion(struct hv_device *device,
+static void netvsc_send_completion(struct hyperv_device *device,
struct vmpacket_descriptor *packet)
{
struct netvsc_device *net_device;
@@ -885,7 +890,7 @@ static void netvsc_send_completion(struct hv_device *device,
put_net_device(device);
}
-static int netvsc_send(struct hv_device *device,
+static int netvsc_send(struct hyperv_device *device,
struct hv_netvsc_packet *packet)
{
struct netvsc_device *net_device;
@@ -939,7 +944,7 @@ static int netvsc_send(struct hv_device *device,
return ret;
}
-static void netvsc_receive(struct hv_device *device,
+static void netvsc_receive(struct hyperv_device *device,
struct vmpacket_descriptor *packet)
{
struct netvsc_device *net_device;
@@ -1136,7 +1141,7 @@ static void netvsc_receive(struct hv_device *device,
put_net_device(device);
}
-static void netvsc_send_recv_completion(struct hv_device *device,
+static void netvsc_send_recv_completion(struct hyperv_device *device,
u64 transaction_id)
{
struct nvsp_message recvcompMessage;
@@ -1185,7 +1190,7 @@ retry_send_cmplt:
static void netvsc_receive_completion(void *context)
{
struct hv_netvsc_packet *packet = context;
- struct hv_device *device = (struct hv_device *)packet->device;
+ struct hyperv_device *device = (struct hyperv_device *)packet->device;
struct netvsc_device *net_device;
u64 transaction_id = 0;
bool fsend_receive_comp = false;
@@ -1234,7 +1239,7 @@ static void netvsc_receive_completion(void *context)
static void netvsc_channel_cb(void *context)
{
int ret;
- struct hv_device *device = context;
+ struct hyperv_device *device = context;
struct netvsc_device *net_device;
u32 bytes_recvd;
u64 request_id;
diff --git a/drivers/staging/hv/netvsc.h b/drivers/staging/hv/netvsc.h
index 45d24b9..ea3a05f 100644
--- a/drivers/staging/hv/netvsc.h
+++ b/drivers/staging/hv/netvsc.h
@@ -293,7 +293,7 @@ struct nvsp_message {
/* Per netvsc channel-specific */
struct netvsc_device {
- struct hv_device *dev;
+ struct hyperv_device *dev;
atomic_t refcnt;
atomic_t num_outstanding_sends;
diff --git a/drivers/staging/hv/netvsc_api.h b/drivers/staging/hv/netvsc_api.h
index b4bed36..a96cce4 100644
--- a/drivers/staging/hv/netvsc_api.h
+++ b/drivers/staging/hv/netvsc_api.h
@@ -49,7 +49,7 @@ struct hv_netvsc_packet {
/* Bookkeeping stuff */
struct list_head list_ent;
- struct hv_device *device;
+ struct hyperv_device *device;
bool is_data_pkt;
/*
@@ -84,7 +84,7 @@ struct hv_netvsc_packet {
struct netvsc_driver {
/* Must be the first field */
/* Which is a bug FIXME! */
- struct hv_driver base;
+ struct hyperv_driver base;
u32 ring_buf_size;
u32 req_ext_size;
@@ -93,12 +93,12 @@ struct netvsc_driver {
* This is set by the caller to allow us to callback when we
* receive a packet from the "wire"
*/
- int (*recv_cb)(struct hv_device *dev,
+ int (*recv_cb)(struct hyperv_device *dev,
struct hv_netvsc_packet *packet);
- void (*link_status_change)(struct hv_device *dev, u32 status);
+ void (*link_status_change)(struct hyperv_device *dev, u32 status);
/* Specific to this driver */
- int (*send)(struct hv_device *dev, struct hv_netvsc_packet *packet);
+ int (*send)(struct hyperv_device *dev, struct hv_netvsc_packet *packet);
void *ctx;
};
@@ -109,8 +109,8 @@ struct netvsc_device_info {
};
/* Interface */
-int netvsc_initialize(struct hv_driver *drv);
-int rndis_filter_open(struct hv_device *dev);
-int rndis_filter_close(struct hv_device *dev);
+int netvsc_initialize(struct hyperv_driver *drv);
+int rndis_filter_open(struct hyperv_device *dev);
+int rndis_filter_close(struct hyperv_device *dev);
#endif /* _NETVSC_API_H_ */
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 03f9740..d2cbf4c 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -44,14 +44,14 @@
struct net_device_context {
/* point back to our device context */
- struct vm_device *device_ctx;
+ struct hyperv_device *hyperv_dev;
unsigned long avail;
};
-struct netvsc_driver_context {
+struct netvsc_hyperv_driver {
/* !! These must be the first 2 fields !! */
/* Which is a bug FIXME! */
- struct driver_context drv_ctx;
+ struct hyperv_driver drv;
struct netvsc_driver drv_obj;
};
@@ -64,7 +64,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_hyperv_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
@@ -75,8 +75,8 @@ static void netvsc_set_multicast_list(struct net_device *net)
static int netvsc_open(struct net_device *net)
{
- struct net_device_context *net_device_ctx = netdev_priv(net);
- struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj;
+ struct net_device_context *net_hyperv_dev = netdev_priv(net);
+ struct hyperv_device *device_obj = net_hyperv_dev->hyperv_dev;
int ret = 0;
if (netif_carrier_ok(net)) {
@@ -98,8 +98,8 @@ static int netvsc_open(struct net_device *net)
static int netvsc_close(struct net_device *net)
{
- struct net_device_context *net_device_ctx = netdev_priv(net);
- struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj;
+ struct net_device_context *net_hyperv_dev = netdev_priv(net);
+ struct hyperv_device *device_obj = net_hyperv_dev->hyperv_dev;
int ret;
netif_stop_queue(net);
@@ -121,25 +121,25 @@ static void netvsc_xmit_completion(void *context)
if (skb) {
struct net_device *net = skb->dev;
- struct net_device_context *net_device_ctx = netdev_priv(net);
+ struct net_device_context *net_hyperv_dev = netdev_priv(net);
unsigned int num_pages = skb_shinfo(skb)->nr_frags + 2;
dev_kfree_skb_any(skb);
- net_device_ctx->avail += num_pages;
- if (net_device_ctx->avail >= PACKET_PAGES_HIWATER)
+ net_hyperv_dev->avail += num_pages;
+ if (net_hyperv_dev->avail >= PACKET_PAGES_HIWATER)
netif_wake_queue(net);
}
}
static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
{
- struct net_device_context *net_device_ctx = netdev_priv(net);
- struct driver_context *driver_ctx =
- driver_to_driver_context(net_device_ctx->device_ctx->device.driver);
- struct netvsc_driver_context *net_drv_ctx =
- (struct netvsc_driver_context *)driver_ctx;
- struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
+ struct net_device_context *net_hyperv_dev = netdev_priv(net);
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(net_hyperv_dev->hyperv_dev->device.driver);
+ struct netvsc_hyperv_driver *net_drv =
+ (struct netvsc_hyperv_driver *)drv;
+ struct netvsc_driver *net_drv_obj = &net_drv->drv_obj;
struct hv_netvsc_packet *packet;
int ret;
unsigned int i, num_pages;
@@ -149,7 +149,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
/* Add 1 for skb->data and additional one for RNDIS */
num_pages = skb_shinfo(skb)->nr_frags + 1 + 1;
- if (num_pages > net_device_ctx->avail)
+ if (num_pages > net_hyperv_dev->avail)
return NETDEV_TX_BUSY;
/* Allocate a netvsc packet based on # of frags. */
@@ -198,7 +198,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
packet->completion.send.send_completion_ctx = packet;
packet->completion.send.send_completion_tid = (unsigned long)skb;
- ret = net_drv_obj->send(&net_device_ctx->device_ctx->device_obj,
+ ret = net_drv_obj->send(net_hyperv_dev->hyperv_dev,
packet);
if (ret == 0) {
net->stats.tx_bytes += skb->len;
@@ -208,8 +208,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
net->stats.tx_packets,
net->stats.tx_bytes);
- net_device_ctx->avail -= num_pages;
- if (net_device_ctx->avail < PACKET_PAGES_LOWATER)
+ net_hyperv_dev->avail -= num_pages;
+ if (net_hyperv_dev->avail < PACKET_PAGES_LOWATER)
netif_stop_queue(net);
} else {
/* we are shutting down or bus overloaded, just drop packet */
@@ -223,11 +223,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
/*
* netvsc_linkstatus_callback - Link up/down notification
*/
-static void netvsc_linkstatus_callback(struct hv_device *device_obj,
+static void netvsc_linkstatus_callback(struct hyperv_device *hyperv_dev,
unsigned int status)
{
- struct vm_device *device_ctx = to_vm_device(device_obj);
- struct net_device *net = dev_get_drvdata(&device_ctx->device);
+ struct net_device *net = dev_get_drvdata(&hyperv_dev->device);
if (!net) {
DPRINT_ERR(NETVSC_DRV, "got link status but net device "
@@ -249,11 +248,10 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
* netvsc_recv_callback - Callback when we receive a packet from the
* "wire" on the specified device.
*/
-static int netvsc_recv_callback(struct hv_device *device_obj,
+static int netvsc_recv_callback(struct hyperv_device *hyperv_dev,
struct hv_netvsc_packet *packet)
{
- struct vm_device *device_ctx = to_vm_device(device_obj);
- struct net_device *net = dev_get_drvdata(&device_ctx->device);
+ struct net_device *net = dev_get_drvdata(&hyperv_dev->device);
struct sk_buff *skb;
void *data;
int i;
@@ -340,15 +338,14 @@ static const struct net_device_ops device_ops = {
static int netvsc_probe(struct device *device)
{
- struct driver_context *driver_ctx =
- driver_to_driver_context(device->driver);
- struct netvsc_driver_context *net_drv_ctx =
- (struct netvsc_driver_context *)driver_ctx;
- struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(device->driver);
+ struct netvsc_hyperv_driver *net_drv =
+ (struct netvsc_hyperv_driver *)drv;
+ struct netvsc_driver *net_drv_obj = &net_drv->drv_obj;
+ struct hyperv_device *device_obj = device_to_hyperv_device(device);
struct net_device *net = NULL;
- struct net_device_context *net_device_ctx;
+ struct net_device_context *net_hyperv_dev;
struct netvsc_device_info device_info;
int ret;
@@ -362,9 +359,9 @@ static int netvsc_probe(struct device *device)
/* Set initial state */
netif_carrier_off(net);
- net_device_ctx = netdev_priv(net);
- net_device_ctx->device_ctx = device_ctx;
- net_device_ctx->avail = ring_size;
+ net_hyperv_dev = netdev_priv(net);
+ net_hyperv_dev->hyperv_dev = device_obj;
+ net_hyperv_dev->avail = ring_size;
dev_set_drvdata(device, net);
/* Notify the netvsc driver of the new device */
@@ -412,14 +409,13 @@ static int netvsc_probe(struct device *device)
static int netvsc_remove(struct device *device)
{
- struct driver_context *driver_ctx =
- driver_to_driver_context(device->driver);
- struct netvsc_driver_context *net_drv_ctx =
- (struct netvsc_driver_context *)driver_ctx;
- struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
- 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;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(device->driver);
+ struct netvsc_hyperv_driver *net_drv =
+ (struct netvsc_hyperv_driver *)drv;
+ struct netvsc_driver *net_drv_obj = &net_drv->drv_obj;
+ struct hyperv_device *device_obj = device_to_hyperv_device(device);
+ struct net_device *net = dev_get_drvdata(&device_obj->device);
int ret;
if (net == NULL) {
@@ -462,7 +458,7 @@ 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 driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
+ struct hyperv_driver *drv = &g_netvsc_drv.drv;
struct device *current_dev;
int ret;
@@ -470,7 +466,7 @@ static void netvsc_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,
¤t_dev, netvsc_drv_exit_cb);
if (ret)
DPRINT_WARN(NETVSC_DRV,
@@ -489,15 +485,15 @@ 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);
return;
}
-static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
+static int netvsc_drv_init(int (*drv_init)(struct hyperv_driver *drv))
{
struct netvsc_driver *net_drv_obj = &g_netvsc_drv.drv_obj;
- struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
+ struct hyperv_driver *drv = &g_netvsc_drv.drv;
int ret;
net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
@@ -507,15 +503,15 @@ static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
/* Callback to client driver to complete the initialization */
drv_init(&net_drv_obj->base);
- drv_ctx->driver.name = net_drv_obj->base.name;
- memcpy(&drv_ctx->class_id, &net_drv_obj->base.dev_type,
+ drv->driver.name = net_drv_obj->base.name;
+ memcpy(&drv->class_id, &net_drv_obj->base.class_id,
sizeof(struct hv_guid));
- drv_ctx->probe = netvsc_probe;
- drv_ctx->remove = netvsc_remove;
+ drv->probe = netvsc_probe;
+ drv->remove = netvsc_remove;
/* The driver belongs to vmbus */
- ret = vmbus_child_driver_register(drv_ctx);
+ ret = vmbus_child_driver_register(drv);
return ret;
}
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index e7189cd..a8f7927 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -28,6 +28,7 @@
#include "logging.h"
#include "hv_api.h"
+#include "vmbus.h"
#include "netvsc_api.h"
#include "rndis_filter.h"
@@ -84,14 +85,14 @@ struct rndis_filter_packet {
};
-static int rndis_filte_device_add(struct hv_device *dev,
+static int rndis_filte_device_add(struct hyperv_device *dev,
void *additional_info);
-static int rndis_filter_device_remove(struct hv_device *dev);
+static int rndis_filter_device_remove(struct hyperv_device *dev);
-static void rndis_filter_cleanup(struct hv_driver *drv);
+static void rndis_filter_cleanup(struct hyperv_driver *drv);
-static int rndis_filter_send(struct hv_device *dev,
+static int rndis_filter_send(struct hyperv_device *dev,
struct hv_netvsc_packet *pkt);
static void rndis_filter_send_completion(void *ctx);
@@ -375,7 +376,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
pkt);
}
-static int rndis_filter_receive(struct hv_device *dev,
+static int rndis_filter_receive(struct hyperv_device *dev,
struct hv_netvsc_packet *pkt)
{
struct netvsc_device *net_dev = dev->ext;
@@ -753,7 +754,7 @@ static int rndis_filter_close_device(struct rndis_device *dev)
return ret;
}
-static int rndis_filte_device_add(struct hv_device *dev,
+static int rndis_filte_device_add(struct hyperv_device *dev,
void *additional_info)
{
int ret;
@@ -816,7 +817,7 @@ static int rndis_filte_device_add(struct hv_device *dev,
return ret;
}
-static int rndis_filter_device_remove(struct hv_device *dev)
+static int rndis_filter_device_remove(struct hyperv_device *dev)
{
struct netvsc_device *net_dev = dev->ext;
struct rndis_device *rndis_dev = net_dev->extension;
@@ -833,11 +834,11 @@ static int rndis_filter_device_remove(struct hv_device *dev)
return 0;
}
-static void rndis_filter_cleanup(struct hv_driver *drv)
+static void rndis_filter_cleanup(struct hyperv_driver *drv)
{
}
-int rndis_filter_open(struct hv_device *dev)
+int rndis_filter_open(struct hyperv_device *dev)
{
struct netvsc_device *netDevice = dev->ext;
@@ -847,7 +848,7 @@ int rndis_filter_open(struct hv_device *dev)
return rndis_filter_open_device(netDevice->extension);
}
-int rndis_filter_close(struct hv_device *dev)
+int rndis_filter_close(struct hyperv_device *dev)
{
struct netvsc_device *netDevice = dev->ext;
@@ -857,7 +858,7 @@ int rndis_filter_close(struct hv_device *dev)
return rndis_filter_close_device(netDevice->extension);
}
-static int rndis_filter_send(struct hv_device *dev,
+static int rndis_filter_send(struct hyperv_device *dev,
struct hv_netvsc_packet *pkt)
{
int ret;
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index e2ad729..dcecd25 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -26,6 +26,7 @@
#include <linux/mm.h>
#include <linux/delay.h>
#include "hv_api.h"
+#include "vmbus.h"
#include "logging.h"
#include "storvsc_api.h"
#include "vmbus_packet_format.h"
@@ -37,7 +38,7 @@ struct storvsc_request_extension {
/* LIST_ENTRY ListEntry; */
struct hv_storvsc_request *request;
- struct hv_device *device;
+ struct hyperv_device *device;
/* Synchronize the request/response if needed */
int wait_condition;
@@ -48,7 +49,7 @@ struct storvsc_request_extension {
/* A storvsc device is a device object that contains a vmbus channel */
struct storvsc_device {
- struct hv_device *device;
+ struct hyperv_device *device;
/* 0 indicates the device is being destroyed */
atomic_t ref_count;
@@ -84,7 +85,8 @@ static const struct hv_guid gStorVscDeviceType = {
};
-static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
+static inline struct
+storvsc_device *alloc_stor_device(struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -109,7 +111,8 @@ static inline void free_stor_device(struct storvsc_device *device)
}
/* Get the stordevice object iff exists and its refcount > 1 */
-static inline struct storvsc_device *get_stor_device(struct hv_device *device)
+static inline struct storvsc_device *
+get_stor_device(struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -124,7 +127,7 @@ static inline struct storvsc_device *get_stor_device(struct hv_device *device)
/* Get the stordevice object iff exists and its refcount > 0 */
static inline struct storvsc_device *must_get_stor_device(
- struct hv_device *device)
+ struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -137,7 +140,7 @@ static inline struct storvsc_device *must_get_stor_device(
return stor_device;
}
-static inline void put_stor_device(struct hv_device *device)
+static inline void put_stor_device(struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -150,7 +153,7 @@ static inline void put_stor_device(struct hv_device *device)
/* Drop ref count to 1 to effectively disable get_stor_device() */
static inline struct storvsc_device *release_stor_device(
- struct hv_device *device)
+ struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -166,7 +169,7 @@ static inline struct storvsc_device *release_stor_device(
/* Drop ref count to 0. No one can use stor_device object. */
static inline struct storvsc_device *final_release_stor_device(
- struct hv_device *device)
+ struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -181,7 +184,7 @@ static inline struct storvsc_device *final_release_stor_device(
return stor_device;
}
-static int stor_vsc_channel_init(struct hv_device *device)
+static int stor_vsc_channel_init(struct hyperv_device *device)
{
struct storvsc_device *stor_device;
struct storvsc_request_extension *request;
@@ -362,7 +365,7 @@ cleanup:
return ret;
}
-static void stor_vsc_on_io_completion(struct hv_device *device,
+static void stor_vsc_on_io_completion(struct hyperv_device *device,
struct vstor_packet *vstor_packet,
struct storvsc_request_extension *request_ext)
{
@@ -426,7 +429,7 @@ static void stor_vsc_on_io_completion(struct hv_device *device,
put_stor_device(device);
}
-static void stor_vsc_on_receive(struct hv_device *device,
+static void stor_vsc_on_receive(struct hyperv_device *device,
struct vstor_packet *vstor_packet,
struct storvsc_request_extension *request_ext)
{
@@ -449,7 +452,7 @@ static void stor_vsc_on_receive(struct hv_device *device,
static void stor_vsc_on_channel_callback(void *context)
{
- struct hv_device *device = (struct hv_device *)context;
+ struct hyperv_device *device = (struct hyperv_device *)context;
struct storvsc_device *stor_device;
u32 bytes_recvd;
u64 request_id;
@@ -509,7 +512,7 @@ static void stor_vsc_on_channel_callback(void *context)
return;
}
-static int stor_vsc_connect_to_vsp(struct hv_device *device)
+static int stor_vsc_connect_to_vsp(struct hyperv_device *device)
{
struct vmstorage_channel_properties props;
struct storvsc_driver_object *stor_driver;
@@ -543,7 +546,7 @@ static int stor_vsc_connect_to_vsp(struct hv_device *device)
* stor_vsc_on_device_add - Callback when the device belonging to this driver
* is added
*/
-static int stor_vsc_on_device_add(struct hv_device *device,
+static int stor_vsc_on_device_add(struct hyperv_device *device,
void *additional_info)
{
struct storvsc_device *stor_device;
@@ -592,7 +595,7 @@ cleanup:
/*
* stor_vsc_on_device_remove - Callback when the our device is being removed
*/
-static int stor_vsc_on_device_remove(struct hv_device *device)
+static int stor_vsc_on_device_remove(struct hyperv_device *device)
{
struct storvsc_device *stor_device;
@@ -626,7 +629,7 @@ static int stor_vsc_on_device_remove(struct hv_device *device)
return 0;
}
-int stor_vsc_on_host_reset(struct hv_device *device)
+int stor_vsc_on_host_reset(struct hyperv_device *device)
{
struct storvsc_device *stor_device;
struct storvsc_request_extension *request;
@@ -685,7 +688,7 @@ cleanup:
/*
* stor_vsc_on_io_request - Callback to initiate an I/O request
*/
-static int stor_vsc_on_io_request(struct hv_device *device,
+static int stor_vsc_on_io_request(struct hyperv_device *device,
struct hv_storvsc_request *request)
{
struct storvsc_device *stor_device;
@@ -778,14 +781,14 @@ static int stor_vsc_on_io_request(struct hv_device *device,
/*
* stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
*/
-static void stor_vsc_on_cleanup(struct hv_driver *driver)
+static void stor_vsc_on_cleanup(struct hyperv_driver *driver)
{
}
/*
* stor_vsc_initialize - Main entry point
*/
-int stor_vsc_initialize(struct hv_driver *driver)
+int stor_vsc_initialize(struct hyperv_driver *driver)
{
struct storvsc_driver_object *stor_driver;
@@ -804,7 +807,7 @@ int stor_vsc_initialize(struct hv_driver *driver)
/* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
driver->name = g_driver_name;
- memcpy(&driver->dev_type, &gStorVscDeviceType,
+ memcpy(&driver->class_id, &gStorVscDeviceType,
sizeof(struct hv_guid));
stor_driver->request_ext_size =
diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h
index fbf5755..e105929 100644
--- a/drivers/staging/hv/storvsc_api.h
+++ b/drivers/staging/hv/storvsc_api.h
@@ -80,7 +80,7 @@ struct hv_storvsc_request {
struct storvsc_driver_object {
/* Must be the first field */
/* Which is a bug FIXME! */
- struct hv_driver base;
+ struct hyperv_driver base;
/* Set by caller (in bytes) */
u32 ring_buffer_size;
@@ -92,7 +92,7 @@ struct storvsc_driver_object {
u32 max_outstanding_req_per_channel;
/* Specific to this driver */
- int (*on_io_request)(struct hv_device *device,
+ int (*on_io_request)(struct hyperv_device *device,
struct hv_storvsc_request *request);
};
@@ -103,8 +103,8 @@ struct storvsc_device_info {
};
/* Interface */
-int stor_vsc_initialize(struct hv_driver *driver);
-int stor_vsc_on_host_reset(struct hv_device *device);
-int blk_vsc_initialize(struct hv_driver *driver);
+int stor_vsc_initialize(struct hyperv_driver *driver);
+int stor_vsc_on_host_reset(struct hyperv_device *device);
+int blk_vsc_initialize(struct hyperv_driver *driver);
#endif /* _STORVSC_API_H_ */
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index a8427ff..d09fe16 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -42,7 +42,7 @@ struct host_device_context {
/* must be 1st field
* FIXME this is a bug */
/* point back to our device context */
- struct vm_device *device_ctx;
+ struct hyperv_device *hyperv_dev;
struct kmem_cache *request_pool;
unsigned int port;
unsigned char path;
@@ -63,10 +63,10 @@ struct storvsc_cmd_request {
* Which sounds like a very bad design... */
};
-struct storvsc_driver_context {
+struct storvsc_hyperv_driver {
/* !! These must be the first 2 fields !! */
/* FIXME this is a bug... */
- struct driver_context drv_ctx;
+ struct hyperv_driver drv;
struct storvsc_driver_object drv_obj;
};
@@ -100,7 +100,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_hyperv_driver g_storvsc_drv;
/* Scsi driver */
static struct scsi_host_template scsi_driver = {
@@ -134,11 +134,11 @@ static struct scsi_host_template scsi_driver = {
/*
* storvsc_drv_init - StorVsc driver initialization.
*/
-static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
+static int storvsc_drv_init(int (*drv_init)(struct hyperv_driver *drv))
{
int ret;
struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
- struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
+ struct hyperv_driver *drv = &g_storvsc_drv.drv;
storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
@@ -160,15 +160,15 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
return -1;
}
- drv_ctx->driver.name = storvsc_drv_obj->base.name;
- memcpy(&drv_ctx->class_id, &storvsc_drv_obj->base.dev_type,
+ drv->driver.name = storvsc_drv_obj->base.name;
+ memcpy(&drv->class_id, &storvsc_drv_obj->base.class_id,
sizeof(struct hv_guid));
- drv_ctx->probe = storvsc_probe;
- drv_ctx->remove = storvsc_remove;
+ drv->probe = storvsc_probe;
+ drv->remove = storvsc_remove;
/* The driver belongs to vmbus */
- ret = vmbus_child_driver_register(drv_ctx);
+ ret = vmbus_child_driver_register(drv);
return ret;
}
@@ -183,7 +183,7 @@ 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 driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
+ struct hyperv_driver *drv = &g_storvsc_drv.drv;
struct device *current_dev = NULL;
int ret;
@@ -191,7 +191,7 @@ static void storvsc_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 *) ¤t_dev,
storvsc_drv_exit_cb);
@@ -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);
return;
}
@@ -219,14 +219,13 @@ static void storvsc_drv_exit(void)
static int storvsc_probe(struct device *device)
{
int ret;
- struct driver_context *driver_ctx =
- driver_to_driver_context(device->driver);
- struct storvsc_driver_context *storvsc_drv_ctx =
- (struct storvsc_driver_context *)driver_ctx;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(device->driver);
+ struct storvsc_hyperv_driver *storvsc_drv =
+ (struct storvsc_hyperv_driver *)drv;
struct storvsc_driver_object *storvsc_drv_obj =
- &storvsc_drv_ctx->drv_obj;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ &storvsc_drv->drv_obj;
+ struct hyperv_device *device_obj = device_to_hyperv_device(device);
struct Scsi_Host *host;
struct host_device_context *host_device_ctx;
struct storvsc_device_info device_info;
@@ -247,10 +246,10 @@ static int storvsc_probe(struct device *device)
memset(host_device_ctx, 0, sizeof(struct host_device_context));
host_device_ctx->port = host->host_no;
- host_device_ctx->device_ctx = device_ctx;
+ host_device_ctx->hyperv_dev = device_obj;
host_device_ctx->request_pool =
- kmem_cache_create(dev_name(&device_ctx->device),
+ kmem_cache_create(dev_name(&device_obj->device),
sizeof(struct storvsc_cmd_request) +
storvsc_drv_obj->request_ext_size, 0,
SLAB_HWCACHE_ALIGN, NULL);
@@ -271,7 +270,7 @@ static int storvsc_probe(struct device *device)
return -1;
}
- /* host_device_ctx->port = device_info.PortNumber; */
+ /* host_hyperv_dev->port = device_info.PortNumber; */
host_device_ctx->path = device_info.path_id;
host_device_ctx->target = device_info.target_id;
@@ -304,16 +303,15 @@ static int storvsc_probe(struct device *device)
static int storvsc_remove(struct device *device)
{
int ret;
- struct driver_context *driver_ctx =
- driver_to_driver_context(device->driver);
- struct storvsc_driver_context *storvsc_drv_ctx =
- (struct storvsc_driver_context *)driver_ctx;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(device->driver);
+ struct storvsc_hyperv_driver *storvsc_drv =
+ (struct storvsc_hyperv_driver *)drv;
struct storvsc_driver_object *storvsc_drv_obj =
- &storvsc_drv_ctx->drv_obj;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ &storvsc_drv->drv_obj;
+ struct hyperv_device *device_obj = device_to_hyperv_device(device);
struct Scsi_Host *host = dev_get_drvdata(device);
- struct host_device_context *host_device_ctx =
+ struct host_device_context *host_hyperv_dev =
(struct host_device_context *)host->hostdata;
@@ -331,9 +329,9 @@ static int storvsc_remove(struct device *device)
ret);
}
- if (host_device_ctx->request_pool) {
- kmem_cache_destroy(host_device_ctx->request_pool);
- host_device_ctx->request_pool = NULL;
+ if (host_hyperv_dev->request_pool) {
+ kmem_cache_destroy(host_hyperv_dev->request_pool);
+ host_hyperv_dev->request_pool = NULL;
}
DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
@@ -352,7 +350,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
struct storvsc_cmd_request *cmd_request =
(struct storvsc_cmd_request *)request->context;
struct scsi_cmnd *scmnd = cmd_request->cmd;
- struct host_device_context *host_device_ctx =
+ struct host_device_context *host_hyperv_dev =
(struct host_device_context *)scmnd->device->host->hostdata;
void (*scsi_done_fn)(struct scsi_cmnd *);
struct scsi_sense_hdr sense_hdr;
@@ -395,7 +393,7 @@ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
/* !!DO NOT MODIFY the scmnd after this call */
scsi_done_fn(scmnd);
- kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+ kmem_cache_free(host_hyperv_dev->request_pool, cmd_request);
}
static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
@@ -599,15 +597,15 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
void (*done)(struct scsi_cmnd *))
{
int ret;
- struct host_device_context *host_device_ctx =
+ struct host_device_context *host_hyperv_dev =
(struct host_device_context *)scmnd->device->host->hostdata;
- struct vm_device *device_ctx = host_device_ctx->device_ctx;
- struct driver_context *driver_ctx =
- driver_to_driver_context(device_ctx->device.driver);
- struct storvsc_driver_context *storvsc_drv_ctx =
- (struct storvsc_driver_context *)driver_ctx;
+ struct hyperv_device *hyperv_dev = host_hyperv_dev->hyperv_dev;
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(hyperv_dev->device.driver);
+ struct storvsc_hyperv_driver *storvsc_drv =
+ (struct storvsc_hyperv_driver *)drv;
struct storvsc_driver_object *storvsc_drv_obj =
- &storvsc_drv_ctx->drv_obj;
+ &storvsc_drv->drv_obj;
struct hv_storvsc_request *request;
struct storvsc_cmd_request *cmd_request;
unsigned int request_size = 0;
@@ -640,7 +638,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
request_size = sizeof(struct storvsc_cmd_request);
- cmd_request = kmem_cache_alloc(host_device_ctx->request_pool,
+ cmd_request = kmem_cache_alloc(host_hyperv_dev->request_pool,
GFP_ATOMIC);
if (!cmd_request) {
DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
@@ -680,7 +678,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
request->context = cmd_request;/* scmnd; */
/* request->PortId = scmnd->device->channel; */
- request->host = host_device_ctx->port;
+ request->host = host_hyperv_dev->port;
request->bus = scmnd->device->channel;
request->target_id = scmnd->device->id;
request->lun_id = scmnd->device->lun;
@@ -713,7 +711,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
scmnd->scsi_done = NULL;
scmnd->host_scribble = NULL;
- kmem_cache_free(host_device_ctx->request_pool,
+ kmem_cache_free(host_hyperv_dev->request_pool,
cmd_request);
return SCSI_MLQUEUE_HOST_BUSY;
@@ -752,7 +750,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
retry_request:
/* Invokes the vsc to start an IO */
- ret = storvsc_drv_obj->on_io_request(&device_ctx->device_obj,
+ ret = storvsc_drv_obj->on_io_request(hyperv_dev,
&cmd_request->request);
if (ret == -1) {
/* no more space */
@@ -772,7 +770,7 @@ retry_request:
cmd_request->bounce_sgl_count);
}
- kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+ kmem_cache_free(host_hyperv_dev->request_pool, cmd_request);
scmnd->scsi_done = NULL;
scmnd->host_scribble = NULL;
@@ -837,20 +835,20 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
{
int ret;
- struct host_device_context *host_device_ctx =
+ struct host_device_context *host_hyperv_dev =
(struct host_device_context *)scmnd->device->host->hostdata;
- struct vm_device *device_ctx = host_device_ctx->device_ctx;
+ struct hyperv_device *hyperv_dev = host_hyperv_dev->hyperv_dev;
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
- scmnd->device, &device_ctx->device_obj);
+ scmnd->device, hyperv_dev);
/* Invokes the vsc to reset the host/bus */
- ret = stor_vsc_on_host_reset(&device_ctx->device_obj);
+ ret = stor_vsc_on_host_reset(hyperv_dev);
if (ret != 0)
return ret;
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
- scmnd->device, &device_ctx->device_obj);
+ scmnd->device, hyperv_dev);
return ret;
}
diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
index 42f2adb..638bb9f 100644
--- a/drivers/staging/hv/vmbus.h
+++ b/drivers/staging/hv/vmbus.h
@@ -28,9 +28,17 @@
#include <linux/device.h>
#include "vmbus_api.h"
-struct driver_context {
+struct hyperv_driver {
+ const char *name;
+
struct hv_guid class_id;
+ int (*dev_add)(struct hyperv_device *device, void *data);
+
+ int (*dev_rm)(struct hyperv_device *device);
+
+ void (*cleanup)(struct hyperv_driver *driver);
+
struct device_driver driver;
/*
@@ -43,34 +51,34 @@ struct driver_context {
void (*shutdown)(struct device *);
};
-struct vm_device {
+struct hyperv_device {
+ char name[64];
struct work_struct probe_failed_work_item;
- struct hv_guid class_id;
- struct hv_guid device_id;
+ struct hv_guid class_id; /* device type id */
+ struct hv_guid device_id; /* device class id */
+ struct hyperv_driver *drv;
int probe_error;
- struct hv_device device_obj;
+ struct vmbus_channel *channel; /* associated channel to host*/
+ void *ext;
struct device device;
};
-static inline struct vm_device *to_vm_device(struct hv_device *d)
-{
- return container_of(d, struct vm_device, device_obj);
-}
-static inline struct vm_device *device_to_vm_device(struct device *d)
+static inline struct hyperv_device *device_to_hyperv_device(struct device *d)
{
- return container_of(d, struct vm_device, device);
+ return container_of(d, struct hyperv_device, device);
}
-static inline struct driver_context *driver_to_driver_context(struct device_driver *d)
+static inline struct hyperv_driver *
+driver_to_hyperv_driver(struct device_driver *d)
{
- return container_of(d, struct driver_context, driver);
+ return container_of(d, struct hyperv_driver, driver);
}
/* Vmbus interface */
-int vmbus_child_driver_register(struct driver_context *driver_ctx);
-void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
+int vmbus_child_driver_register(struct hyperv_driver *drv);
+void vmbus_child_driver_unregister(struct hyperv_driver *drv);
extern struct completion hv_channel_ready;
diff --git a/drivers/staging/hv/vmbus_api.h b/drivers/staging/hv/vmbus_api.h
index 635ce22..6e3e1a8 100644
--- a/drivers/staging/hv/vmbus_api.h
+++ b/drivers/staging/hv/vmbus_api.h
@@ -55,8 +55,8 @@ struct hv_multipage_buffer {
#pragma pack(pop)
-struct hv_driver;
-struct hv_device;
+struct hyperv_driver;
+struct hyperv_device;
struct hv_dev_port_info {
u32 int_mask;
@@ -66,7 +66,7 @@ struct hv_dev_port_info {
u32 bytes_avail_towrite;
};
-struct hv_device_info {
+struct hyperv_device_info {
u32 chn_id;
u32 chn_state;
struct hv_guid chn_type;
@@ -84,35 +84,4 @@ struct hv_device_info {
struct hv_dev_port_info outbound;
};
-/* Base driver object */
-struct hv_driver {
- const char *name;
-
- /* the device type supported by this driver */
- struct hv_guid dev_type;
-
- int (*dev_add)(struct hv_device *device, void *data);
- int (*dev_rm)(struct hv_device *device);
- void (*cleanup)(struct hv_driver *driver);
-};
-
-/* Base device object */
-struct hv_device {
- /* the driver for this device */
- struct hv_driver *drv;
-
- char name[64];
-
- /* the device type id of this device */
- struct hv_guid dev_type;
-
- /* the device instance id of this device */
- struct hv_guid dev_instance;
-
- struct vmbus_channel *channel;
-
- /* Device extension; */
- void *ext;
-};
-
#endif /* _VMBUS_API_H_ */
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 459c707..81e958a 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -41,20 +41,19 @@
#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
/* Main vmbus driver data structure */
-struct vmbus_driver_context {
+struct vmbus_hyperv_driver {
/* !! These must be the first 2 fields !! */
/* FIXME, this is a bug */
/* The driver field is not used in here. Instead, the bus field is */
/* used to represent the driver */
- struct driver_context drv_ctx;
- struct hv_driver drv_obj;
+ struct hyperv_driver drv;
struct bus_type bus;
struct tasklet_struct msg_dpc;
struct tasklet_struct event_dpc;
/* The bus root device */
- struct vm_device device_ctx;
+ struct hyperv_device hyperv_dev;
};
static int vmbus_match(struct device *device, struct device_driver *driver);
@@ -113,7 +112,7 @@ static struct device_attribute vmbus_device_attrs[] = {
};
/* The one and only one */
-static struct vmbus_driver_context vmbus_drv = {
+static struct vmbus_hyperv_driver g_vmbus_drv = {
.bus.name = "vmbus",
.bus.match = vmbus_match,
.bus.shutdown = vmbus_shutdown,
@@ -145,12 +144,12 @@ static const struct hv_guid device_id = {
}
};
-static struct hv_device *vmbus_device; /* vmbus root device */
+static struct hyperv_device *vmbus_device; /* vmbus root device */
/*
* vmbus_child_dev_add - Registers the child device with the vmbus
*/
-int vmbus_child_dev_add(struct hv_device *child_dev)
+int vmbus_child_dev_add(struct hyperv_device *child_dev)
{
return vmbus_child_device_register(vmbus_device, child_dev);
}
@@ -158,15 +157,15 @@ int vmbus_child_dev_add(struct hv_device *child_dev)
/*
* vmbus_dev_add - Callback when the root bus device is added
*/
-static int vmbus_dev_add(struct hv_device *dev, void *info)
+static int vmbus_dev_add(struct hyperv_device *dev, void *info)
{
u32 *irqvector = info;
int ret;
vmbus_device = dev;
- memcpy(&vmbus_device->dev_type, &device_type, sizeof(struct hv_guid));
- memcpy(&vmbus_device->dev_instance, &device_id,
+ memcpy(&vmbus_device->class_id, &device_type, sizeof(struct hv_guid));
+ memcpy(&vmbus_device->device_id, &device_id,
sizeof(struct hv_guid));
/* strcpy(dev->name, "vmbus"); */
@@ -183,7 +182,7 @@ static int vmbus_dev_add(struct hv_device *dev, void *info)
/*
* vmbus_dev_rm - Callback when the root bus device is removed
*/
-static int vmbus_dev_rm(struct hv_device *dev)
+static int vmbus_dev_rm(struct hyperv_device *dev)
{
int ret = 0;
@@ -196,7 +195,7 @@ static int vmbus_dev_rm(struct hv_device *dev)
/*
* vmbus_cleanup - Perform any cleanup when the driver is removed
*/
-static void vmbus_cleanup(struct hv_driver *drv)
+static void vmbus_cleanup(struct hyperv_driver *drv)
{
/* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */
@@ -221,7 +220,7 @@ static void vmbus_onmessage_work(struct work_struct *work)
/*
* vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
*/
-static void vmbus_on_msg_dpc(struct hv_driver *drv)
+static void vmbus_on_msg_dpc(struct hyperv_driver *drv)
{
int cpu = smp_processor_id();
void *page_addr = hv_context.synic_message_page[cpu];
@@ -267,7 +266,7 @@ static void vmbus_on_msg_dpc(struct hv_driver *drv)
/*
* vmbus_on_isr - ISR routine
*/
-static int vmbus_on_isr(struct hv_driver *drv)
+static int vmbus_on_isr(struct hyperv_driver *drv)
{
int ret = 0;
int cpu = smp_processor_id();
@@ -299,8 +298,8 @@ static int vmbus_on_isr(struct hv_driver *drv)
return ret;
}
-static void get_channel_info(struct hv_device *device,
- struct hv_device_info *info)
+static void get_channel_info(struct hyperv_device *device,
+ struct hyperv_device_info *info)
{
struct vmbus_channel_debug_info debug_info;
@@ -354,12 +353,12 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
struct device_attribute *dev_attr,
char *buf)
{
- struct vm_device *device_ctx = device_to_vm_device(dev);
- struct hv_device_info device_info;
+ struct hyperv_device *hyperv_dev = device_to_hyperv_device(dev);
+ struct hyperv_device_info device_info;
- memset(&device_info, 0, sizeof(struct hv_device_info));
+ memset(&device_info, 0, sizeof(struct hyperv_device_info));
- get_channel_info(&device_ctx->device_obj, &device_info);
+ get_channel_info(hyperv_dev, &device_info);
if (!strcmp(dev_attr->attr.name, "class_id")) {
return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
@@ -462,9 +461,9 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
*/
static int vmbus_bus_init(void)
{
- struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
- struct hv_driver *driver = &vmbus_drv.drv_obj;
- struct vm_device *dev_ctx = &vmbus_drv.device_ctx;
+ struct vmbus_hyperv_driver *vmb_drv = &g_vmbus_drv;
+ struct hyperv_driver *hv_drv = &g_vmbus_drv.drv;
+ struct hyperv_device *hv_dev = &g_vmbus_drv.hyperv_dev;
int ret;
unsigned int vector;
@@ -479,13 +478,13 @@ static int vmbus_bus_init(void)
sizeof(struct vmbus_channel_packet_page_buffer),
sizeof(struct vmbus_channel_packet_multipage_buffer));
- driver->name = driver_name;
- memcpy(&driver->dev_type, &device_type, sizeof(struct hv_guid));
+ hv_drv->name = driver_name;
+ memcpy(&hv_drv->class_id, &device_type, sizeof(struct hv_guid));
/* Setup dispatch table */
- driver->dev_add = vmbus_dev_add;
- driver->dev_rm = vmbus_dev_rm;
- driver->cleanup = vmbus_cleanup;
+ hv_drv->dev_add = vmbus_dev_add;
+ hv_drv->dev_rm = vmbus_dev_rm;
+ hv_drv->cleanup = vmbus_cleanup;
/* Hypervisor initialization...setup hypercall page..etc */
ret = hv_init();
@@ -495,23 +494,17 @@ static int vmbus_bus_init(void)
goto cleanup;
}
- /* Sanity checks */
- if (!driver->dev_add) {
- DPRINT_ERR(VMBUS_DRV, "OnDeviceAdd() routine not set");
- ret = -1;
- goto cleanup;
- }
- vmbus_drv_ctx->bus.name = driver->name;
+ vmb_drv->bus.name = hv_drv->name;
/* Initialize the bus context */
- tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc,
- (unsigned long)driver);
- tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc,
- (unsigned long)driver);
+ tasklet_init(&vmb_drv->msg_dpc, vmbus_msg_dpc,
+ (unsigned long)hv_drv);
+ tasklet_init(&vmb_drv->event_dpc, vmbus_event_dpc,
+ (unsigned long)hv_drv);
/* Now, register the bus driver with LDM */
- ret = bus_register(&vmbus_drv_ctx->bus);
+ ret = bus_register(&vmb_drv->bus);
if (ret) {
ret = -1;
goto cleanup;
@@ -519,13 +512,13 @@ static int vmbus_bus_init(void)
/* Get the interrupt resource */
ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
- driver->name, NULL);
+ hv_drv->name, NULL);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
vmbus_irq);
- bus_unregister(&vmbus_drv_ctx->bus);
+ bus_unregister(&vmb_drv->bus);
ret = -1;
goto cleanup;
@@ -535,43 +528,38 @@ static int vmbus_bus_init(void)
DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
/* Call to bus driver to add the root device */
- memset(dev_ctx, 0, sizeof(struct vm_device));
+ memset(hv_dev, 0, sizeof(struct hyperv_device));
- ret = driver->dev_add(&dev_ctx->device_obj, &vector);
+ ret = hv_drv->dev_add(hv_dev, &vector);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV,
"ERROR - Unable to add vmbus root device");
free_irq(vmbus_irq, NULL);
- bus_unregister(&vmbus_drv_ctx->bus);
+ bus_unregister(&vmb_drv->bus);
ret = -1;
goto cleanup;
}
- /* 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));
+ dev_set_name(&hv_dev->device, "vmbus_0_0");
/* No need to bind a driver to the root device. */
- dev_ctx->device.parent = NULL;
+ hv_dev->device.parent = NULL;
/* NULL; vmbus_remove() does not get invoked */
- dev_ctx->device.bus = &vmbus_drv_ctx->bus;
+ hv_dev->device.bus = &vmb_drv->bus;
/* Setup the device dispatch table */
- dev_ctx->device.release = vmbus_bus_release;
+ hv_dev->device.release = vmbus_bus_release;
/* Setup the bus as root device */
- ret = device_register(&dev_ctx->device);
+ ret = device_register(&hv_dev->device);
if (ret) {
DPRINT_ERR(VMBUS_DRV,
"ERROR - Unable to register vmbus root device");
free_irq(vmbus_irq, NULL);
- bus_unregister(&vmbus_drv_ctx->bus);
+ bus_unregister(&vmb_drv->bus);
ret = -1;
goto cleanup;
@@ -591,35 +579,35 @@ cleanup:
*/
static void vmbus_bus_exit(void)
{
- struct hv_driver *driver = &vmbus_drv.drv_obj;
- struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
+ struct hyperv_driver *hv_drv = &g_vmbus_drv.drv;
+ struct vmbus_hyperv_driver *vmb_drv = &g_vmbus_drv;
- struct vm_device *dev_ctx = &vmbus_drv.device_ctx;
+ struct hyperv_device *hv_dev = &g_vmbus_drv.hyperv_dev;
/* Remove the root device */
- if (driver->dev_rm)
- driver->dev_rm(&dev_ctx->device_obj);
+ if (hv_drv->dev_rm)
+ hv_drv->dev_rm(hv_dev);
- if (driver->cleanup)
- driver->cleanup(driver);
+ if (hv_drv->cleanup)
+ hv_drv->cleanup(hv_drv);
/* Unregister the root bus device */
- device_unregister(&dev_ctx->device);
+ device_unregister(&hv_dev->device);
- bus_unregister(&vmbus_drv_ctx->bus);
+ bus_unregister(&vmb_drv->bus);
free_irq(vmbus_irq, NULL);
- tasklet_kill(&vmbus_drv_ctx->msg_dpc);
- tasklet_kill(&vmbus_drv_ctx->event_dpc);
+ tasklet_kill(&vmb_drv->msg_dpc);
+ tasklet_kill(&vmb_drv->event_dpc);
}
/**
* 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
+ * @drv is of type &struct hyperv_driver
*
* Registers the given driver with Linux through the 'driver_register()' call
* And sets up the hyper-v vmbus handling for this driver.
@@ -627,17 +615,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 hyperv_driver *drv)
{
int ret;
DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s",
- driver_ctx, driver_ctx->driver.name);
+ drv, drv->driver.name);
/* The child driver on this vmbus */
- driver_ctx->driver.bus = &vmbus_drv.bus;
+ drv->driver.bus = &g_vmbus_drv.bus;
- ret = driver_register(&driver_ctx->driver);
+ ret = driver_register(&drv->driver);
vmbus_request_offers();
@@ -647,23 +635,23 @@ 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
+ * @drv is of type &struct hyperv_driver
*
* 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 hyperv_driver *drv)
{
DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s",
- driver_ctx, driver_ctx->driver.name);
+ drv, drv->driver.name);
- driver_unregister(&driver_ctx->driver);
+ driver_unregister(&drv->driver);
- driver_ctx->driver.bus = NULL;
+ drv->driver.bus = NULL;
}
EXPORT_SYMBOL(vmbus_child_driver_unregister);
@@ -671,16 +659,15 @@ EXPORT_SYMBOL(vmbus_child_driver_unregister);
* vmbus_child_device_create - Creates and registers a new child device
* on the vmbus.
*/
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
+struct hyperv_device *vmbus_child_device_create(struct hv_guid *type,
struct hv_guid *instance,
struct vmbus_channel *channel)
{
- struct vm_device *child_device_ctx;
- struct hv_device *child_device_obj;
+ struct hyperv_device *child_hyperv_dev;
/* Allocate the new child device */
- child_device_ctx = kzalloc(sizeof(struct vm_device), GFP_KERNEL);
- if (!child_device_ctx) {
+ child_hyperv_dev = kzalloc(sizeof(struct hyperv_device), GFP_KERNEL);
+ if (!child_hyperv_dev) {
DPRINT_ERR(VMBUS_DRV,
"unable to allocate device_context for child device");
return NULL;
@@ -691,7 +678,7 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
"%02x%02x%02x%02x%02x%02x%02x%02x},"
"id {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x%02x%02x}",
- &child_device_ctx->device,
+ &child_hyperv_dev->device,
type->data[3], type->data[2], type->data[1], type->data[0],
type->data[5], type->data[4], type->data[7], type->data[6],
type->data[8], type->data[9], type->data[10], type->data[11],
@@ -705,58 +692,50 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
instance->data[12], instance->data[13],
instance->data[14], instance->data[15]);
- child_device_obj = &child_device_ctx->device_obj;
- child_device_obj->channel = channel;
- memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
- memcpy(&child_device_obj->dev_instance, instance,
- sizeof(struct hv_guid));
+ child_hyperv_dev->channel = channel;
- memcpy(&child_device_ctx->class_id, type, sizeof(struct hv_guid));
- memcpy(&child_device_ctx->device_id, instance, sizeof(struct hv_guid));
+ memcpy(&child_hyperv_dev->class_id, type, sizeof(struct hv_guid));
+ memcpy(&child_hyperv_dev->device_id, instance, sizeof(struct hv_guid));
- return child_device_obj;
+ return child_hyperv_dev;
}
/*
* vmbus_child_device_register - Register the child device on the specified bus
*/
-int vmbus_child_device_register(struct hv_device *root_device_obj,
- struct hv_device *child_device_obj)
+int vmbus_child_device_register(struct hyperv_device *root_hyperv_dev,
+ struct hyperv_device *child_hyperv_dev)
{
int ret = 0;
- struct vm_device *root_device_ctx =
- to_vm_device(root_device_obj);
- struct vm_device *child_device_ctx =
- to_vm_device(child_device_obj);
static atomic_t device_num = ATOMIC_INIT(0);
DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
- child_device_ctx);
+ child_hyperv_dev);
/* Set the device name. Otherwise, device_register() will fail. */
- dev_set_name(&child_device_ctx->device, "vmbus_0_%d",
+ dev_set_name(&child_hyperv_dev->device, "vmbus_0_%d",
atomic_inc_return(&device_num));
/* The new device belongs to this bus */
- child_device_ctx->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
- child_device_ctx->device.parent = &root_device_ctx->device;
- child_device_ctx->device.release = vmbus_device_release;
+ child_hyperv_dev->device.bus = &g_vmbus_drv.bus; /* device->dev.bus; */
+ child_hyperv_dev->device.parent = &root_hyperv_dev->device;
+ child_hyperv_dev->device.release = vmbus_device_release;
/*
* Register with the LDM. This will kick off the driver/device
* binding...which will eventually call vmbus_match() and vmbus_probe()
*/
- ret = device_register(&child_device_ctx->device);
+ ret = device_register(&child_hyperv_dev->device);
/* vmbus_probe() error does not get propergate to device_register(). */
- ret = child_device_ctx->probe_error;
+ ret = child_hyperv_dev->probe_error;
if (ret)
DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
- &child_device_ctx->device);
+ &child_hyperv_dev->device);
else
DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
- &child_device_ctx->device);
+ &child_hyperv_dev->device);
return ret;
}
@@ -765,21 +744,20 @@ int vmbus_child_device_register(struct hv_device *root_device_obj,
* vmbus_child_device_unregister - Remove the specified child device
* from the vmbus.
*/
-void vmbus_child_device_unregister(struct hv_device *device_obj)
+void vmbus_child_device_unregister(struct hyperv_device *hyperv_dev)
{
- struct vm_device *device_ctx = to_vm_device(device_obj);
DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
- &device_ctx->device);
+ &hyperv_dev->device);
/*
* Kick off the process of unregistering the device.
* This will call vmbus_remove() and eventually vmbus_device_release()
*/
- device_unregister(&device_ctx->device);
+ device_unregister(&hyperv_dev->device);
DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
- &device_ctx->device);
+ &hyperv_dev->device);
}
/*
@@ -791,43 +769,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 hyperv_device *hyperv_dev = device_to_hyperv_device(device);
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]);
+ hyperv_dev->class_id.data[3], hyperv_dev->class_id.data[2],
+ hyperv_dev->class_id.data[1], hyperv_dev->class_id.data[0],
+ hyperv_dev->class_id.data[5], hyperv_dev->class_id.data[4],
+ hyperv_dev->class_id.data[7], hyperv_dev->class_id.data[6],
+ hyperv_dev->class_id.data[8], hyperv_dev->class_id.data[9],
+ hyperv_dev->class_id.data[10],
+ hyperv_dev->class_id.data[11],
+ hyperv_dev->class_id.data[12],
+ hyperv_dev->class_id.data[13],
+ hyperv_dev->class_id.data[14],
+ hyperv_dev->class_id.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]);
+ hyperv_dev->class_id.data[3],
+ hyperv_dev->class_id.data[2],
+ hyperv_dev->class_id.data[1],
+ hyperv_dev->class_id.data[0],
+ hyperv_dev->class_id.data[5],
+ hyperv_dev->class_id.data[4],
+ hyperv_dev->class_id.data[7],
+ hyperv_dev->class_id.data[6],
+ hyperv_dev->class_id.data[8],
+ hyperv_dev->class_id.data[9],
+ hyperv_dev->class_id.data[10],
+ hyperv_dev->class_id.data[11],
+ hyperv_dev->class_id.data[12],
+ hyperv_dev->class_id.data[13],
+ hyperv_dev->class_id.data[14],
+ hyperv_dev->class_id.data[15]);
if (ret)
return ret;
@@ -835,22 +813,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]);
+ hyperv_dev->device_id.data[3],
+ hyperv_dev->device_id.data[2],
+ hyperv_dev->device_id.data[1],
+ hyperv_dev->device_id.data[0],
+ hyperv_dev->device_id.data[5],
+ hyperv_dev->device_id.data[4],
+ hyperv_dev->device_id.data[7],
+ hyperv_dev->device_id.data[6],
+ hyperv_dev->device_id.data[8],
+ hyperv_dev->device_id.data[9],
+ hyperv_dev->device_id.data[10],
+ hyperv_dev->device_id.data[11],
+ hyperv_dev->device_id.data[12],
+ hyperv_dev->device_id.data[13],
+ hyperv_dev->device_id.data[14],
+ hyperv_dev->device_id.data[15]);
if (ret)
return ret;
@@ -863,24 +841,24 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
static int vmbus_match(struct device *device, struct device_driver *driver)
{
int match = 0;
- struct driver_context *driver_ctx = driver_to_driver_context(driver);
- struct vm_device *device_ctx = device_to_vm_device(device);
+ struct hyperv_driver *drv = driver_to_hyperv_driver(driver);
+ struct hyperv_device *hyperv_dev = device_to_hyperv_device(device);
/* We found our driver ? */
- if (memcmp(&device_ctx->class_id, &driver_ctx->class_id,
+ if (memcmp(&hyperv_dev->class_id, &drv->class_id,
sizeof(struct hv_guid)) == 0) {
/*
- * !! NOTE: The driver_ctx is not a vmbus_drv_ctx. We typecast
- * it here to access the struct hv_driver field
+ * !! NOTE: The drv is not a vmbus_drv. We typecast
+ * it here to access the struct hyperv_driver field
*/
- struct vmbus_driver_context *vmbus_drv_ctx =
- (struct vmbus_driver_context *)driver_ctx;
+ struct vmbus_hyperv_driver *vmbus_drv =
+ (struct vmbus_hyperv_driver *)drv;
- device_ctx->device_obj.drv = &vmbus_drv_ctx->drv_obj;
+ hyperv_dev->drv = &vmbus_drv->drv;
DPRINT_INFO(VMBUS_DRV,
"device object (%p) set to driver object (%p)",
- &device_ctx->device_obj,
- device_ctx->device_obj.drv);
+ hyperv_dev,
+ hyperv_dev->drv);
match = 1;
}
@@ -896,15 +874,15 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
*/
static void vmbus_probe_failed_cb(struct work_struct *context)
{
- struct vm_device *device_ctx = (struct vm_device *)context;
+ struct hyperv_device *hyperv_dev = (struct hyperv_device *)context;
/*
* Kick off the process of unregistering the device.
* This will call vmbus_remove() and eventually vmbus_device_release()
*/
- device_unregister(&device_ctx->device);
+ device_unregister(&hyperv_dev->device);
- /* put_device(&device_ctx->device); */
+ /* put_device(&hyperv_dev->device); */
}
/*
@@ -913,23 +891,23 @@ static void vmbus_probe_failed_cb(struct work_struct *context)
static int vmbus_probe(struct device *child_device)
{
int ret = 0;
- struct driver_context *driver_ctx =
- driver_to_driver_context(child_device->driver);
- struct vm_device *device_ctx =
- device_to_vm_device(child_device);
+ struct hyperv_driver *drv =
+ driver_to_hyperv_driver(child_device->driver);
+ struct hyperv_device *hyperv_dev =
+ device_to_hyperv_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 (drv->probe) {
+ ret = hyperv_dev->probe_error = drv->probe(child_device);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
"(%p) on driver %s (%d)...",
dev_name(child_device), child_device,
child_device->driver->name, ret);
- INIT_WORK(&device_ctx->probe_failed_work_item,
+ INIT_WORK(&hyperv_dev->probe_failed_work_item,
vmbus_probe_failed_cb);
- schedule_work(&device_ctx->probe_failed_work_item);
+ schedule_work(&hyperv_dev->probe_failed_work_item);
}
} else {
DPRINT_ERR(VMBUS_DRV, "probe() method not set for driver - %s",
@@ -945,7 +923,7 @@ static int vmbus_probe(struct device *child_device)
static int vmbus_remove(struct device *child_device)
{
int ret;
- struct driver_context *driver_ctx;
+ struct hyperv_driver *drv;
/* Special case root bus device */
if (child_device->parent == NULL) {
@@ -957,14 +935,14 @@ static int vmbus_remove(struct device *child_device)
}
if (child_device->driver) {
- driver_ctx = driver_to_driver_context(child_device->driver);
+ drv = driver_to_hyperv_driver(child_device->driver);
/*
* Let the specific open-source driver handles the removal if
* it can
*/
- if (driver_ctx->remove) {
- ret = driver_ctx->remove(child_device);
+ if (drv->remove) {
+ ret = drv->remove(child_device);
} else {
DPRINT_ERR(VMBUS_DRV,
"remove() method not set for driver - %s",
@@ -981,7 +959,7 @@ static int vmbus_remove(struct device *child_device)
*/
static void vmbus_shutdown(struct device *child_device)
{
- struct driver_context *driver_ctx;
+ struct hyperv_driver *drv;
/* Special case root bus device */
if (child_device->parent == NULL) {
@@ -996,11 +974,11 @@ static void vmbus_shutdown(struct device *child_device)
if (!child_device->driver)
return;
- driver_ctx = driver_to_driver_context(child_device->driver);
+ drv = driver_to_hyperv_driver(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 (drv->shutdown)
+ drv->shutdown(child_device);
return;
}
@@ -1022,11 +1000,11 @@ static void vmbus_bus_release(struct device *device)
*/
static void vmbus_device_release(struct device *device)
{
- struct vm_device *device_ctx = device_to_vm_device(device);
+ struct hyperv_device *hyperv_dev = device_to_hyperv_device(device);
- kfree(device_ctx);
+ kfree(hyperv_dev);
- /* !!DO NOT REFERENCE device_ctx anymore at this point!! */
+ /* !!DO NOT REFERENCE hyperv_dev anymore at this point!! */
}
/*
@@ -1034,7 +1012,7 @@ static void vmbus_device_release(struct device *device)
*/
static void vmbus_msg_dpc(unsigned long data)
{
- struct hv_driver *driver = (struct hv_driver *)data;
+ struct hyperv_driver *driver = (struct hyperv_driver *)data;
/* Call to bus driver to handle interrupt */
vmbus_on_msg_dpc(driver);
@@ -1051,7 +1029,7 @@ static void vmbus_event_dpc(unsigned long data)
static irqreturn_t vmbus_isr(int irq, void *dev_id)
{
- struct hv_driver *driver = &vmbus_drv.drv_obj;
+ struct hyperv_driver *driver = &g_vmbus_drv.drv;
int ret;
/* Call to bus driver to handle interrupt */
@@ -1060,10 +1038,10 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id)
/* Schedules a dpc if necessary */
if (ret > 0) {
if (test_bit(0, (unsigned long *)&ret))
- tasklet_schedule(&vmbus_drv.msg_dpc);
+ tasklet_schedule(&g_vmbus_drv.msg_dpc);
if (test_bit(1, (unsigned long *)&ret))
- tasklet_schedule(&vmbus_drv.event_dpc);
+ tasklet_schedule(&g_vmbus_drv.event_dpc);
return IRQ_HANDLED;
} else {
diff --git a/drivers/staging/hv/vmbus_private.h b/drivers/staging/hv/vmbus_private.h
index 9f505c4..b272cc9 100644
--- a/drivers/staging/hv/vmbus_private.h
+++ b/drivers/staging/hv/vmbus_private.h
@@ -103,18 +103,15 @@ extern struct vmbus_connection vmbus_connection;
/* General vmbus interface */
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
+struct hyperv_device *vmbus_child_device_create(struct hv_guid *type,
struct hv_guid *instance,
struct vmbus_channel *channel);
-int vmbus_child_dev_add(struct hv_device *device);
-int vmbus_child_device_register(struct hv_device *root_device_obj,
- struct hv_device *child_device_obj);
-void vmbus_child_device_unregister(struct hv_device *device_obj);
+int vmbus_child_dev_add(struct hyperv_device *device);
+int vmbus_child_device_register(struct hyperv_device *root_device_obj,
+ struct hyperv_device *child_device_obj);
+void vmbus_child_device_unregister(struct hyperv_device *device_obj);
-/* static void */
-/* VmbusChildDeviceDestroy( */
-/* struct hv_device *); */
struct vmbus_channel *relid2channel(u32 relid);
--
1.5.5.6
^ permalink raw reply related
* Re: [PATCH ] Staging: hv: Hyper-V driver cleanup
From: Greg KH @ 2011-02-24 23:45 UTC (permalink / raw)
To: K. Y. Srinivasan
Cc: linux-kernel, devel, virtualization, Haiyang Zhang, Hank Janssen
In-Reply-To: <1298589658-23126-1-git-send-email-kys@microsoft.com>
On Thu, Feb 24, 2011 at 03:20:58PM -0800, K. Y. Srinivasan wrote:
> This patch cleans up (a lot of the) naming issues that
> various reviewers have noted. It also gets rid of
> some unnecessary layering in the code.
Whenever you have a patch description that says "It also..." you know
you need to break this up into smaller, logical pieces.
As it is, I can not take this patch.
Please break it up into logical patches, each doing only one thing, so
we can properly review it.
> At the lowest
> level, we have one abstraction for representing
> a hyperv device (struct hyperv_device) and one
> abstraction for representing a hyperv driver
> (struct hyperv_driver). This collapses an unnecessary
> layering that existed in the code for historical reasons.
> While the patch is large, it was generated by a very
> mechanical process (global search and replace). The code
> compiles cleanly and I have tested this code on a 2.6.38
> kernel.
There is no 2.6.38 kernel yet, so I find this very hard to believe :)
thanks,
greg k-h
^ permalink raw reply
* RE: [PATCH ] Staging: hv: Hyper-V driver cleanup
From: KY Srinivasan @ 2011-02-25 0:24 UTC (permalink / raw)
To: Greg KH
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org, Haiyang Zhang, Hank Janssen
In-Reply-To: <20110224234541.GA23711@suse.de>
> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Thursday, February 24, 2011 6:46 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org; Haiyang Zhang; Hank Janssen
> Subject: Re: [PATCH ] Staging: hv: Hyper-V driver cleanup
>
> On Thu, Feb 24, 2011 at 03:20:58PM -0800, K. Y. Srinivasan wrote:
> > This patch cleans up (a lot of the) naming issues that
> > various reviewers have noted. It also gets rid of
> > some unnecessary layering in the code.
>
> Whenever you have a patch description that says "It also..." you know
> you need to break this up into smaller, logical pieces.
The name change was related to the layering issue. For instance I combined the
Vm_device and hv_device abstractions to build the hyperv_device abstraction.
Likewise, I combined the driver_context and the hv_driver abstractions to build the
the hyperv_driver abstraction. Would breaking this patch up into two patches,
one dealing with the device abstraction consolidation and the other dealing with
the consolidation of driver abstractions satisfy your concern. Even if I partition this
patch along these lines, it will still be a large set of patches; since these changes
are pervasive.
>
> As it is, I can not take this patch.
>
> Please break it up into logical patches, each doing only one thing, so
> we can properly review it.
>
> > At the lowest
> > level, we have one abstraction for representing
> > a hyperv device (struct hyperv_device) and one
> > abstraction for representing a hyperv driver
> > (struct hyperv_driver). This collapses an unnecessary
> > layering that existed in the code for historical reasons.
> > While the patch is large, it was generated by a very
> > mechanical process (global search and replace). The code
> > compiles cleanly and I have tested this code on a 2.6.38
> > kernel.
>
> There is no 2.6.38 kernel yet, so I find this very hard to believe :)
My mistake; I did not specify the full output of uname -a on the box
that I tested this code. This box is running the LINUX-NEXT kernel :
2.6.38-rc1-0.2-default.
Regards,
K. Y
>
> thanks,
>
> greg k-h
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox