Linux virtualization list
 help / color / mirror / Atom feed
* Re: [PATCH 0000/0020] Staging: hv: Driver cleanup
From: Greg KH @ 2011-09-16 18:07 UTC (permalink / raw)
  To: K. Y. Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1315936759-20623-1-git-send-email-kys@microsoft.com>

On Tue, Sep 13, 2011 at 10:59:19AM -0700, K. Y. Srinivasan wrote:
> Address Greg's VmBus audit comments:
> 
> 	1) Leverage driver_data field in struct hv_vmbus_device_id to
> 	   simplify driver code.
> 
> 	2) Make the util driver conform to the Linux Driver Model.
> 
> 	3) Get rid of the ext field in struct hv_device by using the
> 	   driver specific data functionality.
> 
> 	4) Implement vmbus specific wrapper functions for setting and getting
> 	   driver specific data..
> 
> 	5) Other general cleanup.

I applied 17 of these (i.e. the ones I didn't comment on.)

greg k-h

^ permalink raw reply

* Re: [PATCH 06/20] Staging: hv: util: Properly handle util services in the util driver
From: Greg KH @ 2011-09-16 18:03 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1315936796-20662-6-git-send-email-kys@microsoft.com>

On Tue, Sep 13, 2011 at 10:59:42AM -0700, K. Y. Srinivasan wrote:
>  static int __init init_hyperv_utils(void)
>  {
> -	int ret;
>  	pr_info("Registering HyperV Utility Driver\n");

All of these "registering" and "unregistering" messages should be
removed, they do nothing but clutter up the logs and are pointless.  You
can find this information out any time you want by looking in sysfs
instead of trying to parse random strings out of the kernel log.

greg k-h

^ permalink raw reply

* Re: [PATCH 05/20] Staging: hv: util: Perform some service specific init/deinit in probe/remove
From: Greg KH @ 2011-09-16 18:01 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1315936796-20662-5-git-send-email-kys@microsoft.com>

On Tue, Sep 13, 2011 at 10:59:41AM -0700, K. Y. Srinivasan wrote:
> --- a/drivers/staging/hv/hv_util.c
> +++ b/drivers/staging/hv/hv_util.c
> @@ -30,9 +30,31 @@
>  #include "hyperv.h"
>  #include "hv_kvp.h"
>  
> -static u8 *shut_txf_buf;
> -static u8 *time_txf_buf;
> -static u8 *hbeat_txf_buf;
> +
> +static void shutdown_onchannelcallback(void *context);
> +static struct hv_util_service util_shutdown = {
> +	.service_name = "Shutdown channel functionality initialized\n",

That's not a name, it's a text string to send to userspace, and it's
really redundant given the other times you use this.

Please just put the name here, if you really need it (hint, you really
don't, so just drop it please.)

greg k-h

^ permalink raw reply

* RE: [PATCH 06/20] Staging: hv: util: Properly handle util services in the util driver
From: KY Srinivasan @ 2011-09-15 20:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <20110915200853.GJ3789@shale.localdomain>



> -----Original Message-----
> From: Dan Carpenter [mailto:error27@gmail.com]
> Sent: Thursday, September 15, 2011 4:09 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 06/20] Staging: hv: util: Properly handle util services in the
> util driver
> 
> On Tue, Sep 13, 2011 at 10:59:42AM -0700, K. Y. Srinivasan wrote:
> > @@ -403,31 +384,13 @@ static void vmbus_process_offer(struct work_struct
> *work)
> >  		spin_unlock_irqrestore(&vmbus_connection.channel_lock,
> flags);
> >
> >  		free_channel(newchannel);
> > -	} else {
> > +	} else
> >  		/*
> >  		 * This state is used to indicate a successful open
> >  		 * so that when we do close the channel normally, we
> >  		 * can cleanup properly
> >  		 */
> >  		newchannel->state = CHANNEL_OPEN_STATE;
> 
> It's not worth resending, but this should have kept the curly braces
> for two style reasons.
> 1) If one side of the if else pair has braces the other side gets
> braces too.
> 2) If it's more than one line, it gets braces even if it's not needed
> for semantic reasons.
> 
> Sorry to email you these pedantic things, but if I don't then my OCD
> acts up and I feel all itchy for hours.  Also you have a similar
> thing below as well.

Thanks Dan. I will wait for Greg's action here. Given that Kernel.org is still
down, we are all kind of flying in the dark here.

Regards,

K. Y

^ permalink raw reply

* Re: [PATCH 06/20] Staging: hv: util: Properly handle util services in the util driver
From: Dan Carpenter @ 2011-09-15 20:08 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization
In-Reply-To: <1315936796-20662-6-git-send-email-kys@microsoft.com>

On Tue, Sep 13, 2011 at 10:59:42AM -0700, K. Y. Srinivasan wrote:
> @@ -403,31 +384,13 @@ static void vmbus_process_offer(struct work_struct *work)
>  		spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
>  
>  		free_channel(newchannel);
> -	} else {
> +	} else
>  		/*
>  		 * This state is used to indicate a successful open
>  		 * so that when we do close the channel normally, we
>  		 * can cleanup properly
>  		 */
>  		newchannel->state = CHANNEL_OPEN_STATE;

It's not worth resending, but this should have kept the curly braces
for two style reasons.
1) If one side of the if else pair has braces the other side gets
braces too.
2) If it's more than one line, it gets braces even if it's not needed
for semantic reasons.

Sorry to email you these pedantic things, but if I don't then my OCD 
acts up and I feel all itchy for hours.  Also you have a similar
thing below as well.

regards,
dan carpenter

^ permalink raw reply

* [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
From: K. Y. Srinivasan @ 2011-09-13 22:21 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, joe
  Cc: K. Y. Srinivasan, Haiyang Zhang

Consistently name the variable tracking the link status. Use a consistent
type for this variable and get rid of some unnecessary parentheses as well.
I would like to thank Joe Perches <joe@perches.com> for suggesting these
changes and patiently helping me get here!

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 963582a..ef43f2e 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -41,7 +41,7 @@ struct rndis_device {
 	struct netvsc_device *net_dev;
 
 	enum rndis_device_state state;
-	u32 link_stat;
+	bool link_state;
 	atomic_t new_req_id;
 
 	spinlock_t request_lock;
@@ -511,10 +511,15 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev)
 static int rndis_filter_query_device_link_status(struct rndis_device *dev)
 {
 	u32 size = sizeof(u32);
+	u32 link_status;
+	int ret;
 
-	return rndis_filter_query_device(dev,
+	ret = rndis_filter_query_device(dev,
 				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
-				      &dev->link_stat, &size);
+				      &link_status, &size);
+	dev->link_state = (link_status != 0) ? true : false;
+
+	return ret;
 }
 
 static int rndis_filter_set_packet_filter(struct rndis_device *dev,
@@ -736,11 +741,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndis_filter_query_device_link_status(rndis_device);
 
-	device_info->link_state = rndis_device->link_stat;
+	device_info->link_state = rndis_device->link_state;
 
-	dev_info(&dev->device, "Device MAC %pM link state %s",
+	dev_info(&dev->device, "Device MAC %pM link state %s\n",
 		 rndis_device->hw_mac_adr,
-		 ((device_info->link_state) ? ("down\n") : ("up\n")));
+		 device_info->link_state ? "down" : "up");
 
 	return ret;
 }
-- 
1.7.4.1

^ permalink raw reply related

* RE: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
From: KY Srinivasan @ 2011-09-13 20:57 UTC (permalink / raw)
  To: Joe Perches
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <1315944283.25776.14.camel@Joe-Laptop>



> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Tuesday, September 13, 2011 4:05 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of
> link_stat variable
> 
> On Tue, 2011-09-13 at 12:53 -0700, K. Y. Srinivasan wrote:
> > Consistently name the variable tracking the link status. Use a consistent
> > type for this variable and get rid of some unnecessary parentheses as well.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/rndis_filter.c |    8 ++++----
> >  1 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
> > index 963582a..696d2c5 100644
> > --- a/drivers/staging/hv/rndis_filter.c
> > +++ b/drivers/staging/hv/rndis_filter.c
> > @@ -41,7 +41,7 @@ struct rndis_device {
> >  	struct netvsc_device *net_dev;
> >
> >  	enum rndis_device_state state;
> > -	u32 link_stat;
> > +	bool link_state;
> >  	atomic_t new_req_id;
> >
> >  	spinlock_t request_lock;
> > @@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct
> rndis_device *dev)
> >
> >  	return rndis_filter_query_device(dev,
> >  				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
> > -				      &dev->link_stat, &size);
> > +				      &dev->link_state, &size);
> 
> Are you sure you can do this?
> You're changing the info request from u32 to bool
> without changing the size above it

Oops! I will fix this.

> 
> 	u32 size = sizeof(u32);
> 
> 
> >  }
> >
> >  static int rndis_filter_set_packet_filter(struct rndis_device *dev,
> > @@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
> >
> >  	rndis_filter_query_device_link_status(rndis_device);
> >
> > -	device_info->link_state = rndis_device->link_stat;
> > +	device_info->link_state = rndis_device->link_state;
> >
> >  	dev_info(&dev->device, "Device MAC %pM link state %s",
> >  		 rndis_device->hw_mac_adr,
> > -		 ((device_info->link_state) ? ("down\n") : ("up\n")));
> > +		 device_info->link_state ? "down\n" : "up\n");
> 
> It's better to remove the multiple "\n"s from "up" and "down"
> and move it to the format string as I suggested.

I will fix it.

Thank you,

K. Y


^ permalink raw reply

* Re: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
From: Joe Perches @ 2011-09-13 20:04 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1315943618-22308-1-git-send-email-kys@microsoft.com>

On Tue, 2011-09-13 at 12:53 -0700, K. Y. Srinivasan wrote:
> Consistently name the variable tracking the link status. Use a consistent
> type for this variable and get rid of some unnecessary parentheses as well.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/rndis_filter.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
> index 963582a..696d2c5 100644
> --- a/drivers/staging/hv/rndis_filter.c
> +++ b/drivers/staging/hv/rndis_filter.c
> @@ -41,7 +41,7 @@ struct rndis_device {
>  	struct netvsc_device *net_dev;
>  
>  	enum rndis_device_state state;
> -	u32 link_stat;
> +	bool link_state;
>  	atomic_t new_req_id;
>  
>  	spinlock_t request_lock;
> @@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct rndis_device *dev)
>  
>  	return rndis_filter_query_device(dev,
>  				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
> -				      &dev->link_stat, &size);
> +				      &dev->link_state, &size);

Are you sure you can do this?
You're changing the info request from u32 to bool
without changing the size above it

	u32 size = sizeof(u32);


>  }
>  
>  static int rndis_filter_set_packet_filter(struct rndis_device *dev,
> @@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
>  
>  	rndis_filter_query_device_link_status(rndis_device);
>  
> -	device_info->link_state = rndis_device->link_stat;
> +	device_info->link_state = rndis_device->link_state;
>  
>  	dev_info(&dev->device, "Device MAC %pM link state %s",
>  		 rndis_device->hw_mac_adr,
> -		 ((device_info->link_state) ? ("down\n") : ("up\n")));
> +		 device_info->link_state ? "down\n" : "up\n");

It's better to remove the multiple "\n"s from "up" and "down"
and move it to the format string as I suggested.

^ permalink raw reply

* [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
From: K. Y. Srinivasan @ 2011-09-13 19:53 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang

Consistently name the variable tracking the link status. Use a consistent
type for this variable and get rid of some unnecessary parentheses as well.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 963582a..696d2c5 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -41,7 +41,7 @@ struct rndis_device {
 	struct netvsc_device *net_dev;
 
 	enum rndis_device_state state;
-	u32 link_stat;
+	bool link_state;
 	atomic_t new_req_id;
 
 	spinlock_t request_lock;
@@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct rndis_device *dev)
 
 	return rndis_filter_query_device(dev,
 				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
-				      &dev->link_stat, &size);
+				      &dev->link_state, &size);
 }
 
 static int rndis_filter_set_packet_filter(struct rndis_device *dev,
@@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndis_filter_query_device_link_status(rndis_device);
 
-	device_info->link_state = rndis_device->link_stat;
+	device_info->link_state = rndis_device->link_state;
 
 	dev_info(&dev->device, "Device MAC %pM link state %s",
 		 rndis_device->hw_mac_adr,
-		 ((device_info->link_state) ? ("down\n") : ("up\n")));
+		 device_info->link_state ? "down\n" : "up\n");
 
 	return ret;
 }
-- 
1.7.4.1

^ permalink raw reply related

* RE: [PATCH 09/20] Staging: hv: storvsc: Get rid of storvsc_dev_add() by inlining the code
From: KY Srinivasan @ 2011-09-13 18:52 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <20110913183941.GA23318@infradead.org>



> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@infradead.org]
> Sent: Tuesday, September 13, 2011 2:40 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 09/20] Staging: hv: storvsc: Get rid of storvsc_dev_add() by
> inlining the code
> 
> On Tue, Sep 13, 2011 at 10:59:45AM -0700, K. Y. Srinivasan wrote:
> > Get rid of storvsc_dev_add() by inlining the code.
> 
> This also means struct storvsc_device_info can go away, doesn't it?
> 
Yes;  PATCH 11/20 gets rid of struct storvsc_device_info definition and other unneeded state.

Regards,

K. Y

^ permalink raw reply

* Re: [PATCH 16/20] Staging: hv: vmbus: Do not allocate struct hv_device_info on the stack
From: Christoph Hellwig @ 2011-09-13 18:41 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization
In-Reply-To: <1315936796-20662-16-git-send-email-kys@microsoft.com>

On Tue, Sep 13, 2011 at 10:59:52AM -0700, K. Y. Srinivasan wrote:
> struct hv_device_info is about 101 bytes in size. Do not allocate this structure
> on the stack.

The correct fix is to kill that structure entirely but implementing
each attribute separately.

^ permalink raw reply

* Re: [PATCH 09/20] Staging: hv: storvsc: Get rid of storvsc_dev_add() by inlining the code
From: Christoph Hellwig @ 2011-09-13 18:39 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1315936796-20662-9-git-send-email-kys@microsoft.com>

On Tue, Sep 13, 2011 at 10:59:45AM -0700, K. Y. Srinivasan wrote:
> Get rid of storvsc_dev_add() by inlining the code.

This also means struct storvsc_device_info can go away, doesn't it?

^ permalink raw reply

* RE: [PATCH 20/20] Staging: hv: netvsc: Rename deviceInfo as device_info
From: KY Srinivasan @ 2011-09-13 18:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <1315937432.25776.9.camel@Joe-Laptop>



> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Tuesday, September 13, 2011 2:11 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 20/20] Staging: hv: netvsc: Rename deviceInfo as
> device_info
> 
> On Tue, 2011-09-13 at 10:59 -0700, K. Y. Srinivasan wrote:
> > Rename deviceInfo as device_info.
> []
> > diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
> []
> > @@ -732,15 +732,15 @@ int rndis_filter_device_add(struct hv_device *dev,
> []
> >  	dev_info(&dev->device, "Device MAC %pM link state %s",
> >  		 rndis_device->hw_mac_adr,
> > -		 ((deviceInfo->link_state) ? ("down\n") : ("up\n")));
> > +		 ((device_info->link_state) ? ("down\n") : ("up\n")));
> 
> Maybe get rid of the superfluous parentheses too?
> 
> 	dev_info(&dev->device, "Device MAC %pM link state %s\n",
> 		 rndis_device->hw_mac_adr,
> 		 device_info->link_state ? "down" : "up");
> 
> Also, struct rndis_device uses
> 	u32 link_stat;
> that is copied into struct netvsc_device_info
> 	bool link_state;
> could you please rationalize the names and types
> of those 2 variables?

Thanks Joe; I will get a patch out soon.

Regards,

K. Y


^ permalink raw reply

* Re: [PATCH 20/20] Staging: hv: netvsc: Rename deviceInfo as device_info
From: Joe Perches @ 2011-09-13 18:10 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1315936796-20662-20-git-send-email-kys@microsoft.com>

On Tue, 2011-09-13 at 10:59 -0700, K. Y. Srinivasan wrote:
> Rename deviceInfo as device_info.
[]
> diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
[]
> @@ -732,15 +732,15 @@ int rndis_filter_device_add(struct hv_device *dev,
[]
>  	dev_info(&dev->device, "Device MAC %pM link state %s",
>  		 rndis_device->hw_mac_adr,
> -		 ((deviceInfo->link_state) ? ("down\n") : ("up\n")));
> +		 ((device_info->link_state) ? ("down\n") : ("up\n")));

Maybe get rid of the superfluous parentheses too?

	dev_info(&dev->device, "Device MAC %pM link state %s\n",
		 rndis_device->hw_mac_adr,
		 device_info->link_state ? "down" : "up");

Also, struct rndis_device uses
	u32 link_stat;
that is copied into struct netvsc_device_info
	bool link_state;
could you please rationalize the names and types
of those 2 variables?

^ permalink raw reply

* [PATCH 20/20] Staging: hv: netvsc: Rename deviceInfo as device_info
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Rename deviceInfo as device_info.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index bfe9129..963582a 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -691,7 +691,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 	int ret;
 	struct netvsc_device *net_device;
 	struct rndis_device *rndis_device;
-	struct netvsc_device_info *deviceInfo = additional_info;
+	struct netvsc_device_info *device_info = additional_info;
 
 	rndis_device = get_rndis_device();
 	if (!rndis_device)
@@ -732,15 +732,15 @@ int rndis_filter_device_add(struct hv_device *dev,
 		 */
 	}
 
-	memcpy(deviceInfo->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN);
+	memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN);
 
 	rndis_filter_query_device_link_status(rndis_device);
 
