public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Haiyang Zhang <haiyangz@microsoft.com>
Cc: hjanssen@microsoft.com, kys@microsoft.com,
	v-abkane@microsoft.com, gregkh@suse.de,
	linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
	virtualization@lists.osdl.org
Subject: Re: [PATCH 2/4] staging: hv: Fix the code depending on struct netvsc_driver_context data order
Date: Wed, 23 Feb 2011 13:27:38 -0800	[thread overview]
Message-ID: <20110223212738.GD23766@kroah.com> (raw)
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

  parent reply	other threads:[~2011-02-23 21:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 20:19 [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context data order Haiyang Zhang
2011-02-23 20:19 ` [PATCH 2/4] staging: hv: Fix the code depending on struct netvsc_driver_context " Haiyang Zhang
2011-02-23 20:19   ` [PATCH 3/4] staging: hv: Fix the code depending on struct blkvsc_driver_context " Haiyang Zhang
2011-02-23 20:19     ` [PATCH 4/4] staging: hv: Fix the code depending on struct storvsc_driver_context " Haiyang Zhang
2011-02-23 21:28       ` Greg KH
2011-02-23 21:28     ` [PATCH 3/4] staging: hv: Fix the code depending on struct blkvsc_driver_context " Greg KH
2011-02-23 20:53   ` [PATCH 2/4] staging: hv: Fix the code depending on struct netvsc_driver_context " Thomas Gleixner
2011-02-23 21:27   ` Greg KH [this message]
2011-02-23 21:26 ` [PATCH 1/4] staging: hv: Fix the code depending on struct vmbus_driver_context " Greg KH
2011-02-23 22:44   ` KY Srinivasan
2011-02-23 22:48     ` Greg KH
2011-02-23 22:55       ` Haiyang Zhang
2011-02-23 23:06         ` Greg KH
2011-02-23 22:58       ` KY Srinivasan
2011-02-23 22:48   ` Haiyang Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110223212738.GD23766@kroah.com \
    --to=greg@kroah.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@suse.de \
    --cc=haiyangz@microsoft.com \
    --cc=hjanssen@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=v-abkane@microsoft.com \
    --cc=virtualization@lists.osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox