[PATCH] libertas: ifdef'ed usage of "static wlan_private *wlanpriv"

Marcelo Tosatti marcelo at kvack.org
Sat Feb 17 19:58:17 EST 2007


Holger, 

I got rid of all code conditioned by "#ifdef ENABLE_PM". We already
provide proper suspend/resume methods in if_usb.c, and you should
provide them in if_cf.c too (methods in struct pcmcia_driver).

Thanks

On Fri, Feb 16, 2007 at 02:38:14PM +0100, Holger Schurig wrote:
> libertas: ifdef'ed usage of "static wlan_private *wlanpriv"
> 
> There was a "static wlan_private *wlanpriv = NULL" defined which is used
> only in wlan_pm_callback(). The latter is only defined when ENABLE_PM is
> defined, so there's no need to have this ugly variable laying around.
> 
> Signed-off-by: Holger Schurig <hs4233 at mail.mn-solutions.de>
> 
> ---
> 
> wlan_pm_callback() needs to be redesigned anyway, because it is used via the
> deprectated pm_register(). And even then it could be written better, because
> we can transfer void* via pm_register(), so there's no need to
> wlan_pm_callback() to look at static variables, which might break a
> one-driver-for-multiple-devices scenario.
> 
> --- libertas-2.6.orig/drivers/net/wireless/libertas/main.c
> +++ libertas-2.6/drivers/net/wireless/libertas/main.c
> @@ -23,6 +23,7 @@
>  
>  #ifdef ENABLE_PM
>  static struct pm_dev *wlan_pm_dev = NULL;
> +static wlan_private *wlanpriv = NULL;
>  #endif
>  
>  #define WLAN_TX_PWR_DEFAULT		20	/*100mW */
> @@ -165,12 +166,6 @@
>   */
>  u8 libertas_adhoc_rates_b[4] = { 0x82, 0x84, 0x8b, 0x96 };
>  
> -/**
> - * the global variable of a pointer to wlan_private
> - * structure variable
> - */
> -static wlan_private *wlanpriv = NULL;
> -
>  #define MAX_DEVS 5
>  static struct net_device *libertas_devs[MAX_DEVS];
>  static int libertas_found = 0;
> @@ -907,7 +902,9 @@
>  	priv->mesh_open = 0;
>  	priv->infra_open = 0;
>  	priv->mesh_dev = mesh_dev;
> +#ifdef ENABLE_PM
>  	wlanpriv = priv;
> +#endif
>  
>  	SET_MODULE_OWNER(dev);
>  	SET_MODULE_OWNER(mesh_dev);
> @@ -922,8 +919,8 @@
>  	mesh_dev->hard_start_xmit = mesh_pre_start_xmit;
>  	mesh_dev->stop = mesh_close;
>  	mesh_dev->do_ioctl = libertas_do_ioctl; 
> -	memcpy(mesh_dev->dev_addr, wlanpriv->wlan_dev.netdev->dev_addr, 
> -			sizeof(wlanpriv->wlan_dev.netdev->dev_addr));
> +	memcpy(mesh_dev->dev_addr, priv->wlan_dev.netdev->dev_addr,
> +			sizeof(priv->wlan_dev.netdev->dev_addr));
>  
>  #define	WLAN_WATCHDOG_TIMEOUT	(5 * HZ)
>  
> @@ -1017,7 +1014,9 @@
>  err_kmalloc:
>  	free_netdev(dev);
>  	free_netdev(mesh_dev);
> +#ifdef ENABLE_PM
>  	wlanpriv = NULL;
> +#endif
>  
>  	LEAVE();
>  	return NULL;
> @@ -1112,7 +1111,9 @@
>  	priv->mesh_dev = NULL ;
>  	free_netdev(mesh_dev);
>  	free_netdev(dev);
> +#ifdef ENABLE_PM
>  	wlanpriv = NULL;
> +#endif
>  
>  	LEAVE();
>  	return 0;
> 
> _______________________________________________
> libertas-dev mailing list
> libertas-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libertas-dev



More information about the libertas-dev mailing list