Subject: Re: [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()

From: Wang Chen <[email-masked]>
Date: Mon, 03 Nov 2008 10:06:28 +0800

John W. Linville said the following on 2008-11-1 2:48:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
>    netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
> 
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
> 
> (Original patch posted by Wang Chen <[email-masked]> w/ above
> changelog but using dev->ml_priv.  That doesn't seem appropriate
> to me for this driver, so I've revamped it to use netdev_priv()
> instead. -- JWL)
> 
> Cc: Wang Chen <[email-masked]>
> Signed-off-by: John W. Linville <[email-masked]>
> ---
>  drivers/net/wireless/zd1201.c |  115 ++++++++++++++++++++---------------------
>  1 files changed, 56 insertions(+), 59 deletions(-)
> 
snip...
> @@ -1731,6 +1731,7 @@ static int zd1201_probe(struct usb_interface *interface,
>  			const struct usb_device_id *id)
>  {
>  	struct zd1201 *zd;
> +	struct net_device *dev;
>  	struct usb_device *usb;
>  	int err;
>  	short porttype;
> @@ -1738,9 +1739,12 @@ static int zd1201_probe(struct usb_interface *interface,
>  
>  	usb = interface_to_usbdev(interface);
>  
> -	zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
> -	if (!zd)
> +	dev = alloc_etherdev(sizeof(*zd));
> +	if (!dev)
>  		return -ENOMEM;
> +	zd = netdev_priv(dev);
> +	zd->dev = dev;
> +

It's ok to me.

Reviewed-by: Wang Chen <[email-masked]>

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email-masked]
More majordomo info at  http://vger.kernel.org/majordomo-info.html