-	deviceInfo->link_state = rndis_device->link_stat;
+	device_info->link_state = rndis_device->link_stat;
 
 	dev_info(&dev->device, "Device MAC %pM link state %s",
 		 rndis_device->hw_mac_adr,
-		 ((deviceInfo->link_state) ? ("down\n") : ("up\n")));
+		 ((device_info->link_state) ? ("down\n") : ("up\n")));
 
 	return ret;
 }
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 19/20] Staging: hv: netvsc: Rename rndisDevice to rndis_device
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Rename rndisDevice to rndis_device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index efa7df5..bfe9129 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -690,11 +690,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 {
 	int ret;
 	struct netvsc_device *net_device;
-	struct rndis_device *rndisDevice;
+	struct rndis_device *rndis_device;
 	struct netvsc_device_info *deviceInfo = additional_info;
 
-	rndisDevice = get_rndis_device();
-	if (!rndisDevice)
+	rndis_device = get_rndis_device();
+	if (!rndis_device)
 		return -ENODEV;
 
 	/*
@@ -704,7 +704,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 	 */
 	ret = netvsc_device_add(dev, additional_info);
 	if (ret != 0) {
-		kfree(rndisDevice);
+		kfree(rndis_device);
 		return ret;
 	}
 
@@ -712,11 +712,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 	/* Initialize the rndis device */
 	net_device = hv_get_drvdata(dev);
 
-	net_device->extension = rndisDevice;
-	rndisDevice->net_dev = net_device;
+	net_device->extension = rndis_device;
+	rndis_device->net_dev = net_device;
 
 	/* Send the rndis initialization message */
-	ret = rndis_filter_init_device(rndisDevice);
+	ret = rndis_filter_init_device(rndis_device);
 	if (ret != 0) {
 		/*
 		 * TODO: If rndis init failed, we will need to shut down the
@@ -725,21 +725,21 @@ int rndis_filter_device_add(struct hv_device *dev,
 	}
 
 	/* Get the mac address */
-	ret = rndis_filter_query_device_mac(rndisDevice);
+	ret = rndis_filter_query_device_mac(rndis_device);
 	if (ret != 0) {
 		/*
 		 * TODO: shutdown rndis device and the channel
 		 */
 	}
 
-	memcpy(deviceInfo->mac_adr, rndisDevice->hw_mac_adr, ETH_ALEN);
+	memcpy(deviceInfo->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN);
 
-	rndis_filter_query_device_link_status(rndisDevice);
+	rndis_filter_query_device_link_status(rndis_device);
 
-	deviceInfo->link_state = rndisDevice->link_stat;
+	deviceInfo->link_state = rndis_device->link_stat;
 
 	dev_info(&dev->device, "Device MAC %pM link state %s",
-		 rndisDevice->hw_mac_adr,
+		 rndis_device->hw_mac_adr,
 		 ((deviceInfo->link_state) ? ("down\n") : ("up\n")));
 
 	return ret;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 18/20] Staging: hv: netvsc: Rename netDevice as net_device
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Rename netDevice as net_device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c       |    5 ++++-
 drivers/staging/hv/rndis_filter.c |   14 +++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 2bcc8b2..b902579 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -382,7 +382,10 @@ int netvsc_device_remove(struct hv_device *device)
 	hv_set_drvdata(device, NULL);
 	spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
 
-	/* At this point, no one should be accessing netDevice except in here */
+	/*
+	 * At this point, no one should be accessing net_device
+	 * except in here
+	 */
 	dev_notice(&device->device, "net device safe to remove\n");
 
 	/* Now, we can close the channel safely */
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index b354b0b..efa7df5 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -689,7 +689,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 				  void *additional_info)
 {
 	int ret;
-	struct netvsc_device *netDevice;
+	struct netvsc_device *net_device;
 	struct rndis_device *rndisDevice;
 	struct netvsc_device_info *deviceInfo = additional_info;
 
@@ -710,10 +710,10 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 
 	/* Initialize the rndis device */
-	netDevice = hv_get_drvdata(dev);
+	net_device = hv_get_drvdata(dev);
 
-	netDevice->extension = rndisDevice;
-	rndisDevice->net_dev = netDevice;
+	net_device->extension = rndisDevice;
+	rndisDevice->net_dev = net_device;
 
 	/* Send the rndis initialization message */
 	ret = rndis_filter_init_device(rndisDevice);
@@ -762,12 +762,12 @@ void rndis_filter_device_remove(struct hv_device *dev)
 
 int rndis_filter_open(struct hv_device *dev)
 {
-	struct netvsc_device *netDevice = hv_get_drvdata(dev);
+	struct netvsc_device *net_device = hv_get_drvdata(dev);
 
-	if (!netDevice)
+	if (!net_device)
 		return -EINVAL;
 
-	return rndis_filter_open_device(netDevice->extension);
+	return rndis_filter_open_device(net_device->extension);
 }
 
 int rndis_filter_close(struct hv_device *dev)
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 17/20] Staging: hv: vmbus: Get rid of the module dependency
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Hyper-V modules can be built as part of the kernel (not just as modules).
Get rid of the module dependency in Kconfig.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/Kconfig b/drivers/staging/hv/Kconfig
index 26b5064..815f8c2 100644
--- a/drivers/staging/hv/Kconfig
+++ b/drivers/staging/hv/Kconfig
@@ -1,6 +1,6 @@
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && PCI && m
+	depends on X86 && ACPI && PCI
 	default n
 	help
 	  Select this option to run Linux as a Hyper-V client operating
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 16/20] Staging: hv: vmbus: Do not allocate struct hv_device_info on the stack
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

struct hv_device_info is about 101 bytes in size. Do not allocate this structure
on the stack.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/vmbus_drv.c |  134 ++++++++++++++++++++-------------------
 1 files changed, 69 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 466425a..d2562af 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -112,101 +112,105 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
 				      char *buf)
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
-	struct hv_device_info device_info;
+	struct hv_device_info *device_info;
 	char alias_name[VMBUS_ALIAS_LEN + 1];
+	int ret = 0;
 
-	memset(&device_info, 0, sizeof(struct hv_device_info));
+	device_info = kzalloc(sizeof(struct hv_device_info), GFP_KERNEL);
+	if (!device_info)
+		return ret;
 
-	get_channel_info(hv_dev, &device_info);
+	get_channel_info(hv_dev, device_info);
 
 	if (!strcmp(dev_attr->attr.name, "class_id")) {
-		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
+		ret = sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_type.b[3],
-			       device_info.chn_type.b[2],
-			       device_info.chn_type.b[1],
-			       device_info.chn_type.b[0],
-			       device_info.chn_type.b[5],
-			       device_info.chn_type.b[4],
-			       device_info.chn_type.b[7],
-			       device_info.chn_type.b[6],
-			       device_info.chn_type.b[8],
-			       device_info.chn_type.b[9],
-			       device_info.chn_type.b[10],
-			       device_info.chn_type.b[11],
-			       device_info.chn_type.b[12],
-			       device_info.chn_type.b[13],
-			       device_info.chn_type.b[14],
-			       device_info.chn_type.b[15]);
+			       device_info->chn_type.b[3],
+			       device_info->chn_type.b[2],
+			       device_info->chn_type.b[1],
+			       device_info->chn_type.b[0],
+			       device_info->chn_type.b[5],
+			       device_info->chn_type.b[4],
+			       device_info->chn_type.b[7],
+			       device_info->chn_type.b[6],
+			       device_info->chn_type.b[8],
+			       device_info->chn_type.b[9],
+			       device_info->chn_type.b[10],
+			       device_info->chn_type.b[11],
+			       device_info->chn_type.b[12],
+			       device_info->chn_type.b[13],
+			       device_info->chn_type.b[14],
+			       device_info->chn_type.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "device_id")) {
-		return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
+		ret = sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 			       "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
-			       device_info.chn_instance.b[3],
-			       device_info.chn_instance.b[2],
-			       device_info.chn_instance.b[1],
-			       device_info.chn_instance.b[0],
-			       device_info.chn_instance.b[5],
-			       device_info.chn_instance.b[4],
-			       device_info.chn_instance.b[7],
-			       device_info.chn_instance.b[6],
-			       device_info.chn_instance.b[8],
-			       device_info.chn_instance.b[9],
-			       device_info.chn_instance.b[10],
-			       device_info.chn_instance.b[11],
-			       device_info.chn_instance.b[12],
-			       device_info.chn_instance.b[13],
-			       device_info.chn_instance.b[14],
-			       device_info.chn_instance.b[15]);
+			       device_info->chn_instance.b[3],
+			       device_info->chn_instance.b[2],
+			       device_info->chn_instance.b[1],
+			       device_info->chn_instance.b[0],
+			       device_info->chn_instance.b[5],
+			       device_info->chn_instance.b[4],
+			       device_info->chn_instance.b[7],
+			       device_info->chn_instance.b[6],
+			       device_info->chn_instance.b[8],
+			       device_info->chn_instance.b[9],
+			       device_info->chn_instance.b[10],
+			       device_info->chn_instance.b[11],
+			       device_info->chn_instance.b[12],
+			       device_info->chn_instance.b[13],
+			       device_info->chn_instance.b[14],
+			       device_info->chn_instance.b[15]);
 	} else if (!strcmp(dev_attr->attr.name, "modalias")) {
 		print_alias_name(hv_dev, alias_name);
-		return sprintf(buf, "vmbus:%s\n", alias_name);
+		ret = sprintf(buf, "vmbus:%s\n", alias_name);
 	} else if (!strcmp(dev_attr->attr.name, "state")) {
-		return sprintf(buf, "%d\n", device_info.chn_state);
+		ret = sprintf(buf, "%d\n", device_info->chn_state);
 	} else if (!strcmp(dev_attr->attr.name, "id")) {
-		return sprintf(buf, "%d\n", device_info.chn_id);
+		ret = sprintf(buf, "%d\n", device_info->chn_id);
 	} else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
