[PATCH v2 15/21] staging: rtl8192e: Fix LONG_LINE warnings - modify variables

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

 



Further reduction of checkpatch.pl LONG_LINE warnings:
- Local variables are compacted where it's needed
- Helper (local) variables are used (to avoid expressions like a.b.c.d.e)

Both changes should be optimized out by compilers.dd

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx>
---
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c    |  13 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c     |  45 +--
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c        |  53 ++-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c         | 397 +++++++++++----------
 drivers/staging/rtl8192e/rtllib_rx.c               |   2 +-
 drivers/staging/rtl8192e/rtllib_softmac.c          | 123 +++----
 drivers/staging/rtl8192e/rtllib_tx.c               |  28 +-
 7 files changed, 344 insertions(+), 317 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index 02c5b0a..05f534e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -36,6 +36,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
 			     u32 buffer_len)
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
+	struct rtllib_device *rt = priv->rtllib;
 	u16		    frag_threshold;
 	u16		    frag_length, frag_offset = 0;
 	int		    i;
@@ -80,15 +81,15 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
 		tcb_desc->txbuf_size = (u16)i;
 		skb_put(skb, i);
 
-		if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) ||
-		    (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index])) ||
-		    (priv->rtllib->queue_stop)) {
+		if (!rt->check_nic_enough_desc(dev, tcb_desc->queue_index) ||
+		    !skb_queue_empty(&rt->skb_waitQ[tcb_desc->queue_index]) ||
+		    rt->queue_stop) {
 			RT_TRACE(COMP_FIRMWARE,
 				 "===================> tx full!\n");
-			skb_queue_tail(&priv->rtllib->skb_waitQ
-					[tcb_desc->queue_index], skb);
+			skb_queue_tail(&rt->skb_waitQ[tcb_desc->queue_index],
+					skb);
 		} else {
-		priv->rtllib->softmac_hard_start_xmit(skb, dev);
+			rt->softmac_hard_start_xmit(skb, dev);
 		}
 
 		code_virtual_address += frag_length;
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 0765c97..87361cd 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -640,42 +640,43 @@ void rtl8192_phy_getTxPower(struct net_device *dev)
 
 void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel)
 {
-	struct r8192_priv *priv = rtllib_priv(dev);
+	struct r8192_priv *p = rtllib_priv(dev);
 	u8	powerlevel = 0, powerlevelOFDM24G = 0;
 	char ant_pwr_diff;
 	u32	u4RegValue;
 
-	if (priv->epromtype == EEPROM_93C46) {
-		powerlevel = priv->TxPowerLevelCCK[channel-1];
-		powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1];
-	} else if (priv->epromtype == EEPROM_93C56) {
-		if (priv->rf_type == RF_1T2R) {
-			powerlevel = priv->TxPowerLevelCCK_C[channel-1];
-			powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1];
-		} else if (priv->rf_type == RF_2T4R) {
-			powerlevel = priv->TxPowerLevelCCK_A[channel-1];
-			powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1];
+	if (p->epromtype == EEPROM_93C46) {
+		powerlevel = p->TxPowerLevelCCK[channel-1];
+		powerlevelOFDM24G = p->TxPowerLevelOFDM24G[channel-1];
+	} else if (p->epromtype == EEPROM_93C56) {
+		if (p->rf_type == RF_1T2R) {
+			powerlevel = p->TxPowerLevelCCK_C[channel-1];
+			powerlevelOFDM24G = p->TxPowerLevelOFDM24G_C[channel-1];
+		} else if (p->rf_type == RF_2T4R) {
+			powerlevel = p->TxPowerLevelCCK_A[channel-1];
+			powerlevelOFDM24G = p->TxPowerLevelOFDM24G_A[channel-1];
 
-			ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1]
-				       - priv->TxPowerLevelOFDM24G_A[channel-1];
+			ant_pwr_diff = p->TxPowerLevelOFDM24G_C[channel-1] -
+				       p->TxPowerLevelOFDM24G_A[channel-1];
 
-			priv->RF_C_TxPwDiff = ant_pwr_diff;
+			p->RF_C_TxPwDiff = ant_pwr_diff;
 
 			ant_pwr_diff &= 0xf;
 
-			priv->AntennaTxPwDiff[2] = 0;
-			priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
-			priv->AntennaTxPwDiff[0] = 0;
+			p->AntennaTxPwDiff[2] = 0;
+			p->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff);
+			p->AntennaTxPwDiff[0] = 0;
 
-			u4RegValue = (priv->AntennaTxPwDiff[2]<<8 |
-				      priv->AntennaTxPwDiff[1]<<4 |
-				      priv->AntennaTxPwDiff[0]);
+			u4RegValue = (p->AntennaTxPwDiff[2]<<8 |
+				      p->AntennaTxPwDiff[1]<<4 |
+				      p->AntennaTxPwDiff[0]);
 
 			rtl8192_setBBreg(dev, rFPGA0_TxGainStage,
-			(bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue);
+					 (bXBTxAGC | bXCTxAGC | bXDTxAGC),
+					 u4RegValue);
 		}
 	}
-	switch (priv->rf_chip) {
+	switch (p->rf_chip) {
 	case RF_8225:
 		break;
 	case RF_8256:
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
index 41b025e..2b94ddc 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
@@ -181,6 +181,7 @@ void CamRestoreAllEntry(struct net_device *dev)
 	static u8	CAM_CONST_BROAD[] = {
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 	};
+	struct sw_cam_table *swcam = priv->rtllib->swcamtable;
 
 	RT_TRACE(COMP_SEC, "CamRestoreAllEntry:\n");
 
@@ -190,11 +191,10 @@ void CamRestoreAllEntry(struct net_device *dev)
 
 		for (EntryId = 0; EntryId < 4; EntryId++) {
 			MacAddr = CAM_CONST_ADDR[EntryId];
-			if (priv->rtllib->swcamtable[EntryId].bused) {
+			if (swcam[EntryId].bused) {
 				setKey(dev, EntryId, EntryId,
 				       priv->rtllib->pairwise_key_type, MacAddr,
-				       0, (u32 *)(&priv->rtllib->swcamtable
-				      [EntryId].key_buf[0]));
+				       0, (u32 *)(&swcam[EntryId].key_buf[0]));
 			}
 		}
 
@@ -202,46 +202,37 @@ void CamRestoreAllEntry(struct net_device *dev)
 		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
 			setKey(dev, 4, 0, priv->rtllib->pairwise_key_type,
 			       (u8 *)dev->dev_addr, 0,
-			       (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0]));
+			       (u32 *)(&swcam[4].key_buf[0]));
 		} else {
 			setKey(dev, 4, 0, priv->rtllib->pairwise_key_type,
-			       MacAddr, 0,
-			       (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0]));
+			       MacAddr, 0, (u32 *)(&swcam[4].key_buf[0]));
 		}
 
 	} else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) {
 		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
-			setKey(dev, 4, 0,
-			       priv->rtllib->pairwise_key_type,
+			setKey(dev, 4, 0, priv->rtllib->pairwise_key_type,
 			       (u8 *)dev->dev_addr, 0,
-			       (u32 *)(&priv->rtllib->swcamtable[4].
-			       key_buf[0]));
+			       (u32 *)(&swcam[4].key_buf[0]));
 		} else {
-			setKey(dev, 4, 0,
-			       priv->rtllib->pairwise_key_type, MacAddr,
-			       0, (u32 *)(&priv->rtllib->swcamtable[4].
-			       key_buf[0]));
+			setKey(dev, 4, 0, priv->rtllib->pairwise_key_type,
+			       MacAddr, 0, (u32 *)(&swcam[4].key_buf[0]));
 			}
 	}
 
 	if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) {
 		MacAddr = CAM_CONST_BROAD;
 		for (EntryId = 1; EntryId < 4; EntryId++) {
-			if (priv->rtllib->swcamtable[EntryId].bused) {
+			if (swcam[EntryId].bused) {
 				setKey(dev, EntryId, EntryId,
-					priv->rtllib->group_key_type,
-					MacAddr, 0,
-					(u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0])
-				     );
+				       priv->rtllib->group_key_type, MacAddr, 0,
+				       (u32 *)(&swcam[EntryId].key_buf[0]));
 			}
 		}
 		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
-			if (priv->rtllib->swcamtable[0].bused) {
-				setKey(dev, 0, 0,
-				       priv->rtllib->group_key_type,
+			if (swcam[0].bused) {
+				setKey(dev, 0, 0, priv->rtllib->group_key_type,
 				       CAM_CONST_ADDR[0], 0,
-				       (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])
-				     );
+				       (u32 *)(&swcam[0].key_buf[0]));
 			} else {
 				RT_TRACE(COMP_ERR,
 					 "===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",
@@ -252,20 +243,18 @@ void CamRestoreAllEntry(struct net_device *dev)
 	} else if (priv->rtllib->group_key_type == KEY_TYPE_CCMP) {
 		MacAddr = CAM_CONST_BROAD;
 		for (EntryId = 1; EntryId < 4; EntryId++) {
-			if (priv->rtllib->swcamtable[EntryId].bused) {
+			if (swcam[EntryId].bused) {
 				setKey(dev, EntryId, EntryId,
-				       priv->rtllib->group_key_type,
-				       MacAddr, 0,
-				       (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0]));
+				       priv->rtllib->group_key_type, MacAddr, 0,
+				       (u32 *)(&swcam[EntryId].key_buf[0]));
 			}
 		}
 
 		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
-			if (priv->rtllib->swcamtable[0].bused) {
-				setKey(dev, 0, 0,
-					priv->rtllib->group_key_type,
+			if (swcam[0].bused) {
+				setKey(dev, 0, 0, priv->rtllib->group_key_type,
 					CAM_CONST_ADDR[0], 0,
-					(u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]));
+				       (u32 *)(&swcam[0].key_buf[0]));
 			} else {
 				RT_TRACE(COMP_ERR,
 					 "===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n",
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index a921857..d71459f 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -471,28 +471,30 @@ static void dm_check_rate_adaptive(struct net_device *dev)
 static void dm_init_bandwidth_autoswitch(struct net_device *dev)
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
+	struct bandwidth_autoswitch *bas = &priv->rtllib->bandwidth_auto_switch;
 
-	priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH;
-	priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW;
-	priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false;
-	priv->rtllib->bandwidth_auto_switch.bautoswitch_enable = false;
+	bas->threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH;
+	bas->threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW;
+	bas->bforced_tx20Mhz = false;
+	bas->bautoswitch_enable = false;
 }
 
 static void dm_bandwidth_autoswitch(struct net_device *dev)
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
+	struct bandwidth_autoswitch *bas = &priv->rtllib->bandwidth_auto_switch;
 
 	if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||
-	   !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable)
+	    !bas->bautoswitch_enable)
 		return;
-	if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false) {
+	if (bas->bforced_tx20Mhz == false) {
 		if (priv->undecorated_smoothed_pwdb <=
-		    priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
-			priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true;
+		    bas->threshold_40Mhzto20Mhz)
+			bas->bforced_tx20Mhz = true;
 	} else {
 		if (priv->undecorated_smoothed_pwdb >=
-		    priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz)
-			priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false;
+		    bas->threshold_20Mhzto40Mhz)
+			bas->bforced_tx20Mhz = false;
 	}
 }
 
@@ -557,43 +559,43 @@ static u8	CCKSwingTable_Ch14[CCK_Table_length][8] = {
 static void dm_tx_update_tssi_weak_signal(struct net_device *dev, u8 RF_Type)
 {
 	struct r8192_priv *p = rtllib_priv(dev);
+	u8 *rfa_pti = &p->rfa_txpowertrackingindex;
+	u8 *rfc_pti = &p->rfc_txpowertrackingindex;
+	u8 *rfa_pti_r = &p->rfa_txpowertrackingindex_real;
+	u8 *rfc_pti_r = &p->rfc_txpowertrackingindex_real;
 
 	if (RF_Type == RF_2T4R) {
-		if ((p->rfa_txpowertrackingindex > 0) &&
-		    (p->rfc_txpowertrackingindex > 0)) {
-			p->rfa_txpowertrackingindex--;
-			if (p->rfa_txpowertrackingindex_real > 4) {
-				p->rfa_txpowertrackingindex_real--;
+		if ((*rfa_pti > 0) && (*rfc_pti > 0)) {
+			(*rfa_pti)--;
+			if (*rfa_pti_r > 4) {
+				(*rfa_pti_r)--;
 				rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
 						 bMaskDWord,
-						 dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+						 dm_tx_bb_gain[*rfa_pti_r]);
 			}
 
-			p->rfc_txpowertrackingindex--;
-			if (p->rfc_txpowertrackingindex_real > 4) {
-				p->rfc_txpowertrackingindex_real--;
+			(*rfc_pti)--;
+			if (*rfc_pti_r > 4) {
+				(*rfc_pti_r)--;
 				rtl8192_setBBreg(dev,
 						 rOFDM0_XCTxIQImbalance,
 						 bMaskDWord,
-						 dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+						 dm_tx_bb_gain[*rfc_pti_r]);
 			}
 		} else {
 			rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
-					 bMaskDWord,
-					 dm_tx_bb_gain[4]);
-			rtl8192_setBBreg(dev,
-					 rOFDM0_XCTxIQImbalance,
+					 bMaskDWord, dm_tx_bb_gain[4]);
+			rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance,
 					 bMaskDWord, dm_tx_bb_gain[4]);
 		}
 	} else {
-		if (p->rfa_txpowertrackingindex > 0) {
-			p->rfa_txpowertrackingindex--;
-			if (p->rfa_txpowertrackingindex_real > 4) {
-				p->rfa_txpowertrackingindex_real--;
-				rtl8192_setBBreg(dev,
-						 rOFDM0_XATxIQImbalance,
+		if (*rfa_pti > 0) {
+			(*rfa_pti)--;
+			if (*rfa_pti_r > 4) {
+				(*rfa_pti_r)--;
+				rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
 						 bMaskDWord,
-						 dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+						 dm_tx_bb_gain[*rfa_pti_r]);
 			}
 		} else {
 			rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
@@ -605,49 +607,48 @@ static void dm_tx_update_tssi_weak_signal(struct net_device *dev, u8 RF_Type)
 static void dm_tx_update_tssi_strong_signal(struct net_device *dev, u8 RF_Type)
 {
 	struct r8192_priv *p = rtllib_priv(dev);
+	u8 *rfa_pti = &p->rfa_txpowertrackingindex;
+	u8 *rfc_pti = &p->rfc_txpowertrackingindex;
+	u8 *rfa_pti_r = &p->rfa_txpowertrackingindex_real;
+	u8 *rfc_pti_r = &p->rfc_txpowertrackingindex_real;
 
 	if (RF_Type == RF_2T4R) {
-		if ((p->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&
-		    (p->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) {
-			p->rfa_txpowertrackingindex++;
-			p->rfa_txpowertrackingindex_real++;
-			rtl8192_setBBreg(dev,
-				 rOFDM0_XATxIQImbalance,
-				 bMaskDWord,
-				 dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
-			p->rfc_txpowertrackingindex++;
-			p->rfc_txpowertrackingindex_real++;
-			rtl8192_setBBreg(dev,
-				 rOFDM0_XCTxIQImbalance,
-				 bMaskDWord,
-				 dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+		if ((*rfa_pti < TxBBGainTableLength - 1) &&
+		    (*rfc_pti < TxBBGainTableLength - 1)) {
+			(*rfa_pti)++;
+			(*rfa_pti_r)++;
+			rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+					 bMaskDWord, dm_tx_bb_gain[*rfa_pti_r]);
+			(*rfc_pti)++;
+			(*rfc_pti_r)++;
+			rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance,
+					 bMaskDWord, dm_tx_bb_gain[*rfc_pti_r]);
 		} else {
-			rtl8192_setBBreg(dev,
-				 rOFDM0_XATxIQImbalance,
-				 bMaskDWord,
-				 dm_tx_bb_gain[TxBBGainTableLength - 1]);
+			rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+					 bMaskDWord,
+					 dm_tx_bb_gain[TxBBGainTableLength-1]);
 			rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance,
 					 bMaskDWord,
-					 dm_tx_bb_gain[TxBBGainTableLength - 1]);
+					 dm_tx_bb_gain[TxBBGainTableLength-1]);
 		}
 	} else {
-		if (p->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
-			p->rfa_txpowertrackingindex++;
-			p->rfa_txpowertrackingindex_real++;
+		if (*rfa_pti < (TxBBGainTableLength - 1)) {
+			(*rfa_pti)++;
+			(*rfa_pti_r)++;
 			rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
-					 bMaskDWord,
-					 dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+					 bMaskDWord, dm_tx_bb_gain[*rfa_pti_r]);
 		} else {
 			rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
 					 bMaskDWord,
-					 dm_tx_bb_gain[TxBBGainTableLength - 1]);
+					 dm_tx_bb_gain[TxBBGainTableLength-1]);
 		}
 	}
 }
 
 static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 {
-	struct r8192_priv *priv = rtllib_priv(dev);
+	struct r8192_priv *p = rtllib_priv(dev);
+	struct rtllib_device *rtl = p->rtllib;
 	bool	bHighpowerstate, viviflag = false;
 	struct dcmd_txcmd tx_cmd;
 	u8	powerlevelOFDM24G;
@@ -661,11 +662,11 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 	RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__);
 	write_nic_byte(dev, Pw_Track_Flag, 0);
 	write_nic_byte(dev, FW_Busy_Flag, 0);
-	priv->rtllib->bdynamic_txpower_enable = false;
-	bHighpowerstate = priv->bDynamicTxHighPower;
+	rtl->bdynamic_txpower_enable = false;
+	bHighpowerstate = p->bDynamicTxHighPower;
 
-	powerlevelOFDM24G = (u8)(priv->Pwr_Track>>24);
-	RF_Type = priv->rf_type;
+	powerlevelOFDM24G = (u8)(p->Pwr_Track>>24);
+	RF_Type = p->rf_type;
 	Value = (RF_Type<<8) | powerlevelOFDM24G;
 
 	RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n",
@@ -687,14 +688,14 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 			if (Pwr_Flag == 0) {
 				mdelay(1);
 
-				if (priv->bResetInProgress) {
+				if (p->bResetInProgress) {
 					RT_TRACE(COMP_POWER_TRACKING,
 						 "we are in silent reset progress, so return\n");
 					write_nic_byte(dev, Pw_Track_Flag, 0);
 					write_nic_byte(dev, FW_Busy_Flag, 0);
 					return;
 				}
-				if (priv->rtllib->eRFPowerState != eRfOn) {
+				if (rtl->eRFPowerState != eRfOn) {
 					RT_TRACE(COMP_POWER_TRACKING,
 						 "we are in power save, so return\n");
 					write_nic_byte(dev, Pw_Track_Flag, 0);
@@ -748,8 +749,9 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 			RT_TRACE(COMP_POWER_TRACKING,
 				 "Avg_TSSI_Meas_from_driver = %d\n",
 				 Avg_TSSI_Meas_from_driver);
-			TSSI_13dBm = priv->TSSI_13dBm;
-			RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm);
+			TSSI_13dBm = p->TSSI_13dBm;
+			RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n",
+				 TSSI_13dBm);
 
 			if (Avg_TSSI_Meas_from_driver > TSSI_13dBm)
 				delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm;
@@ -757,82 +759,94 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 				delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver;
 
 			if (delta <= E_FOR_TX_POWER_TRACK) {
-				priv->rtllib->bdynamic_txpower_enable = true;
+				rtl->bdynamic_txpower_enable = true;
 				write_nic_byte(dev, Pw_Track_Flag, 0);
 				write_nic_byte(dev, FW_Busy_Flag, 0);
 				RT_TRACE(COMP_POWER_TRACKING,
 					 "tx power track is done\n");
 				RT_TRACE(COMP_POWER_TRACKING,
 					 "priv->rfa_txpowertrackingindex = %d\n",
-					 priv->rfa_txpowertrackingindex);
+					 p->rfa_txpowertrackingindex);
 				RT_TRACE(COMP_POWER_TRACKING,
 					 "priv->rfa_txpowertrackingindex_real = %d\n",
-					 priv->rfa_txpowertrackingindex_real);
+					 p->rfa_txpowertrackingindex_real);
 				RT_TRACE(COMP_POWER_TRACKING,
 					 "priv->CCKPresentAttentuation_difference = %d\n",
-					 priv->CCKPresentAttentuation_difference);
+					 p->CCKPresentAttentuation_difference);
 				RT_TRACE(COMP_POWER_TRACKING,
 					 "priv->CCKPresentAttentuation = %d\n",
-					 priv->CCKPresentAttentuation);
+					 p->CCKPresentAttentuation);
 				return;
 			}
-			if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK)
+			if (Avg_TSSI_Meas_from_driver <
+					TSSI_13dBm - E_FOR_TX_POWER_TRACK)
 				dm_tx_update_tssi_weak_signal(dev, RF_Type);
 			else
 				dm_tx_update_tssi_strong_signal(dev, RF_Type);
 
 			if (RF_Type == RF_2T4R) {
-				priv->CCKPresentAttentuation_difference
-					= priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default;
+				p->CCKPresentAttentuation_difference =
+					p->rfa_txpowertrackingindex -
+					p->rfa_txpowertracking_default;
 			} else {
-				priv->CCKPresentAttentuation_difference
-					= priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default;
+				p->CCKPresentAttentuation_difference =
+					p->rfa_txpowertrackingindex_real -
+					p->rfa_txpowertracking_default;
 			}
 
-			if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
-				priv->CCKPresentAttentuation =
-					 priv->CCKPresentAttentuation_20Mdefault +
-					 priv->CCKPresentAttentuation_difference;
+			if (p->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+				p->CCKPresentAttentuation =
+					p->CCKPresentAttentuation_20Mdefault+
+					p->CCKPresentAttentuation_difference;
 			else
-				priv->CCKPresentAttentuation =
-					 priv->CCKPresentAttentuation_40Mdefault +
-					 priv->CCKPresentAttentuation_difference;
-
-			if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1))
-				priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1;
-			if (priv->CCKPresentAttentuation < 0)
-				priv->CCKPresentAttentuation = 0;
-
-			if (priv->CCKPresentAttentuation > -1 &&
-			    priv->CCKPresentAttentuation < CCKTxBBGainTableLength) {
-				if (priv->rtllib->current_network.channel == 14 &&
-				    !priv->bcck_in_ch14) {
-					priv->bcck_in_ch14 = true;
-					dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
-				} else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) {
-					priv->bcck_in_ch14 = false;
-					dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+				p->CCKPresentAttentuation =
+					p->CCKPresentAttentuation_40Mdefault+
+					p->CCKPresentAttentuation_difference;
+
+			if (p->CCKPresentAttentuation >
+					(CCKTxBBGainTableLength-1))
+				p->CCKPresentAttentuation =
+						CCKTxBBGainTableLength-1;
+			if (p->CCKPresentAttentuation < 0)
+				p->CCKPresentAttentuation = 0;
+
+			if (p->CCKPresentAttentuation > -1 &&
+			    p->CCKPresentAttentuation <
+					CCKTxBBGainTableLength) {
+				if (rtl->current_network.channel == 14 &&
+				    !p->bcck_in_ch14) {
+					p->bcck_in_ch14 = true;
+					dm_cck_txpower_adjust(dev,
+							      p->bcck_in_ch14);
+				} else if (rtl->current_network.channel != 14 &&
+					   p->bcck_in_ch14) {
+					p->bcck_in_ch14 = false;
+					dm_cck_txpower_adjust(dev,
+							      p->bcck_in_ch14);
 				} else
-					dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+					dm_cck_txpower_adjust(dev,
+							      p->bcck_in_ch14);
 			}
 			RT_TRACE(COMP_POWER_TRACKING,
 				 "priv->rfa_txpowertrackingindex = %d\n",
-				 priv->rfa_txpowertrackingindex);
+				 p->rfa_txpowertrackingindex);
 			RT_TRACE(COMP_POWER_TRACKING,
 				 "priv->rfa_txpowertrackingindex_real = %d\n",
-				 priv->rfa_txpowertrackingindex_real);
+				 p->rfa_txpowertrackingindex_real);
 			RT_TRACE(COMP_POWER_TRACKING,
 				 "priv->CCKPresentAttentuation_difference = %d\n",
-				 priv->CCKPresentAttentuation_difference);
+				 p->CCKPresentAttentuation_difference);
 			RT_TRACE(COMP_POWER_TRACKING,
 				 "priv->CCKPresentAttentuation = %d\n",
-				 priv->CCKPresentAttentuation);
+				 p->CCKPresentAttentuation);
 
-			if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) {
-				priv->rtllib->bdynamic_txpower_enable = true;
+			if (p->CCKPresentAttentuation_difference <= -12 ||
+			    p->CCKPresentAttentuation_difference >= 24) {
+				rtl->bdynamic_txpower_enable = true;
 				write_nic_byte(dev, Pw_Track_Flag, 0);
 				write_nic_byte(dev, FW_Busy_Flag, 0);
-				RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
+				RT_TRACE(COMP_POWER_TRACKING,
+					 "tx power track--->limited\n");
 				return;
 			}
 
@@ -844,7 +858,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 		}
 		write_nic_byte(dev, FW_Busy_Flag, 0);
 	}
-	priv->rtllib->bdynamic_txpower_enable = true;
+	p->rtllib->bdynamic_txpower_enable = true;
 	write_nic_byte(dev, Pw_Track_Flag, 0);
 }
 
@@ -1228,23 +1242,32 @@ static void dm_bb_initialgain_restore(struct net_device *dev)
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
 	u32 bit_mask = 0x7f;
+	struct init_gain *igain = &priv->initgain_backup;
 
 	if (dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
 		return;
 
 	rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);
-	rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1);
-	rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1);
-	rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1);
-	rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1);
+	rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask,
+			 (u32)igain->xaagccore1);
+	rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask,
+			 (u32)igain->xbagccore1);
+	rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask,
+			 (u32)igain->xcagccore1);
+	rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask,
+			 (u32)igain->xdagccore1);
 	bit_mask  = bMaskByte2;
-	rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca);
-
-	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", priv->initgain_backup.xaagccore1);
-	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", priv->initgain_backup.xbagccore1);
-	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", priv->initgain_backup.xcagccore1);
-	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", priv->initgain_backup.xdagccore1);
-	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", priv->initgain_backup.cca);
+	rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)igain->cca);
+
+	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",
+		 igain->xaagccore1);
+	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",
+		 igain->xbagccore1);
+	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",
+		 igain->xcagccore1);
+	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",
+		 igain->xdagccore1);
+	RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", igain->cca);
 	rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1);
 
 }
@@ -1265,23 +1288,32 @@ static void dm_bb_initialgain_backup(struct net_device *dev)
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
 	u32 bit_mask = bMaskByte0;
+	struct init_gain *igain = &priv->initgain_backup;
 
 	if (dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
 		return;
 
 	rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);
-	priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bit_mask);
-	priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bit_mask);
-	priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bit_mask);
-	priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bit_mask);
+	igain->xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1,
+						   bit_mask);
+	igain->xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1,
+						   bit_mask);
+	igain->xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1,
+						   bit_mask);
+	igain->xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1,
+						   bit_mask);
 	bit_mask  = bMaskByte2;
-	priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask);
-
-	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", priv->initgain_backup.xaagccore1);
-	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", priv->initgain_backup.xbagccore1);
-	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", priv->initgain_backup.xcagccore1);
-	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", priv->initgain_backup.xdagccore1);
-	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", priv->initgain_backup.cca);
+	igain->cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask);
+
+	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",
+		 igain->xaagccore1);
+	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",
+		 igain->xbagccore1);
+	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",
+		 igain->xcagccore1);
+	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",
+		 igain->xdagccore1);
+	RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", igain->cca);
 
 }
 
@@ -1712,7 +1744,8 @@ static	void dm_cs_ratio(struct net_device *dev)
 		if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) {
 			if (dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)
 				dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
-			else if (dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh)
+			else if (dm_digtable.rssi_val >=
+				 dm_digtable.rssi_high_thresh)
 				dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER;
 			else
 				dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state;
@@ -1759,6 +1792,7 @@ static void dm_check_edca_turbo(struct net_device *dev)
 	static unsigned long lastRxOkCnt;
 	unsigned long curTxOkCnt = 0;
 	unsigned long curRxOkCnt = 0;
+	u8 peer = pHTInfo->IOTPeer;
 
 	if (priv->rtllib->iw_mode == IW_MODE_ADHOC)
 		goto dm_CheckEdcaTurbo_EXIT;
@@ -1778,7 +1812,7 @@ static void dm_check_edca_turbo(struct net_device *dev)
 		if (wb_tmp == 0) {
 			netdev_info(dev,
 				    "%s():iot peer is %s, bssid: %pM\n",
-				    __func__, peername[pHTInfo->IOTPeer],
+				    __func__, peername[peer],
 				    priv->rtllib->current_network.bssid);
 			wb_tmp = 1;
 		}
@@ -1791,38 +1825,45 @@ static void dm_check_edca_turbo(struct net_device *dev)
 				if (priv->bis_cur_rdlstate ||
 				    !priv->bcurrent_turbo_EDCA) {
 					write_nic_dword(dev, EDCAPARA_BE,
-						 edca_setting_UL[pHTInfo->IOTPeer]);
+							edca_setting_UL[peer]);
 					priv->bis_cur_rdlstate = false;
 				}
 			} else {
 				if (!priv->bis_cur_rdlstate ||
 				    !priv->bcurrent_turbo_EDCA) {
-					if (priv->rtllib->mode == WIRELESS_MODE_G)
-						write_nic_dword(dev, EDCAPARA_BE,
-							 edca_setting_DL_GMode[pHTInfo->IOTPeer]);
+					if (priv->rtllib->mode ==
+					    WIRELESS_MODE_G)
+						write_nic_dword(dev,
+								EDCAPARA_BE,
+						   edca_setting_DL_GMode[peer]);
 					else
-						write_nic_dword(dev, EDCAPARA_BE,
-							 edca_setting_DL[pHTInfo->IOTPeer]);
+						write_nic_dword(dev,
+								EDCAPARA_BE,
+							 edca_setting_DL[peer]);
 					priv->bis_cur_rdlstate = true;
 				}
 			}
 			priv->bcurrent_turbo_EDCA = true;
 		} else {
 			if (curRxOkCnt > 4*curTxOkCnt) {
-				if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) {
-					if (priv->rtllib->mode == WIRELESS_MODE_G)
-						write_nic_dword(dev, EDCAPARA_BE,
-							 edca_setting_DL_GMode[pHTInfo->IOTPeer]);
+				if (!priv->bis_cur_rdlstate ||
+				    !priv->bcurrent_turbo_EDCA) {
+					if (priv->rtllib->mode ==
+							WIRELESS_MODE_G)
+						write_nic_dword(dev,
+								EDCAPARA_BE,
+						   edca_setting_DL_GMode[peer]);
 					else
-						write_nic_dword(dev, EDCAPARA_BE,
-							 edca_setting_DL[pHTInfo->IOTPeer]);
+						write_nic_dword(dev,
+								EDCAPARA_BE,
+							 edca_setting_DL[peer]);
 					priv->bis_cur_rdlstate = true;
 				}
 			} else {
 				if (priv->bis_cur_rdlstate ||
 				    !priv->bcurrent_turbo_EDCA) {
 					write_nic_dword(dev, EDCAPARA_BE,
-							edca_setting_UL[pHTInfo->IOTPeer]);
+							edca_setting_UL[peer]);
 					priv->bis_cur_rdlstate = false;
 				}
 
@@ -2239,18 +2280,19 @@ void dm_fsync_timer_callback(unsigned long data)
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct r8192_priv *priv = rtllib_priv((struct net_device *)data);
+	struct rtllib_device *rtl = priv->rtllib;
 	u32 rate_index, rate_count = 0, rate_count_diff = 0;
 	bool		bSwitchFromCountDiff = false;
 	bool		bDoubleTimeInterval = false;
 
-	if (priv->rtllib->state == RTLLIB_LINKED &&
-	    priv->rtllib->bfsync_enable &&
-	    (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) {
+	if (rtl->state == RTLLIB_LINKED &&
+	    rtl->bfsync_enable &&
+	    (rtl->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) {
 		u32 rate_bitmap;
 
 		for (rate_index = 0; rate_index <= 27; rate_index++) {
 			rate_bitmap  = 1 << rate_index;
-			if (priv->rtllib->fsync_rate_bitmap &  rate_bitmap)
+			if (rtl->fsync_rate_bitmap & rate_bitmap)
 				rate_count +=
 				   priv->stats.received_rate_histogram[1]
 				   [rate_index];
@@ -2265,8 +2307,7 @@ void dm_fsync_timer_callback(unsigned long data)
 
 			u32 DiffNum = priv->rateCountDiffRecord -
 				      rate_count_diff;
-			if (DiffNum >=
-			    priv->rtllib->fsync_seconddiff_ratethreshold)
+			if (DiffNum >= rtl->fsync_seconddiff_ratethreshold)
 				priv->ContinueDiffCount++;
 			else
 				priv->ContinueDiffCount = 0;
@@ -2279,8 +2320,7 @@ void dm_fsync_timer_callback(unsigned long data)
 			priv->ContinueDiffCount = 0;
 		}
 
-		if (rate_count_diff <=
-		    priv->rtllib->fsync_firstdiff_ratethreshold) {
+		if (rate_count_diff <= rtl->fsync_firstdiff_ratethreshold) {
 			bSwitchFromCountDiff = true;
 			priv->ContinueDiffCount = 0;
 		}
@@ -2290,9 +2330,8 @@ void dm_fsync_timer_callback(unsigned long data)
 			 "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n",
 			 priv->rate_record, rate_count, rate_count_diff,
 			 priv->bswitch_fsync);
-		if (priv->undecorated_smoothed_pwdb >
-		    priv->rtllib->fsync_rssi_threshold &&
-		    bSwitchFromCountDiff) {
+		if (priv->undecorated_smoothed_pwdb > rtl->fsync_rssi_threshold
+		    && bSwitchFromCountDiff) {
 			bDoubleTimeInterval = true;
 			priv->bswitch_fsync = !priv->bswitch_fsync;
 			if (priv->bswitch_fsync) {
@@ -2303,7 +2342,7 @@ void dm_fsync_timer_callback(unsigned long data)
 				write_nic_byte(dev, 0xC3e, 0x96);
 			}
 		} else if (priv->undecorated_smoothed_pwdb <=
-			   priv->rtllib->fsync_rssi_threshold) {
+			   rtl->fsync_rssi_threshold) {
 			if (priv->bswitch_fsync) {
 				priv->bswitch_fsync  = false;
 				write_nic_byte(dev, 0xC36, 0x5c);
@@ -2314,14 +2353,14 @@ void dm_fsync_timer_callback(unsigned long data)
 			if (timer_pending(&priv->fsync_timer))
 				del_timer_sync(&priv->fsync_timer);
 			priv->fsync_timer.expires = jiffies +
-				 msecs_to_jiffies(priv->rtllib->fsync_time_interval *
-				 priv->rtllib->fsync_multiple_timeinterval);
+				 msecs_to_jiffies(rtl->fsync_time_interval *
+				 rtl->fsync_multiple_timeinterval);
 			add_timer(&priv->fsync_timer);
 		} else {
 			if (timer_pending(&priv->fsync_timer))
 				del_timer_sync(&priv->fsync_timer);
 			priv->fsync_timer.expires = jiffies +
-				 msecs_to_jiffies(priv->rtllib->fsync_time_interval);
+				 msecs_to_jiffies(rtl->fsync_time_interval);
 			add_timer(&priv->fsync_timer);
 		}
 	} else {
@@ -2385,35 +2424,35 @@ static void dm_EndSWFsync(struct net_device *dev)
 
 static void dm_StartSWFsync(struct net_device *dev)
 {
-	struct r8192_priv *priv = rtllib_priv(dev);
+	struct r8192_priv *p = rtllib_priv(dev);
+	struct rtllib_device *rtl = p->rtllib;
 	u32			rateIndex;
 	u32			rateBitmap;
 
 	RT_TRACE(COMP_HALDM, "%s\n", __func__);
-	priv->rate_record = 0;
-	priv->ContinueDiffCount = 0;
-	priv->rateCountDiffRecord = 0;
-	priv->bswitch_fsync  = false;
-
-	if (priv->rtllib->mode == WIRELESS_MODE_N_24G) {
-		priv->rtllib->fsync_firstdiff_ratethreshold = 600;
-		priv->rtllib->fsync_seconddiff_ratethreshold = 0xffff;
+	p->rate_record = 0;
+	p->ContinueDiffCount = 0;
+	p->rateCountDiffRecord = 0;
+	p->bswitch_fsync  = false;
+
+	if (rtl->mode == WIRELESS_MODE_N_24G) {
+		rtl->fsync_firstdiff_ratethreshold = 600;
+		rtl->fsync_seconddiff_ratethreshold = 0xffff;
 	} else {
-		priv->rtllib->fsync_firstdiff_ratethreshold = 200;
-		priv->rtllib->fsync_seconddiff_ratethreshold = 200;
+		rtl->fsync_firstdiff_ratethreshold = 200;
+		rtl->fsync_seconddiff_ratethreshold = 200;
 	}
 	for (rateIndex = 0; rateIndex <= 27; rateIndex++) {
 		rateBitmap  = 1 << rateIndex;
-		if (priv->rtllib->fsync_rate_bitmap & rateBitmap)
-			priv->rate_record +=
-				 priv->stats.received_rate_histogram[1]
-				[rateIndex];
-	}
-	if (timer_pending(&priv->fsync_timer))
-		del_timer_sync(&priv->fsync_timer);
-	priv->fsync_timer.expires = jiffies +
-				    msecs_to_jiffies(priv->rtllib->fsync_time_interval);
-	add_timer(&priv->fsync_timer);
+		if (rtl->fsync_rate_bitmap & rateBitmap)
+			p->rate_record +=
+				p->stats.received_rate_histogram[1][rateIndex];
+	}
+	if (timer_pending(&p->fsync_timer))
+		del_timer_sync(&p->fsync_timer);
+	p->fsync_timer.expires = jiffies +
+				    msecs_to_jiffies(rtl->fsync_time_interval);
+	add_timer(&p->fsync_timer);
 
 	write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd);
 
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 64b21b8..2ae4a3f 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1721,7 +1721,7 @@ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element
 		struct rtllib_qos_parameter_info param_element;
 
 		rc = rtllib_read_qos_param_element(&param_element,
-						      info_element);
+						   info_element);
 		if (rc == 0) {
 			rtllib_qos_convert_ac_to_parameters(&param_element,
 							       &(network->qos_data));
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 511565d..3c62638 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -403,9 +403,12 @@ static void rtllib_send_beacon(struct rtllib_device *ieee)
 		ieee->softmac_stats.tx_beacons++;
 	}
 
-	if (ieee->beacon_txing && ieee->ieee_up)
-		mod_timer(&ieee->beacon_timer, jiffies +
-			  (msecs_to_jiffies(ieee->current_network.beacon_interval - 5)));
+	if (ieee->beacon_txing && ieee->ieee_up) {
+		unsigned long e = jiffies;
+
+		e += msecs_to_jiffies(ieee->current_network.beacon_interval-5);
+		mod_timer(&ieee->beacon_timer, e);
+	}
 }
 
 
@@ -598,6 +601,7 @@ static void rtllib_softmac_scan_wq(void *data)
 {
 	struct rtllib_device *ieee = container_of_dwork_rsl(data,
 				     struct rtllib_device, softmac_scan_wq);
+	u8 *channel = &ieee->current_network.channel;
 	u8 last_channel = ieee->current_network.channel;
 
 	rtllib_update_active_chan_map(ieee);
@@ -617,22 +621,20 @@ static void rtllib_softmac_scan_wq(void *data)
 	}
 
 	do {
-		ieee->current_network.channel =
-			(ieee->current_network.channel + 1) %
-			MAX_CHANNEL_NUMBER;
+		*channel = (*channel + 1) % MAX_CHANNEL_NUMBER;
 		if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) {
-			if (!ieee->active_channel_map[ieee->current_network.channel])
-				ieee->current_network.channel = 6;
+			if (!ieee->active_channel_map[*channel])
+				*channel = 6;
 			goto out; /* no good chans */
 		}
-	} while (!ieee->active_channel_map[ieee->current_network.channel]);
+	} while (!ieee->active_channel_map[*channel]);
 
 	if (ieee->scanning_continue == 0)
 		goto out;
 
-	ieee->set_chan(ieee->dev, ieee->current_network.channel);
+	ieee->set_chan(ieee->dev, *channel);
 
-	if (ieee->active_channel_map[ieee->current_network.channel] == 1)
+	if (ieee->active_channel_map[*channel] == 1)
 		rtllib_send_probe_requests(ieee, 0);
 
 	queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq,
@@ -644,7 +646,7 @@ static void rtllib_softmac_scan_wq(void *data)
 out:
 	if (IS_DOT11D_ENABLE(ieee))
 		DOT11D_ScanComplete(ieee);
-	ieee->current_network.channel = last_channel;
+	*channel = last_channel;
 
 out1:
 	ieee->actscanning = false;
@@ -2000,17 +2002,18 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
 	u8 dtim;
 	struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
 					(&(ieee->PowerSaveControl));
+	struct rtllib_network *cnet = &ieee->current_network;
 
 	if (ieee->LPSDelayCnt) {
 		ieee->LPSDelayCnt--;
 		return 0;
 	}
 
-	dtim = ieee->current_network.dtim_data;
+	dtim = cnet->dtim_data;
 	if (!(dtim & RTLLIB_DTIM_VALID))
 		return 0;
-	timeout = ieee->current_network.beacon_interval;
-	ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID;
+	timeout = cnet->beacon_interval;
+	cnet->dtim_data = RTLLIB_DTIM_INVALID;
 	/* there's no need to nofity AP that I find you buffered
 	 * with broadcast packet
 	 */
@@ -2038,7 +2041,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
 			if (pPSC->RegMaxLPSAwakeIntvl == 0)
 				MaxPeriod = 1;
 			else if (pPSC->RegMaxLPSAwakeIntvl == 0xFF)
-				MaxPeriod = ieee->current_network.dtim_period;
+				MaxPeriod = cnet->dtim_period;
 			else
 				MaxPeriod = pPSC->RegMaxLPSAwakeIntvl;
 			pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >=
@@ -2047,8 +2050,8 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
 		}
 		{
 			u8 LPSAwakeIntvl_tmp = 0;
-			u8 period = ieee->current_network.dtim_period;
-			u8 count = ieee->current_network.tim.tim_count;
+			u8 period = cnet->dtim_period;
+			u8 count = cnet->tim.tim_count;
 
 			if (count == 0) {
 				if (pPSC->LPSAwakeIntvl > period)
@@ -2061,19 +2064,18 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
 					LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;
 
 			} else {
-				if (pPSC->LPSAwakeIntvl >
-				    ieee->current_network.tim.tim_count)
-					LPSAwakeIntvl_tmp = count +
-					(pPSC->LPSAwakeIntvl - count) -
-					((pPSC->LPSAwakeIntvl-count)%period);
+				if (pPSC->LPSAwakeIntvl > cnet->tim.tim_count)
+					LPSAwakeIntvl_tmp =
+							pPSC->LPSAwakeIntvl -
+					((pPSC->LPSAwakeIntvl - count) % period);
 				else
 					LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;
 			}
 
-		*time = ieee->current_network.last_dtim_sta_time
-			+ msecs_to_jiffies(ieee->current_network.beacon_interval *
-			LPSAwakeIntvl_tmp);
-	}
+			*time = cnet->last_dtim_sta_time +
+					msecs_to_jiffies(cnet->beacon_interval *
+							 LPSAwakeIntvl_tmp);
+		}
 	}
 
 	return 1;
@@ -2691,6 +2693,7 @@ static void rtllib_start_ibss_wq(void *data)
 {
 	struct rtllib_device *ieee = container_of_dwork_rsl(data,
 				     struct rtllib_device, start_ibss_wq);
+	struct rtllib_network *current_net = &ieee->current_network;
 	/* iwconfig mode ad-hoc will schedule this and return
 	 * on the other hand this will block further iwconfig SET
 	 * operations because of the wx_sem hold.
@@ -2704,9 +2707,9 @@ static void rtllib_start_ibss_wq(void *data)
 	}
 	down(&ieee->wx_sem);
 
-	if (ieee->current_network.ssid_len == 0) {
-		strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID);
-		ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID);
+	if (current_net->ssid_len == 0) {
+		strcpy(current_net->ssid, RTLLIB_DEFAULT_TX_ESSID);
+		current_net->ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID);
 		ieee->ssid_set = 1;
 	}
 
@@ -2736,57 +2739,49 @@ static void rtllib_start_ibss_wq(void *data)
 	/* the network definitively is not here.. create a new cell */
 	if (ieee->state == RTLLIB_NOLINK) {
 		netdev_info(ieee->dev, "creating new IBSS cell\n");
-		ieee->current_network.channel = ieee->IbssStartChnl;
+		current_net->channel = ieee->IbssStartChnl;
 		if (!ieee->wap_set)
 			rtllib_randomize_cell(ieee);
 
 		if (ieee->modulation & RTLLIB_CCK_MODULATION) {
 
-			ieee->current_network.rates_len = 4;
+			current_net->rates_len = 4;
 
-			ieee->current_network.rates[0] =
-				 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB;
-			ieee->current_network.rates[1] =
-				 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB;
-			ieee->current_network.rates[2] =
-				 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB;
-			ieee->current_network.rates[3] =
-				 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB;
+			current_net->rates[0] = RTLLIB_BASIC_RATE_MASK |
+						RTLLIB_CCK_RATE_1MB;
+			current_net->rates[1] = RTLLIB_BASIC_RATE_MASK |
+						RTLLIB_CCK_RATE_2MB;
+			current_net->rates[2] = RTLLIB_BASIC_RATE_MASK |
+						RTLLIB_CCK_RATE_5MB;
+			current_net->rates[3] = RTLLIB_BASIC_RATE_MASK |
+						RTLLIB_CCK_RATE_11MB;
 
 		} else
-			ieee->current_network.rates_len = 0;
+			current_net->rates_len = 0;
 
 		if (ieee->modulation & RTLLIB_OFDM_MODULATION) {
-			ieee->current_network.rates_ex_len = 8;
-
-			ieee->current_network.rates_ex[0] =
-						 RTLLIB_OFDM_RATE_6MB;
-			ieee->current_network.rates_ex[1] =
-						 RTLLIB_OFDM_RATE_9MB;
-			ieee->current_network.rates_ex[2] =
-						 RTLLIB_OFDM_RATE_12MB;
-			ieee->current_network.rates_ex[3] =
-						 RTLLIB_OFDM_RATE_18MB;
-			ieee->current_network.rates_ex[4] =
-						 RTLLIB_OFDM_RATE_24MB;
-			ieee->current_network.rates_ex[5] =
-						 RTLLIB_OFDM_RATE_36MB;
-			ieee->current_network.rates_ex[6] =
-						 RTLLIB_OFDM_RATE_48MB;
-			ieee->current_network.rates_ex[7] =
-						 RTLLIB_OFDM_RATE_54MB;
+			current_net->rates_ex_len = 8;
+
+			current_net->rates_ex[0] = RTLLIB_OFDM_RATE_6MB;
+			current_net->rates_ex[1] = RTLLIB_OFDM_RATE_9MB;
+			current_net->rates_ex[2] = RTLLIB_OFDM_RATE_12MB;
+			current_net->rates_ex[3] = RTLLIB_OFDM_RATE_18MB;
+			current_net->rates_ex[4] = RTLLIB_OFDM_RATE_24MB;
+			current_net->rates_ex[5] = RTLLIB_OFDM_RATE_36MB;
+			current_net->rates_ex[6] = RTLLIB_OFDM_RATE_48MB;
+			current_net->rates_ex[7] = RTLLIB_OFDM_RATE_54MB;
 
 			ieee->rate = 108;
 		} else {
-			ieee->current_network.rates_ex_len = 0;
+			current_net->rates_ex_len = 0;
 			ieee->rate = 22;
 		}
 
-		ieee->current_network.qos_data.supported = 0;
+		current_net->qos_data.supported = 0;
 		ieee->SetWirelessMode(ieee->dev, IEEE_G);
-		ieee->current_network.mode = ieee->mode;
-		ieee->current_network.atim_window = 0;
-		ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
+		current_net->mode = ieee->mode;
+		current_net->atim_window = 0;
+		current_net->capability = WLAN_CAPABILITY_IBSS;
 	}
 
 	netdev_info(ieee->dev, "%s(): ieee->mode = %d\n", __func__, ieee->mode);
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index 2280332..1f2a3ab 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -326,8 +326,12 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
 			}
 			goto FORCED_AGG_SETTING;
 		} else if (pTxTs->bUsingBa == false) {
-			if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum,
-			   (pTxTs->TxCurSeq+1)%4096))
+			union sequence_control *seq_ctl;
+
+			seq_ctl = &pTxTs->TxAdmittedBARecord.BaStartSeqCtrl;
+
+			if (SN_LESS(seq_ctl->field.SeqNum,
+				    (pTxTs->TxCurSeq+1) % 4096))
 				pTxTs->bUsingBa = true;
 			else
 				goto FORCED_AGG_SETTING;
@@ -567,6 +571,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 {
 	struct rtllib_device *ieee = (struct rtllib_device *)
 				     netdev_priv_rsl(dev);
+	struct rtllib_network *curr_net = &ieee->current_network;
 	struct rtllib_txb *txb = NULL;
 	struct rtllib_hdr_3addrqos *frag_hdr;
 	int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
@@ -581,7 +586,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 		.qos_ctl = 0
 	};
 	u8 dest[ETH_ALEN], src[ETH_ALEN];
-	int qos_actived = ieee->current_network.qos_data.active;
+	int qos_actived = curr_net->qos_data.active;
 	struct lib80211_crypt_data *crypt = NULL;
 	struct cb_desc *tcb_desc;
 	u8 bIsMulticast = false;
@@ -652,8 +657,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 				netdev_info(ieee->dev,
 					    "=================>DHCP Protocol start tx ARP pkt!!\n");
 				bdhcp = true;
-				ieee->LPSDelayCnt =
-					 ieee->current_network.tim.tim_count;
+				ieee->LPSDelayCnt = curr_net->tim.tim_count;
 			}
 		}
 
@@ -696,11 +700,11 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 			 * Addr3 = DA
 			 */
 			ether_addr_copy_unaligned(&header.addr1,
-						  ieee->current_network.bssid);
+						  curr_net->bssid);
 			ether_addr_copy_unaligned(&header.addr2, &src);
 			if (IsAmsdu)
 				ether_addr_copy_unaligned(&header.addr3,
-							  ieee->current_network.bssid);
+							  curr_net->bssid);
 			else
 				ether_addr_copy_unaligned(&header.addr3, &dest);
 		} else if (ieee->iw_mode == IW_MODE_ADHOC) {
@@ -710,7 +714,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 			ether_addr_copy_unaligned(&header.addr1, dest);
 			ether_addr_copy_unaligned(&header.addr2, src);
 			ether_addr_copy_unaligned(&header.addr3,
-						  ieee->current_network.bssid);
+						  curr_net->bssid);
 		}
 
 		bIsMulticast = is_multicast_ether_addr(header.addr1);
@@ -833,11 +837,9 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 				bytes = bytes_last_frag;
 			}
 			if ((qos_actived) && (!bIsMulticast)) {
-				frag_hdr->seq_ctl =
-					 cpu_to_le16(rtllib_query_seqnum(ieee, skb_frag,
-							     header.addr1));
-				frag_hdr->seq_ctl =
-					 cpu_to_le16(le16_to_cpu(frag_hdr->seq_ctl)<<4 | i);
+				u16 t  = rtllib_query_seqnum(ieee, skb_frag,
+							     header.addr1);
+				frag_hdr->seq_ctl = cpu_to_le16(t << 4 | i);
 			} else {
 				frag_hdr->seq_ctl =
 					 cpu_to_le16(ieee->seq_ctrl[0]<<4 | i);
-- 
1.8.4.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel





[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux