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

Holger Schurig hs4233 at mail.mn-solutions.de
Fri Feb 16 08:38:14 EST 2007


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;



More information about the libertas-dev mailing list