-		return sprintf(buf, "%d\n", device_info.outbound.int_mask);
+		ret = sprintf(buf, "%d\n", device_info->outbound.int_mask);
 	} else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
-		return sprintf(buf, "%d\n", device_info.outbound.read_idx);
+		ret = sprintf(buf, "%d\n", device_info->outbound.read_idx);
 	} else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
-		return sprintf(buf, "%d\n", device_info.outbound.write_idx);
+		ret = sprintf(buf, "%d\n", device_info->outbound.write_idx);
 	} else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
-		return sprintf(buf, "%d\n",
-			       device_info.outbound.bytes_avail_toread);
+		ret = sprintf(buf, "%d\n",
+			       device_info->outbound.bytes_avail_toread);
 	} else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
-		return sprintf(buf, "%d\n",
-			       device_info.outbound.bytes_avail_towrite);
+		ret = sprintf(buf, "%d\n",
+			       device_info->outbound.bytes_avail_towrite);
 	} else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
-		return sprintf(buf, "%d\n", device_info.inbound.int_mask);
+		ret = sprintf(buf, "%d\n", device_info->inbound.int_mask);
 	} else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
-		return sprintf(buf, "%d\n", device_info.inbound.read_idx);
+		ret = sprintf(buf, "%d\n", device_info->inbound.read_idx);
 	} else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
-		return sprintf(buf, "%d\n", device_info.inbound.write_idx);
+		ret = sprintf(buf, "%d\n", device_info->inbound.write_idx);
 	} else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
-		return sprintf(buf, "%d\n",
-			       device_info.inbound.bytes_avail_toread);
+		ret = sprintf(buf, "%d\n",
+			       device_info->inbound.bytes_avail_toread);
 	} else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
-		return sprintf(buf, "%d\n",
-			       device_info.inbound.bytes_avail_towrite);
+		ret = sprintf(buf, "%d\n",
+			       device_info->inbound.bytes_avail_towrite);
 	} else if (!strcmp(dev_attr->attr.name, "monitor_id")) {
-		return sprintf(buf, "%d\n", device_info.monitor_id);
+		ret = sprintf(buf, "%d\n", device_info->monitor_id);
 	} else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) {
-		return sprintf(buf, "%d\n", device_info.server_monitor_pending);
+		ret = sprintf(buf, "%d\n", device_info->server_monitor_pending);
 	} else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) {
-		return sprintf(buf, "%d\n", device_info.server_monitor_latency);
+		ret = sprintf(buf, "%d\n", device_info->server_monitor_latency);
 	} else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) {
-		return sprintf(buf, "%d\n",
-			       device_info.server_monitor_conn_id);
+		ret = sprintf(buf, "%d\n",
+			       device_info->server_monitor_conn_id);
 	} else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) {
-		return sprintf(buf, "%d\n", device_info.client_monitor_pending);
+		ret = sprintf(buf, "%d\n", device_info->client_monitor_pending);
 	} else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) {
-		return sprintf(buf, "%d\n", device_info.client_monitor_latency);
+		ret = sprintf(buf, "%d\n", device_info->client_monitor_latency);
 	} else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) {
-		return sprintf(buf, "%d\n",
-			       device_info.client_monitor_conn_id);
-	} else {
-		return 0;
+		ret = sprintf(buf, "%d\n",
+			       device_info->client_monitor_conn_id);
 	}
+
+	kfree(device_info);
+	return ret;
 }
 
 /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 15/20] Staging: hv: vmbus: Get rid of the ext field in struct hv_device
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Now that we have eliminated all uses of the ext field in struct hv_device,
get rid of the ext field.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index e51341f..4b692ea 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -822,9 +822,6 @@ struct hv_device {
 	struct device device;
 
 	struct vmbus_channel *channel;
-
-	/* Device extension; */
-	void *ext;
 };
 
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 14/20] Staging: hv: mousevsc: Get rid of the usage of the ext field in struct hv_device
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Get rid of the usage of the ext field in struct hv_device for the mouse driver.
We do this by using the newly introduced functions to set and and get driver
specific data.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 5ff8a03..fcb023a 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -196,7 +196,7 @@ static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 	atomic_cmpxchg(&input_dev->ref_count, 0, 2);
 
 	input_dev->device = device;
-	device->ext = input_dev;
+	hv_set_drvdata(device, input_dev);
 
 	return input_dev;
 }
@@ -214,7 +214,7 @@ static struct mousevsc_dev *get_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *input_dev;
 
-	input_dev = (struct mousevsc_dev *)device->ext;
+	input_dev = hv_get_drvdata(device);
 
 /*
  *	FIXME
@@ -240,7 +240,7 @@ static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *input_dev;
 
-	input_dev = (struct mousevsc_dev *)device->ext;
+	input_dev = hv_get_drvdata(device);
 
 	if (input_dev && atomic_read(&input_dev->ref_count))
 		atomic_inc(&input_dev->ref_count);
@@ -254,7 +254,7 @@ static void put_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *input_dev;
 
-	input_dev = (struct mousevsc_dev *)device->ext;
+	input_dev = hv_get_drvdata(device);
 
 	atomic_dec(&input_dev->ref_count);
 }
@@ -266,7 +266,7 @@ static struct mousevsc_dev *release_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *input_dev;
 
-	input_dev = (struct mousevsc_dev *)device->ext;
+	input_dev = hv_get_drvdata(device);
 
 	/* Busy wait until the ref drop to 2, then set it to 1  */
 	while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2)
@@ -282,13 +282,13 @@ static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
 {
 	struct mousevsc_dev *input_dev;
 
-	input_dev = (struct mousevsc_dev *)device->ext;
+	input_dev = hv_get_drvdata(device);
 
 	/* Busy wait until the ref drop to 1, then set it to 0  */
 	while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1)
 		udelay(100);
 
-	device->ext = NULL;
+	hv_set_drvdata(device, NULL);
 	return input_dev;
 }
 
@@ -790,7 +790,7 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 	int ret = 0;
 
 	pr_info("disabling input device (%p)...",
-		    device->ext);
+		    hv_get_drvdata(device));
 
 	input_dev = release_input_device(device);
 
@@ -808,7 +808,7 @@ static int mousevsc_on_device_remove(struct hv_device *device)
 		udelay(100);
 	}
 
-	pr_info("removing input device (%p)...", device->ext);
+	pr_info("removing input device (%p)...", hv_get_drvdata(device));
 
 	input_dev = final_release_input_device(device);
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 13/20] Staging: hv: netvsc: Get rid of the usage of the ext field in struct hv_device
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Now, eliminate the usage of ext field in struct  hv_device for netvsc driver.
We do this by registering pointer to struct netvsc_device as the driver
specific data and eliminating the current usage of driver specific data
to save and retrieve the pointer to struct net_device.
Additionally, all access to the driver specific data is through
the vmbus wrapper functions. As part of this cleanup, we also get rid
of some unnecessary debug print statements.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hyperv_net.h   |    2 +
 drivers/staging/hv/netvsc.c       |   86 ++++++++++++++++++------------------
 drivers/staging/hv/netvsc_drv.c   |   24 ++++++++--
 drivers/staging/hv/rndis_filter.c |   28 ++++++++----
 4 files changed, 83 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index af8a37f..366dd2b 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -392,6 +392,8 @@ struct netvsc_device {
 	struct nvsp_message revoke_packet;
 	/* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
 
+	struct net_device *ndev;
+
 	/* Holds rndis device info */
 	void *extension;
 };
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 115629f..2bcc8b2 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -35,6 +35,7 @@
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
+	struct net_device *ndev = hv_get_drvdata(device);
 
 	net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
 	if (!net_device)
@@ -43,8 +44,9 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 
 	net_device->destroy = false;
 	net_device->dev = device;
-	device->ext = net_device;
+	net_device->ndev = ndev;
 
+	hv_set_drvdata(device, net_device);
 	return net_device;
 }
 
@@ -52,7 +54,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 
-	net_device = device->ext;
+	net_device = hv_get_drvdata(device);
 	if (net_device && net_device->destroy)
 		net_device = NULL;
 
@@ -63,7 +65,7 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
 
-	net_device = device->ext;
+	net_device = hv_get_drvdata(device);
 
 	if (!net_device)
 		goto get_in_err;
@@ -81,7 +83,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 {
 	struct nvsp_message *revoke_packet;
 	int ret = 0;
-	struct net_device *ndev = dev_get_drvdata(&net_device->dev->device);
+	struct net_device *ndev = net_device->ndev;
 
 	/*
 	 * If we got a section count, it means we received a
@@ -153,14 +155,12 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	int t;
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	net_device = get_outbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "unable to get net device..."
-			   "device being destroyed?\n");
+	if (!net_device)
 		return -ENODEV;
-	}
+	ndev = net_device->ndev;
 
 	net_device->recv_buf =
 		(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
@@ -269,14 +269,12 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	struct netvsc_device *net_device;
 	struct nvsp_message *init_packet;
 	int ndis_version;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	net_device = get_outbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "unable to get net device..."
-			   "device being destroyed?\n");
+	if (!net_device)
 		return -ENODEV;
-	}
+	ndev = net_device->ndev;
 
 	init_packet = &net_device->channel_init_pkt;
 
@@ -357,7 +355,7 @@ int netvsc_device_remove(struct hv_device *device)
 	struct hv_netvsc_packet *netvsc_packet, *pos;
 	unsigned long flags;
 
-	net_device = (struct netvsc_device *)device->ext;
+	net_device = hv_get_drvdata(device);
 	spin_lock_irqsave(&device->channel->inbound_lock, flags);
 	net_device->destroy = true;
 	spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
@@ -381,7 +379,7 @@ int netvsc_device_remove(struct hv_device *device)
 	 */
 
 	spin_lock_irqsave(&device->channel->inbound_lock, flags);
-	device->ext = NULL;
+	hv_set_drvdata(device, NULL);
 	spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
 
 	/* At this point, no one should be accessing netDevice except in here */
@@ -407,14 +405,12 @@ static void netvsc_send_completion(struct hv_device *device,
 	struct netvsc_device *net_device;
 	struct nvsp_message *nvsp_packet;
 	struct hv_netvsc_packet *nvsc_packet;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	net_device = get_inbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "unable to get net device..."
-			   "device being destroyed?\n");
+	if (!net_device)
 		return;
-	}
+	ndev = net_device->ndev;
 
 	nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
 			(packet->offset8 << 3));
@@ -452,14 +448,12 @@ int netvsc_send(struct hv_device *device,
 	struct netvsc_device *net_device;
 	int ret = 0;
 	struct nvsp_message sendMessage;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	net_device = get_outbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "net device (%p) shutting down..."
-			   "ignoring outbound packets\n", net_device);
+	if (!net_device)
 		return -ENODEV;
-	}
+	ndev = net_device->ndev;
 
 	sendMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
 	if (packet->is_data_pkt) {
@@ -506,7 +500,10 @@ static void netvsc_send_recv_completion(struct hv_device *device,
 	struct nvsp_message recvcompMessage;
 	int retries = 0;
 	int ret;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
+	struct netvsc_device *net_device = hv_get_drvdata(device);
+
+	ndev = net_device->ndev;
 
 	recvcompMessage.hdr.msg_type =
 				NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
@@ -552,7 +549,7 @@ static void netvsc_receive_completion(void *context)
 	u64 transaction_id = 0;
 	bool fsend_receive_comp = false;
 	unsigned long flags;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	/*
 	 * Even though it seems logical to do a GetOutboundNetDevice() here to
@@ -560,11 +557,9 @@ static void netvsc_receive_completion(void *context)
 	 * since we may have disable outbound traffic already.
 	 */
 	net_device = get_inbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "unable to get net device..."
-			   "device being destroyed?\n");
+	if (!net_device)
 		return;
-	}
+	ndev = net_device->ndev;
 
 	/* Overloading use of the lock. */
 	spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
@@ -607,16 +602,14 @@ static void netvsc_receive(struct hv_device *device,
 	int i, j;
 	int count = 0, bytes_remain = 0;
 	unsigned long flags;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	LIST_HEAD(listHead);
 
 	net_device = get_inbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "unable to get net device..."
-			   "device being destroyed?\n");
+	if (!net_device)
 		return;
-	}
+	ndev = net_device->ndev;
 
 	/*
 	 * All inbound packets other than send completion should be xfer page
@@ -784,7 +777,7 @@ static void netvsc_channel_cb(void *context)
 	struct vmpacket_descriptor *desc;
 	unsigned char *buffer;
 	int bufferlen = NETVSC_PACKET_SIZE;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char),
 			 GFP_ATOMIC);
@@ -793,11 +786,9 @@ static void netvsc_channel_cb(void *context)
 	buffer = packet;
 
 	net_device = get_inbound_net_device(device);
-	if (!net_device) {
-		netdev_err(ndev, "net device (%p) shutting down..."
-			   "ignoring inbound packets\n", net_device);
+	if (!net_device)
 		goto out;
-	}
+	ndev = net_device->ndev;
 
 	do {
 		ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen,
@@ -871,7 +862,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 	((struct netvsc_device_info *)additional_info)->ring_size;
 	struct netvsc_device *net_device;
 	struct hv_netvsc_packet *packet, *pos;
-	struct net_device *ndev = dev_get_drvdata(&device->device);
+	struct net_device *ndev;
 
 	net_device = alloc_net_device(device);
 	if (!net_device) {
@@ -879,6 +870,15 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 		goto cleanup;
 	}
 
+	/*
+	 * Coming into this function, struct net_device * is
+	 * registered as the driver private data.
+	 * In alloc_net_device(), we register struct netvsc_device *
+	 * as the driver private data and stash away struct net_device *
+	 * in struct netvsc_device *.
+	 */
+	ndev = net_device->ndev;
+
 	/* Initialize the NetVSC channel extension */
 	net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
 	spin_lock_init(&net_device->recv_pkt_list_lock);
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index d06cde2..69c233e 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -203,8 +203,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 void netvsc_linkstatus_callback(struct hv_device *device_obj,
 				       unsigned int status)
 {
-	struct net_device *net = dev_get_drvdata(&device_obj->device);
+	struct net_device *net;
 	struct net_device_context *ndev_ctx;
+	struct netvsc_device *net_device;
+
+	net_device = hv_get_drvdata(device_obj);
+	net = net_device->ndev;
 
 	if (!net) {
 		netdev_err(net, "got link status but net device "
@@ -236,6 +240,10 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 	void *data;
 	int i;
 	unsigned long flags;
+	struct netvsc_device *net_device;
+
+	net_device = hv_get_drvdata(device_obj);
+	net = net_device->ndev;
 
 	if (!net) {
 		netdev_err(net, "got receive callback but net device"
@@ -322,9 +330,11 @@ static void netvsc_send_garp(struct work_struct *w)
 {
 	struct net_device_context *ndev_ctx;
 	struct net_device *net;
+	struct netvsc_device *net_device;
 
 	ndev_ctx = container_of(w, struct net_device_context, dwork.work);
-	net = dev_get_drvdata(&ndev_ctx->device_ctx->device);
+	net_device = hv_get_drvdata(ndev_ctx->device_ctx);
+	net = net_device->ndev;
 	netif_notify_peers(net);
 }
 
@@ -347,7 +357,7 @@ static int netvsc_probe(struct hv_device *dev,
 	net_device_ctx = netdev_priv(net);
 	net_device_ctx->device_ctx = dev;
 	atomic_set(&net_device_ctx->avail, ring_size);
-	dev_set_drvdata(&dev->device, net);
+	hv_set_drvdata(dev, net);
 	INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);
 
 	net->netdev_ops = &device_ops;
@@ -373,7 +383,7 @@ static int netvsc_probe(struct hv_device *dev,
 		netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
 		unregister_netdev(net);
 		free_netdev(net);
-		dev_set_drvdata(&dev->device, NULL);
+		hv_set_drvdata(dev, NULL);
 		return ret;
 	}
 	memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
@@ -386,8 +396,12 @@ out:
 
 static int netvsc_remove(struct hv_device *dev)
 {
-	struct net_device *net = dev_get_drvdata(&dev->device);
+	struct net_device *net;
 	struct net_device_context *ndev_ctx;
+	struct netvsc_device *net_device;
+
+	net_device = hv_get_drvdata(dev);
+	net = net_device->ndev;
 
 	if (net == NULL) {
 		dev_err(&dev->device, "No net device to remove\n");
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index b325345..b354b0b 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -141,7 +141,11 @@ static void put_rndis_request(struct rndis_device *dev,
 static void dump_rndis_message(struct hv_device *hv_dev,
 			struct rndis_message *rndis_msg)
 {
-	struct net_device *netdev = dev_get_drvdata(&hv_dev->device);
+	struct net_device *netdev;
+	struct netvsc_device *net_device;
+
+	net_device = hv_get_drvdata(hv_dev);
+	netdev = net_device->ndev;
 
 	switch (rndis_msg->ndis_msg_type) {
 	case REMOTE_NDIS_PACKET_MSG:
@@ -249,7 +253,9 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
 	struct rndis_request *request = NULL;
 	bool found = false;
 	unsigned long flags;
-	struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device);
+	struct net_device *ndev;
+
+	ndev = dev->net_dev->ndev;
 
 	spin_lock_irqsave(&dev->request_lock, flags);
 	list_for_each_entry(request, &dev->req_list, list_ent) {
@@ -356,11 +362,13 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
 int rndis_filter_receive(struct hv_device *dev,
 				struct hv_netvsc_packet	*pkt)
 {
-	struct netvsc_device *net_dev = dev->ext;
+	struct netvsc_device *net_dev = hv_get_drvdata(dev);
 	struct rndis_device *rndis_dev;
 	struct rndis_message rndis_msg;
 	struct rndis_message *rndis_hdr;
-	struct net_device *ndev = dev_get_drvdata(&dev->device);
+	struct net_device *ndev;
+
+	ndev = net_dev->ndev;
 
 	if (!net_dev)
 		return -EINVAL;
@@ -517,7 +525,9 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	struct rndis_set_complete *set_complete;
 	u32 status;
 	int ret, t;
-	struct net_device *ndev = dev_get_drvdata(&dev->net_dev->dev->device);
+	struct net_device *ndev;
+
+	ndev = dev->net_dev->ndev;
 
 	request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@ -700,7 +710,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 
 	/* Initialize the rndis device */
-	netDevice = dev->ext;
+	netDevice = hv_get_drvdata(dev);
 
 	netDevice->extension = rndisDevice;
 	rndisDevice->net_dev = netDevice;
@@ -737,7 +747,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 void rndis_filter_device_remove(struct hv_device *dev)
 {
-	struct netvsc_device *net_dev = dev->ext;
+	struct netvsc_device *net_dev = hv_get_drvdata(dev);
 	struct rndis_device *rndis_dev = net_dev->extension;
 
 	/* Halt and release the rndis device */
@@ -752,7 +762,7 @@ void rndis_filter_device_remove(struct hv_device *dev)
 
 int rndis_filter_open(struct hv_device *dev)
 {
-	struct netvsc_device *netDevice = dev->ext;
+	struct netvsc_device *netDevice = hv_get_drvdata(dev);
 
 	if (!netDevice)
 		return -EINVAL;
@@ -762,7 +772,7 @@ int rndis_filter_open(struct hv_device *dev)
 
 int rndis_filter_close(struct hv_device *dev)
 {
-	struct netvsc_device *netDevice = dev->ext;
+	struct netvsc_device *netDevice = hv_get_drvdata(dev);
 
 	if (!netDevice)
 		return -EINVAL;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 12/20] Staging: hv: storvsc: Eliminate the usage of ext field in struct hv_device
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Now, eliminate the usage of ext field in struct  hv_device for storvsc driver.
We do this by registering pointer to struct storvsc_device as the driver
specific data and eliminating the current usage of driver specific data to
save and retrieve the pointer to struct Scsi_Host.
Additionally, all access to the driver specific data is through
the vmbus wrapper functions. Note that function to allocate the host
gives us a reference on the host object.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 5e306a5..807c94d 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -266,6 +266,7 @@ struct storvsc_device {
 	bool	 destroy;
 	bool	 drain_notify;
 	atomic_t num_outstanding_req;
+	struct Scsi_Host *host;
 
 	wait_queue_head_t waiting_to_drain;
 
@@ -306,7 +307,7 @@ static inline struct storvsc_device *get_out_stor_device(
 {
 	struct storvsc_device *stor_device;
 
-	stor_device = (struct storvsc_device *)device->ext;
+	stor_device = hv_get_drvdata(device);
 
 	if (stor_device && stor_device->destroy)
 		stor_device = NULL;
@@ -328,7 +329,7 @@ static inline struct storvsc_device *get_in_stor_device(
 {
 	struct storvsc_device *stor_device;
 
-	stor_device = (struct storvsc_device *)device->ext;
+	stor_device = hv_get_drvdata(device);
 
 	if (!stor_device)
 		goto get_in_err;
@@ -480,8 +481,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
 	struct storvsc_device *stor_device;
 	struct vstor_packet *stor_pkt;
 
-	stor_device = (struct storvsc_device *)device->ext;
-
+	stor_device = hv_get_drvdata(device);
 	stor_pkt = &request->vstor_packet;
 
 	/*
@@ -630,7 +630,7 @@ static int storvsc_dev_remove(struct hv_device *device)
 	struct storvsc_device *stor_device;
 	unsigned long flags;
 
-	stor_device = (struct storvsc_device *)device->ext;
+	stor_device = hv_get_drvdata(device);
 
 	spin_lock_irqsave(&device->channel->inbound_lock, flags);
 	stor_device->destroy = true;
@@ -652,7 +652,7 @@ static int storvsc_dev_remove(struct hv_device *device)
 	 * allow incoming packets.
 	 */
 	spin_lock_irqsave(&device->channel->inbound_lock, flags);
-	device->ext = NULL;
+	hv_set_drvdata(device, NULL);
 	spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
 
 	/* Close the channel */
@@ -962,7 +962,8 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 
 static int storvsc_remove(struct hv_device *dev)
 {
-	struct Scsi_Host *host = dev_get_drvdata(&dev->device);
+	struct storvsc_device *stor_device = hv_get_drvdata(dev);
+	struct Scsi_Host *host = stor_device->host;
 	struct hv_host_device *host_dev =
 			(struct hv_host_device *)host->hostdata;
 
@@ -1338,8 +1339,6 @@ static int storvsc_probe(struct hv_device *device,
 	if (!host)
 		return -ENOMEM;
 
-	dev_set_drvdata(&device->device, host);
-
 	host_dev = (struct hv_host_device *)host->hostdata;
 	memset(host_dev, 0, sizeof(struct hv_host_device));
 
@@ -1366,7 +1365,8 @@ static int storvsc_probe(struct hv_device *device,
 	stor_device->destroy = false;
 	init_waitqueue_head(&stor_device->waiting_to_drain);
 	stor_device->device = device;
-	device->ext = stor_device;
+	stor_device->host = host;
+	hv_set_drvdata(device, stor_device);
 
 	stor_device->port_number = host->host_no;
 	ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 11/20] Staging: hv: storvsc: Get rid of some unnecessary state and definitions
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Now, get rid of some unnecessary state and definitions.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ce8652e..5e306a5 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -245,7 +245,6 @@ enum storvsc_request_type {
 
 
 struct hv_storvsc_request {
-	struct hv_storvsc_request *request;
 	struct hv_device *device;
 
 	/* Synchronize the request/response if needed */
@@ -260,14 +259,6 @@ struct hv_storvsc_request {
 };
 
 
-struct storvsc_device_info {
-	u32 ring_buffer_size;
-	unsigned int port_number;
-	unsigned char path_id;
-	unsigned char target_id;
-};
-
-
 /* A storvsc device is a device object that contains a vmbus channel */
 struct storvsc_device {
 	struct hv_device *device;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 10/20] Staging: hv: storvsc: Get rid of alloc_stor_device() by inlining the code
From: K. Y. Srinivasan @ 2011-09-13 17:59 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1315936796-20662-1-git-send-email-kys@microsoft.com>

Get rid of alloc_stor_device() by inlining the code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 2210c8c..ce8652e 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -332,23 +332,6 @@ static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
 	dev->drain_notify = false;
 }
 
-static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
-{
-	struct storvsc_device *stor_device;
-
-	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
-	if (!stor_device)
-		return NULL;
-
-	stor_device->destroy = false;
-	init_waitqueue_head(&stor_device->waiting_to_drain);
-	stor_device->device = device;
-	device->ext = stor_device;
-
-	return stor_device;
-}
-
-
 static inline struct storvsc_device *get_in_stor_device(
 					struct hv_device *device)
 {
@@ -1382,13 +1365,18 @@ static int storvsc_probe(struct hv_device *device,
 		return -ENOMEM;
 	}
 
-	stor_device = alloc_stor_device(device);
+	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
 	if (!stor_device) {
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
 		return -ENOMEM;
 	}
 
+	stor_device->destroy = false;
+	init_waitqueue_head(&stor_device->waiting_to_drain);
+	stor_device->device = device;
+	device->ext = stor_device;
+
 	stor_device->port_number = host->host_no;
 	ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
 	if (ret) {
-- 
1.7.4.1

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox