Search Linux Wireless

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <wangchen@xxxxxxxxxxxxxx> 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 <wangchen@xxxxxxxxxxxxxx>
> Signed-off-by: John W. Linville <linville@xxxxxxxxxxxxx>
> ---
>  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 <wangchen@xxxxxxxxxxxxxx>

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

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux