linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 00/16] staging: rtl8192u: code clean up
@ 2015-09-11  7:29 Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte
                   ` (31 more replies)
  0 siblings, 32 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Paul Gortmaker,
	Cristina Opriceana, Andy Shevchenko, Ragnar B. Johannsson,
	Joe Perches, Marti Bolivar, Greg Donald, Ksenija Stanojevic,
	Arnd Bergmann, Luis de Bethencourt, Aya Mahfouz, Haneen Mohammed,
	Somya Anand, Rene Kolarik, Vaishali Thakkar, Melike Yurtoglu,
	Hatice ERTÜRK, devel, linux-kernel

Hi,

Following comments from Dan Carpenter on my previous patch to
limit the lines lengths for rtl8192u/r8192U_core.c [1], please
find attached a set of patches splitting those operations.

I also took care of keeping the code the more readable possible,
some of those patchs even aim to clean the original content.

The last patch gets rid of the last WARNING of checkpatch about
the 80 lines, as well as the TO_DO_LIST macro that was used in
that module to comment out unused or unusable code.

Thanks,
- R.

[1]: https://lkml.org/lkml/2015/8/19/173


Raphaël Beamonte (16):
  staging: rtl8192u: r8192U_core: fix comments lines over 80 characters
  staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80
    characters
  staging: rtl8192u: r8192U_core: add temporary variables to keep lines
    under 80 characters
  staging: rtl8192u: r8192U_core: reverse conditions to get lines under
    80 characters
  staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize
    function
  staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize
    function
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable pprevious_stats to prev_stats
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable slide_beacon_adc_pwdb_index to sb_index
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable slide_beacon_adc_pwdb_statistics to sb_stats
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove
    unneeded variable
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable rfpath to rfp
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize
    function
  staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline
    conditions
  staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function
  staging: rtl8192u: r8192U_core: replace else { if() {} } by else if ()
    {}
  staging: rtl8192u: remove all code framed by symbol TO_DO_LIST

 drivers/staging/rtl8192u/ieee80211/ieee80211.h     |    4 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |   23 -
 .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c    |    4 -
 .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c    |    5 +-
 drivers/staging/rtl8192u/r8192U_core.c             | 1548 ++++++++++++--------
 drivers/staging/rtl8192u/r819xU_phy.c              |   57 -
 6 files changed, 940 insertions(+), 701 deletions(-)

-- 
2.5.1


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under " Raphaël Beamonte
                   ` (30 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Move, replace and reorganize comments to stay under 80 characters
per line, as to follow the kernel code style. Some unuseful comments
have been removed.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 232 ++++++++++++++++++++++-----------
 1 file changed, 153 insertions(+), 79 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index b143b36..5e9d0ac 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -143,17 +143,28 @@ struct CHANNEL_LIST {
 };
 
 static struct CHANNEL_LIST ChannelPlan[] = {
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24},	/* FCC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},								/* IC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21},			/* ETSI */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},							/* Spain. Change to ETSI. */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},							/* France. Change to ETSI. */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},			/* MKK */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},			/* MKK1 */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},							/* Israel. */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},			/* For 11a , TELEC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},			/* MIC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}	/* For Global Domain. 1-11:active scan, 12-14 passive scan. */
+	/* FCC */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24},
+	/* IC */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},
+	/* ETSI */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21},
+	/* Spain. Change to ETSI. */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
+	/* France. Change to ETSI. */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
+	/* MKK */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	/* MKK1 */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	/* Israel. */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
+	/* For 11a , TELEC */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	/* MIC */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	/* For Global Domain. 1-11:active scan, 12-14 passive scan. */
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}
 };
 
 static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
@@ -194,7 +205,10 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 		break;
 
 	case COUNTRY_CODE_GLOBAL_DOMAIN:
-		GET_DOT11D_INFO(ieee)->bEnabled = 0; /* this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings. */
+		/* this flag enabled to follow 11d country IE setting,
+		 * otherwise, it shall follow global domain settings.
+		 */
+		GET_DOT11D_INFO(ieee)->bEnabled = 0;
 		Dot11d_Reset(ieee);
 		ieee->bGlobalDomain = true;
 		break;
@@ -210,9 +224,11 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 static void CamResetAllEntry(struct net_device *dev)
 {
 	u32 ulcommand = 0;
-	/* 2004/02/11  In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA associate to AP.
-	 *  However, ResetKey is called on OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest
-	 *  In this condition, Cam can not be reset because upper layer will not set this static key again.
+	/* In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA
+	 * associate to AP. However, ResetKey is called on
+	 * OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest. In this
+	 * condition, Cam can not be reset because upper layer will not set
+	 * this static key again.
 	 */
 	ulcommand |= BIT31 | BIT30;
 	write_nic_dword(dev, RWCAM, ulcommand);
@@ -1039,8 +1055,9 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 	 *
 	 * Caution:
 	 * Handling the wait queue of command packets.
-	 * For Tx command packets, we must not do TCB fragment because it is not handled right now.
-	 * We must cut the packets to match the size of TX_CMD_PKT before we send it.
+	 * For Tx command packets, we must not do TCB fragment because it is
+	 * not handled right now. We must cut the packets to match the size of
+	 * TX_CMD_PKT before we send it.
 	 */
 
 	/* Handle MPDU in wait queue. */
@@ -1169,9 +1186,10 @@ static void rtl8192_update_cap(struct net_device *dev, u16 cap)
 	if (net->mode & (IEEE_G | IEEE_N_24G)) {
 		u8 slot_time = 0;
 
-		if ((cap & WLAN_CAPABILITY_SHORT_SLOT) && (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) /* short slot time */
+		if ((cap & WLAN_CAPABILITY_SHORT_SLOT) && (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
+			/* short slot time */
 			slot_time = SHORT_SLOT_TIME;
-		else /* long slot time */
+		else	/* long slot time */
 			slot_time = NON_SHORT_SLOT_TIME;
 		priv->slot_time = slot_time;
 		write_nic_byte(dev, SLOT_TIME, slot_time);
@@ -1297,9 +1315,9 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 	pdesc->OWN = 1;
 	pdesc->LINIP = tcb_desc->bLastIniPkt;
 
-	/*----------------------------------------------------------------------------
+	/*---------------------------------------------------------------------
 	 * Fill up USB_OUT_CONTEXT.
-	 *----------------------------------------------------------------------------
+	 *---------------------------------------------------------------------
 	 */
 	idx_pipe = 0x04;
 	usb_fill_bulk_urb(tx_urb, priv->udev, usb_sndbulkpipe(priv->udev, idx_pipe),
@@ -1349,7 +1367,7 @@ static u8 MapHwQueueToFirmwareQueue(u8 QueueID)
 		QueueSelect = QSLT_BEACON;
 		break;
 
-		/* TODO: 2006.10.30 mark other queue selection until we verify it is OK */
+		/* TODO: mark other queue selection until we verify it is OK */
 		/* TODO: Remove Assertions */
 	case TXCMD_QUEUE:
 		QueueSelect = QSLT_CMD;
@@ -1551,7 +1569,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) {
 		if (tcb_desc->bPacketBW) {
 			tx_fwinfo->TxBandwidth = 1;
-			tx_fwinfo->TxSubCarrier = 0;    /* use duplicated mode */
+			/* use duplicated mode */
+			tx_fwinfo->TxSubCarrier = 0;
 		} else {
 			tx_fwinfo->TxBandwidth = 0;
 			tx_fwinfo->TxSubCarrier = priv->nCur40MhzPrimeSC;
@@ -1602,7 +1621,9 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack;
 	tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate;
 
-	/* Fill fields that are required to be initialized in all of the descriptors */
+	/* Fill fields that are required to be initialized in
+	 * all of the descriptors
+	 */
 	/* DWORD 0 */
 	tx_desc->FirstSeg = 1;
 	tx_desc->LastSeg = 1;
@@ -1838,9 +1859,13 @@ static void rtl8192_qos_activate(struct work_struct *work)
 	if (priv->ieee80211->state != IEEE80211_LINKED)
 		goto success;
 	RT_TRACE(COMP_QOS, "qos active process with associate response received\n");
-	/* It better set slot time at first */
-	/* For we just support b/g mode at present, let the slot time at 9/20 selection */
-	/* update the ac parameter to related registers */
+	/* It better set slot time at first
+	 *
+	 * For we just support b/g mode at present, let the slot time at
+	 * 9/20 selection
+	 *
+	 * update the ac parameter to related registers
+	 */
 	for (i = 0; i <  QOS_QUEUE_NUM; i++) {
 		/* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
 		u1bAIFS = qos_parameters->aifs[i] * ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20) + aSifsTime;
@@ -2115,7 +2140,10 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 			wireless_mode = WIRELESS_MODE_B;
 		}
 	}
-#ifdef TO_DO_LIST /* TODO: this function doesn't work well at this time, we should wait for FPGA */
+#ifdef TO_DO_LIST
+	/* TODO: this function doesn't work well at this time,
+	 * we should wait for FPGA
+	 */
 	ActUpdateChannelAccessSetting(pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
 #endif
 	priv->ieee80211->mode = wireless_mode;
@@ -2153,7 +2181,8 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 	priv->bDisableNormalResetCheck = false;
 	priv->force_reset = false;
 
-	priv->ieee80211->FwRWRF = 0;	/* we don't use FW read/write RF until stable firmware is available. */
+	/* we don't use FW read/write RF until stable firmware is available. */
+	priv->ieee80211->FwRWRF = 0;
 	priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
 	priv->ieee80211->softmac_features  = IEEE_SOFTMAC_SCAN |
 		IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
@@ -2199,29 +2228,54 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 	priv->EarlyRxThreshold = 7;
 	priv->enable_gpio0 = 0;
 	priv->TransmitConfig =
-		(TCR_MXDMA_2048 << TCR_MXDMA_OFFSET)	  | /* Max DMA Burst Size per Tx DMA Burst, 7: reserved. */
-		(priv->ShortRetryLimit << TCR_SRL_OFFSET) | /* Short retry limit */
-		(priv->LongRetryLimit << TCR_LRL_OFFSET)  | /* Long retry limit */
-		(false ? TCR_SAT : 0);	/* FALSE: HW provides PLCP length and LENGEXT, TRUE: SW provides them */
+		/* Max DMA Burst Size per Tx DMA Burst, 7: reserved. */
+		(TCR_MXDMA_2048 << TCR_MXDMA_OFFSET)	  |
+		/* Short retry limit */
+		(priv->ShortRetryLimit << TCR_SRL_OFFSET) |
+		/* Long retry limit */
+		(priv->LongRetryLimit << TCR_LRL_OFFSET)  |
+		/* FALSE: HW provides PLCP length and LENGEXT
+		 * TRUE: SW provides them
+		 */
+		(false ? TCR_SAT : 0);
 #ifdef TO_DO_LIST
 	if (Adapter->bInHctTest)
 		pHalData->ReceiveConfig	=	pHalData->CSMethod |
-						RCR_AMF | RCR_ADF | /* accept management/data */
-						RCR_ACF | /* accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. */
-						RCR_AB | RCR_AM | RCR_APM | /* accept BC/MC/UC */
-						RCR_AICV | RCR_ACRC32 | /* accept ICV/CRC error packet */
-						((u32)7 << RCR_MXDMA_OFFSET) | /* Max DMA Burst Size per Tx DMA Burst, 7: unlimited. */
-						(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) | /* Rx FIFO Threshold, 7: No Rx threshold. */
+						/* accept management/data */
+						RCR_AMF | RCR_ADF |
+						/* accept control frame for SW
+						 * AP needs PS-poll
+						 */
+						RCR_ACF |
+						/* accept BC/MC/UC */
+						RCR_AB | RCR_AM | RCR_APM |
+						/* accept ICV/CRC error
+						 * packet
+						 */
+						RCR_AICV | RCR_ACRC32 |
+						/* Max DMA Burst Size per Tx
+						 * DMA Burst, 7: unlimited.
+						 */
+						((u32)7 << RCR_MXDMA_OFFSET) |
+						/* Rx FIFO Threshold,
+						 * 7: No Rx threshold.
+						 */
+						(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
 						(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
 	else
 
 #endif
 	priv->ReceiveConfig	=
-		RCR_AMF | RCR_ADF | /* accept management/data */
-		RCR_ACF | /* accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. */
-		RCR_AB | RCR_AM | RCR_APM | /* accept BC/MC/UC */
-		((u32)7 << RCR_MXDMA_OFFSET) | /* Max DMA Burst Size per Rx DMA Burst, 7: unlimited. */
-		(priv->EarlyRxThreshold << RX_FIFO_THRESHOLD_SHIFT) | /* Rx FIFO Threshold, 7: No Rx threshold. */
+		/* accept management/data */
+		RCR_AMF | RCR_ADF |
+		/* accept control frame for SW AP needs PS-poll */
+		RCR_ACF |
+		/* accept BC/MC/UC */
+		RCR_AB | RCR_AM | RCR_APM |
+		/* Max DMA Burst Size per Rx DMA Burst, 7: unlimited. */
+		((u32)7 << RCR_MXDMA_OFFSET) |
+		/* Rx FIFO Threshold, 7: No Rx threshold. */
+		(priv->EarlyRxThreshold << RX_FIFO_THRESHOLD_SHIFT) |
 		(priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT : 0);
 
 	priv->AcmControl = 0;
@@ -2786,7 +2840,8 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 			 */
 			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
 				PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
-		} else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) { /* H/W or S/W RF OFF before sleep. */
+		} else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) {
+			/* H/W or S/W RF OFF before sleep. */
 			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", pMgntInfo->RfOffReason));
 			MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
 		} else {
@@ -2995,17 +3050,18 @@ static RESET_TYPE RxCheckStuck(struct net_device *dev)
 
 
 /**
-*	This function is called by Checkforhang to check whether we should ask OS to reset driver
-*
-*	\param pAdapter	The adapter context for this miniport
-*
-*	Note:NIC with USB interface sholud not call this function because we cannot scan descriptor
-*	to judge whether there is tx stuck.
-*	Note: This function may be required to be rewrite for Vista OS.
-*	<<<Assumption: Tx spinlock has been acquired >>>
-*
-*	8185 and 8185b does not implement this function. This is added by Emily at 2006.11.24
-*/
+ * This function is called by Checkforhang to check whether we should
+ * ask OS to reset driver
+ *
+ * \param pAdapter	The adapter context for this miniport
+ *
+ * Note:NIC with USB interface sholud not call this function because we
+ * cannot scan descriptor to judge whether there is tx stuck.
+ * Note: This function may be required to be rewrite for Vista OS.
+ * <<<Assumption: Tx spinlock has been acquired >>>
+ *
+ * 8185 and 8185b does not implement this function.
+ */
 static RESET_TYPE rtl819x_ifcheck_resetornot(struct net_device *dev)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
@@ -3286,9 +3342,10 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 		ResetType = rtl819x_ifcheck_resetornot(dev);
 		check_reset_cnt = 3;
 	}
+	/* This is control by OID set in Pomelo */
 	if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
 	    (priv->bForcedSilentReset ||
-	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) { /* This is control by OID set in Pomelo */
+	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) {
 		RT_TRACE(COMP_RESET, "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n", __func__, priv->force_reset, priv->ResetProgress, priv->bForcedSilentReset, priv->bDisableNormalResetCheck, ResetType);
 		rtl819x_ifsilentreset(dev);
 	}
@@ -3551,11 +3608,16 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
 				if (ieee->group_key_type) {
 					setKey(dev, ipw->u.crypt.idx,
-					       ipw->u.crypt.idx, /* KeyIndex */
-					       ieee->group_key_type, /* KeyType */
-					       broadcast_addr, /* MacAddr */
-					       0,	       /* DefaultKey */
-					       key);	       /* KeyContent */
+					       /* KeyIndex */
+					       ipw->u.crypt.idx,
+					       /* KeyType */
+					       ieee->group_key_type,
+					       /* MacAddr */
+					       broadcast_addr,
+					       /* DefaultKey */
+					       0,
+					       /* KeyContent */
+					       key);
 				}
 			}
 		}
@@ -3715,7 +3777,8 @@ static void UpdateRxPktTimeStamp8190(struct net_device *dev,
 	}
 }
 
-static long rtl819x_translate_todbm(u8 signal_strength_index) /* 0-100 index. */
+/* 0-100 index. */
+static long rtl819x_translate_todbm(u8 signal_strength_index)
 {
 	long	signal_power; /* in dBm. */
 
@@ -3852,7 +3915,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 
 	if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
-		if (priv->undecorated_smoothed_pwdb < 0)	/* initialize */
+		if (priv->undecorated_smoothed_pwdb < 0)
+			/* initialize */
 			priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll;
 		if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
 			priv->undecorated_smoothed_pwdb =
@@ -3886,7 +3950,9 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 			/* <1> Showed on UI for user, in percentage. */
 			tmp_val = priv->stats.slide_evm_total / slide_evm_statistics;
 			priv->stats.signal_quality = tmp_val;
-			/* Showed on UI for user in Windows Vista, for Link quality. */
+			/* Showed on UI for user in Windows Vista,
+			 * for Link quality.
+			 */
 			priv->stats.last_signal_strength_inpercent = tmp_val;
 		}
 
@@ -3917,11 +3983,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
  * Output:		NONE
  *
  * Return:		0-100 percentage
- *
- * Revised History:
- *	When		Who		Remark
- *	05/26/2008	amy		Create Version 0 porting from windows code.
- *
  *---------------------------------------------------------------------------*/
 static u8 rtl819x_query_rxpwrpercentage(char antpower)
 {
@@ -4048,7 +4109,9 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	if (is_cck_rate) {
 		/* (1)Hardware does not provide RSSI for CCK */
 
-		/* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */
+		/* (2)PWDB, Average PWDB cacluated by hardware
+		 * (for rate adaptive)
+		 */
 		u8 report;
 
 		priv->stats.numqry_phystatusCCK++;
@@ -4155,9 +4218,11 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 		/* (3)EVM of HT rate */
 		if (pdrvinfo->RxHT && pdrvinfo->RxRate >= DESC90_RATEMCS8 &&
 		    pdrvinfo->RxRate <= DESC90_RATEMCS15)
-			max_spatial_stream = 2; /* both spatial stream make sense */
+			/* both spatial stream make sense */
+			max_spatial_stream = 2;
 		else
-			max_spatial_stream = 1; /* only spatial stream 1 makes sense */
+			/* only spatial stream 1 makes sense */
+			max_spatial_stream = 1;
 
 		for (i = 0; i < max_spatial_stream; i++) {
 			tmp_rxevm =	pofdm_buf->rxevm_X[i];
@@ -4173,7 +4238,10 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 			rx_evmX /= 2;	/* dbm */
 
 			evm = rtl819x_evm_dbtopercentage(rx_evmX);
-			if (i == 0) /* Fill value in RFD, Get the first spatial stream only */
+			if (i == 0)
+				/* Fill value in RFD, Get the first spatial
+				 * stream only
+				 */
 				pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff);
 			pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff);
 		}
@@ -4287,9 +4355,11 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev,
 					  struct ieee80211_rx_stats *stats)
 {
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-	u32 rcvType = 1;   /* 0: Total, 1:OK, 2:CRC, 3:ICV */
+	/* 0: Total, 1:OK, 2:CRC, 3:ICV */
+	u32 rcvType = 1;
 	u32 rateIndex;
-	u32 preamble_guardinterval;  /* 1: short preamble/GI, 0: long preamble/GI */
+	/* 1: short preamble/GI, 0: long preamble/GI */
+	u32 preamble_guardinterval;
 
 
 	if (stats->bCRC)
@@ -4449,7 +4519,8 @@ static void query_rxdesc_status(struct sk_buff *skb,
 				 */
 
 				stats->bHwError = 1;
-				stats->rate = MGN_1M; /* Set 1M rate by default */
+				/* Set 1M rate by default */
+				stats->rate = MGN_1M;
 			} else {
 				stats->rate = ret_rate;
 			}
@@ -4740,7 +4811,9 @@ fail:
 	return ret;
 }
 
-/* detach all the work and timer structure declared or inititialize in r8192U_init function. */
+/* detach all the work and timer structure declared or inititialize
+ * in r8192U_init function.
+ */
 static void rtl8192_cancel_deferred_work(struct r8192_priv *priv)
 {
 
@@ -4862,7 +4935,8 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 
 	ieee->hwsec_active = 1;
 
-	if ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_PURE_N_MODE) || !hwwep) { /* add hwsec_support flag to totol control hw_sec on/off */
+	/* add hwsec_support flag to totol control hw_sec on/off */
+	if ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_PURE_N_MODE) || !hwwep) {
 		ieee->hwsec_active = 0;
 		SECR_value &= ~SCR_RxDecEnable;
 	}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-17  4:55   ` Greg Kroah-Hartman
  2015-09-11  7:29 ` [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
                   ` (29 subsequent siblings)
  31 siblings, 1 reply; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Add line breaks in multiple lines to keep them under 80 characters,
as to follow the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 626 ++++++++++++++++++++++-----------
 1 file changed, 421 insertions(+), 205 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 5e9d0ac..37c17eb 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -144,25 +144,31 @@ struct CHANNEL_LIST {
 
 static struct CHANNEL_LIST ChannelPlan[] = {
 	/* FCC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24},
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64,
+	  149, 153, 157, 161, 165}, 24},
 	/* IC */
 	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},
 	/* ETSI */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21},
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56,
+	  60, 64}, 21},
 	/* Spain. Change to ETSI. */
 	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
 	/* France. Change to ETSI. */
 	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
 	/* MKK */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
+	  56, 60, 64}, 22},
 	/* MKK1 */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
+	  56, 60, 64}, 22},
 	/* Israel. */
 	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
 	/* For 11a , TELEC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
+	  56, 60, 64}, 22},
 	/* MIC */
-	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
+	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
+	  56, 60, 64}, 22},
 	/* For Global Domain. 1-11:active scan, 12-14 passive scan. */
 	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}
 };
@@ -190,11 +196,14 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 			min_chan = 1;
 			max_chan = 14;
 		} else {
-			RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __func__);
+			RT_TRACE(COMP_ERR,
+				 "unknown rf chip, can't set channel map in function:%s()\n",
+				 __func__);
 		}
 		if (ChannelPlan[channel_plan].Len != 0) {
 			/* Clear old channel map */
-			memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map));
+			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
+			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
 			/* Set new channel map */
 			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
 				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
@@ -262,7 +271,8 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
 				 indx | 0xfe00, 0, &data, 1, HZ / 2);
 
 	if (status < 0)
-		netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n", status);
+		netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n",
+			   status);
 }
 
 int read_nic_byte_E(struct net_device *dev, int indx, u8 *data)
@@ -292,7 +302,8 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data)
 
 	status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, &data, 1, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 &data, 1, HZ / 2);
 
 	if (status < 0)
 		netdev_err(dev, "write_nic_byte TimeOut! status: %d\n", status);
@@ -311,7 +322,8 @@ void write_nic_word(struct net_device *dev, int indx, u16 data)
 
 	status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, &data, 2, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 &data, 2, HZ / 2);
 
 	if (status < 0)
 		netdev_err(dev, "write_nic_word TimeOut! status: %d\n", status);
@@ -329,11 +341,13 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data)
 
 	status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, &data, 4, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 &data, 4, HZ / 2);
 
 
 	if (status < 0)
-		netdev_err(dev, "write_nic_dword TimeOut! status: %d\n", status);
+		netdev_err(dev, "write_nic_dword TimeOut! status: %d\n",
+			   status);
 
 }
 
@@ -347,7 +361,8 @@ int read_nic_byte(struct net_device *dev, int indx, u8 *data)
 
 	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
 				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, data, 1, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 data, 1, HZ / 2);
 
 	if (status < 0) {
 		netdev_err(dev, "%s failure status: %d\n", __func__, status);
@@ -619,7 +634,8 @@ static void rtl8192_proc_init_one(struct net_device *dev)
 	if (rtl8192_proc) {
 		dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
 		if (!dir) {
-			RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
+			RT_TRACE(COMP_ERR,
+				 "Unable to initialize /proc/net/rtl8192/%s\n",
 				 dev->name);
 			return;
 		}
@@ -732,7 +748,8 @@ static int rtl8192_rx_initiate(struct net_device *dev)
 			break;
 		}
 		usb_fill_bulk_urb(entry, priv->udev,
-				  usb_rcvbulkpipe(priv->udev, 3), skb_tail_pointer(skb),
+				  usb_rcvbulkpipe(priv->udev, 3),
+				  skb_tail_pointer(skb),
 				  RX_URB_SIZE, rtl8192_rx_isr, skb);
 		info = (struct rtl8192_rx_info *)skb->cb;
 		info->urb = entry;
@@ -753,7 +770,8 @@ static int rtl8192_rx_initiate(struct net_device *dev)
 			break;
 		}
 		usb_fill_bulk_urb(entry, priv->udev,
-				  usb_rcvbulkpipe(priv->udev, 9), skb_tail_pointer(skb),
+				  usb_rcvbulkpipe(priv->udev, 9),
+				  skb_tail_pointer(skb),
 				  RX_URB_SIZE, rtl8192_rx_isr, skb);
 		info = (struct rtl8192_rx_info *)skb->cb;
 		info->urb = entry;
@@ -924,7 +942,8 @@ static void rtl8192_rx_isr(struct urb *urb)
 	}
 
 	usb_fill_bulk_urb(urb, priv->udev,
-			  usb_rcvbulkpipe(priv->udev, out_pipe), skb_tail_pointer(skb),
+			  usb_rcvbulkpipe(priv->udev, out_pipe),
+			  skb_tail_pointer(skb),
 			  RX_URB_SIZE, rtl8192_rx_isr, skb);
 
 	info = (struct rtl8192_rx_info *)skb->cb;
@@ -937,7 +956,9 @@ static void rtl8192_rx_isr(struct urb *urb)
 	skb_queue_tail(&priv->rx_queue, skb);
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err && err != EPERM)
-		netdev_err(dev, "can not submit rxurb, err is %x, URB status is %x\n", err, urb->status);
+		netdev_err(dev,
+			   "can not submit rxurb, err is %x, URB status is %x\n",
+			   err, urb->status);
 }
 
 static u32 rtl819xusb_rx_command_packet(struct net_device *dev,
@@ -967,7 +988,8 @@ static void rtl8192_data_hard_resume(struct net_device *dev)
 /* this function TX data frames when the ieee80211 stack requires this.
  * It checks also if we need to stop the ieee tx queue, eventually do it
  */
-static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
+static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
+				   int rate)
 {
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 	int ret;
@@ -1034,7 +1056,8 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 			dev->trans_start = jiffies;
 			priv->stats.txoktotal++;
 			priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++;
-			priv->stats.txbytesunicast += (skb->len - priv->ieee80211->tx_headroom);
+			priv->stats.txbytesunicast +=
+				(skb->len - priv->ieee80211->tx_headroom);
 		} else {
 			priv->ieee80211->stats.tx_errors++;
 			/* TODO */
@@ -1067,7 +1090,8 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 		    (!(priv->ieee80211->queue_stop))) {
 			skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]));
 			if (skb)
-				priv->ieee80211->softmac_hard_start_xmit(skb, dev);
+				priv->ieee80211->softmac_hard_start_xmit(skb,
+									 dev);
 
 			return; /* avoid further processing AMSDU */
 		}
@@ -1186,7 +1210,8 @@ static void rtl8192_update_cap(struct net_device *dev, u16 cap)
 	if (net->mode & (IEEE_G | IEEE_N_24G)) {
 		u8 slot_time = 0;
 
-		if ((cap & WLAN_CAPABILITY_SHORT_SLOT) && (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
+		if ((cap & WLAN_CAPABILITY_SHORT_SLOT) &&
+		    (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
 			/* short slot time */
 			slot_time = SHORT_SLOT_TIME;
 		else	/* long slot time */
@@ -1320,7 +1345,8 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 	 *---------------------------------------------------------------------
 	 */
 	idx_pipe = 0x04;
-	usb_fill_bulk_urb(tx_urb, priv->udev, usb_sndbulkpipe(priv->udev, idx_pipe),
+	usb_fill_bulk_urb(tx_urb, priv->udev,
+			  usb_sndbulkpipe(priv->udev, idx_pipe),
 			  skb->data, skb->len, rtl8192_tx_isr, skb);
 
 	status = usb_submit_urb(tx_urb, GFP_ATOMIC);
@@ -1377,7 +1403,9 @@ static u8 MapHwQueueToFirmwareQueue(u8 QueueID)
 		break;
 
 	default:
-		RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d\n", QueueID);
+		RT_TRACE(COMP_ERR,
+			 "TransmitTCB(): Impossible Queue Selection: %d\n",
+			 QueueID);
 		break;
 	}
 	return QueueSelect;
@@ -1489,7 +1517,9 @@ static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
 {
 	u8   tmp_Short;
 
-	tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) : ((tcb_desc->bUseShortPreamble) ? 1 : 0);
+	tmp_Short = (TxHT == 1) ?
+			((tcb_desc->bUseShortGI) ? 1 : 0) :
+			((tcb_desc->bUseShortPreamble) ? 1 : 0);
 
 	if (TxHT == 1 && TxRate != DESC90_RATEMCS15)
 		tmp_Short = 0;
@@ -1511,7 +1541,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
 	tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
-	tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
+	tx_fwinfo_819x_usb *tx_fwinfo =
+		(tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
 	struct usb_device *udev = priv->udev;
 	int pend;
 	int status;
@@ -1541,7 +1572,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	tx_fwinfo->TxHT = (tcb_desc->data_rate & 0x80) ? 1 : 0;
 	tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
 	tx_fwinfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
-	tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, tcb_desc);
+	tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate,
+					tcb_desc);
 	if (tcb_desc->bAMPDUEnable) { /* AMPDU enabled */
 		tx_fwinfo->AllowAggregation = 1;
 		/* DWORD 1 */
@@ -1658,15 +1690,19 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 		if (bSend0Byte) {
 			tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
 			if (!tx_urb_zero) {
-				RT_TRACE(COMP_ERR, "can't alloc urb for zero byte\n");
+				RT_TRACE(COMP_ERR,
+					 "can't alloc urb for zero byte\n");
 				return -ENOMEM;
 			}
 			usb_fill_bulk_urb(tx_urb_zero, udev,
-					  usb_sndbulkpipe(udev, idx_pipe), &zero,
-					  0, tx_zero_isr, dev);
+					  usb_sndbulkpipe(udev, idx_pipe),
+					  &zero, 0, tx_zero_isr, dev);
 			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
 			if (status) {
-				RT_TRACE(COMP_ERR, "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status);
+				RT_TRACE(COMP_ERR,
+					 "Error TX URB for zero byte %d, error %d",
+					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+					 status);
 				return -1;
 			}
 		}
@@ -1675,7 +1711,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 		return 0;
 	}
 
-	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
+		 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
 		 status);
 	return -1;
 }
@@ -1694,7 +1731,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 
 		priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
 
-		priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
+		priv->rx_urb[i]->transfer_buffer =
+			kmalloc(RX_URB_SIZE, GFP_KERNEL);
 
 		priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
 	}
@@ -1801,7 +1839,8 @@ static void rtl8192_link_change(struct net_device *dev)
 		 * way, but there is no chance to set this as wep will not set
 		 * group key in wext.
 		 */
-		if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type))
+		if (KEY_TYPE_WEP40 == ieee->pairwise_key_type ||
+		    KEY_TYPE_WEP104 == ieee->pairwise_key_type)
 			EnableHWSecurityConfig8192(dev);
 	}
 	/*update timing params*/
@@ -1828,25 +1867,30 @@ static struct ieee80211_qos_parameters def_qos_parameters = {
 
 static void rtl8192_update_beacon(struct work_struct *work)
 {
-	struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
+	struct r8192_priv *priv = container_of(work, struct r8192_priv,
+					       update_beacon_wq.work);
 	struct net_device *dev = priv->ieee80211->dev;
 	struct ieee80211_device *ieee = priv->ieee80211;
 	struct ieee80211_network *net = &ieee->current_network;
 
 	if (ieee->pHTInfo->bCurrentHTSupport)
 		HTUpdateSelfAndPeerSetting(ieee, net);
-	ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime;
+	ieee->pHTInfo->bCurrentRT2RTLongSlotTime =
+		net->bssht.bdRT2RTLongSlotTime;
 	rtl8192_update_cap(dev, net->capability);
 }
 /*
 * background support to run QoS activate functionality
 */
-static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO};
+static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK,
+			     EDCAPARA_VI, EDCAPARA_VO};
 static void rtl8192_qos_activate(struct work_struct *work)
 {
-	struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate);
+	struct r8192_priv *priv = container_of(work, struct r8192_priv,
+					       qos_activate);
 	struct net_device *dev = priv->ieee80211->dev;
-	struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
+	struct ieee80211_qos_parameters *qos_parameters =
+		&priv->ieee80211->current_network.qos_data.parameters;
 	u8 mode = priv->ieee80211->current_network.mode;
 	u32  u1bAIFS;
 	u32 u4bAcParam;
@@ -1858,7 +1902,8 @@ static void rtl8192_qos_activate(struct work_struct *work)
 	mutex_lock(&priv->mutex);
 	if (priv->ieee80211->state != IEEE80211_LINKED)
 		goto success;
-	RT_TRACE(COMP_QOS, "qos active process with associate response received\n");
+	RT_TRACE(COMP_QOS,
+		 "qos active process with associate response received\n");
 	/* It better set slot time at first
 	 *
 	 * For we just support b/g mode at present, let the slot time at
@@ -1918,7 +1963,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
 
 		if ((network->qos_data.active == 1) && (active_network == 1)) {
 			queue_work(priv->priv_wq, &priv->qos_activate);
-			RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n");
+			RT_TRACE(COMP_QOS,
+				 "QoS was disabled call qos_activate\n");
 		}
 		network->qos_data.active = 0;
 		network->qos_data.supported = 0;
@@ -1983,7 +2029,9 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
 
 	spin_unlock_irqrestore(&priv->ieee80211->lock, flags);
 
-	RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, network->flags, priv->ieee80211->current_network.qos_data.active);
+	RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__,
+		 network->flags,
+		 priv->ieee80211->current_network.qos_data.active);
 	if (set_qos_param == 1)
 		queue_work(priv->priv_wq, &priv->qos_activate);
 
@@ -1992,9 +2040,10 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
 }
 
 
-static int rtl8192_handle_assoc_response(struct net_device *dev,
-					 struct ieee80211_assoc_response_frame *resp,
-					 struct ieee80211_network *network)
+static int rtl8192_handle_assoc_response(
+		struct net_device *dev,
+		struct ieee80211_assoc_response_frame *resp,
+		struct ieee80211_network *network)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
 
@@ -2040,7 +2089,8 @@ static void rtl8192_update_ratr_table(struct net_device *dev)
 	ratr_value &= 0x0FFFFFFF;
 	if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz)
 		ratr_value |= 0x80000000;
-	else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz)
+	else if (!ieee->pHTInfo->bCurTxBW40MHz &&
+		 ieee->pHTInfo->bCurShortGI20MHz)
 		ratr_value |= 0x80000000;
 	write_nic_dword(dev, RATR0 + rate_index * 4, ratr_value);
 	write_nic_byte(dev, UFWP, 1);
@@ -2061,7 +2111,9 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
 	/* we use connecting AP's capability instead of only security config
 	 * on our driver to distinguish whether it should use N mode or G mode
 	 */
-	encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) || (ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")));
+	encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) ||
+		  (ieee->host_encrypt && crypt && crypt->ops &&
+		   (0 == strcmp(crypt->ops->name, "WEP")));
 
 	/* simply judge  */
 	if (encrypt && (wpa_ie_len == 0)) {
@@ -2093,8 +2145,10 @@ static void rtl8192_refresh_supportrate(struct r8192_priv *priv)
 	/* We do not consider set support rate for ABG mode, only
 	 * HT MCS rate is set here.
 	 */
-	if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G)
-		memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16);
+	if (ieee->mode == WIRELESS_MODE_N_24G ||
+	    ieee->mode == WIRELESS_MODE_N_5G)
+		memcpy(ieee->Regdot11HTOperationalRateSet,
+		       ieee->RegHTSuppRateSet, 16);
 	else
 		memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
 }
@@ -2124,7 +2178,8 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev);
 
-	if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode & bSupportMode) == 0)) {
+	if (wireless_mode == WIRELESS_MODE_AUTO ||
+	    (wireless_mode & bSupportMode) == 0) {
 		if (bSupportMode & WIRELESS_MODE_N_24G) {
 			wireless_mode = WIRELESS_MODE_N_24G;
 		} else if (bSupportMode & WIRELESS_MODE_N_5G) {
@@ -2136,7 +2191,9 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 		} else if ((bSupportMode & WIRELESS_MODE_B)) {
 			wireless_mode = WIRELESS_MODE_B;
 		} else {
-			RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __func__, bSupportMode);
+			RT_TRACE(COMP_ERR,
+				 "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n",
+				 __func__, bSupportMode);
 			wireless_mode = WIRELESS_MODE_B;
 		}
 	}
@@ -2144,11 +2201,14 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 	/* TODO: this function doesn't work well at this time,
 	 * we should wait for FPGA
 	 */
-	ActUpdateChannelAccessSetting(pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
+	ActUpdateChannelAccessSetting(
+			pAdapter, pHalData->CurrentWirelessMode,
+			&pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
 #endif
 	priv->ieee80211->mode = wireless_mode;
 
-	if ((wireless_mode == WIRELESS_MODE_N_24G) ||  (wireless_mode == WIRELESS_MODE_N_5G))
+	if (wireless_mode == WIRELESS_MODE_N_24G ||
+	    wireless_mode == WIRELESS_MODE_N_5G)
 		priv->ieee80211->pHTInfo->bEnableHT = 1;
 	else
 		priv->ieee80211->pHTInfo->bEnableHT = 0;
@@ -2183,14 +2243,16 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 
 	/* we don't use FW read/write RF until stable firmware is available. */
 	priv->ieee80211->FwRWRF = 0;
-	priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
+	priv->ieee80211->current_network.beacon_interval =
+		DEFAULT_BEACONINTERVAL;
 	priv->ieee80211->softmac_features  = IEEE_SOFTMAC_SCAN |
 		IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
 		IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
 		IEEE_SOFTMAC_BEACONS;
 
 	priv->ieee80211->active_scan = 1;
-	priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
+	priv->ieee80211->modulation =
+		IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
 	priv->ieee80211->host_encrypt = 1;
 	priv->ieee80211->host_decrypt = 1;
 	priv->ieee80211->start_send_beacons = NULL;
@@ -2212,7 +2274,8 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 	priv->ieee80211->handle_beacon = rtl8192_handle_beacon;
 
 	priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8192;
-	priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xUsb;
+	priv->ieee80211->GetHalfNmodeSupportByAPsHandler =
+		GetHalfNmodeSupportByAPs819xUsb;
 	priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode;
 
 	priv->ieee80211->InitialGainHandler = InitialGain819xUsb;
@@ -2240,28 +2303,29 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 		(false ? TCR_SAT : 0);
 #ifdef TO_DO_LIST
 	if (Adapter->bInHctTest)
-		pHalData->ReceiveConfig	=	pHalData->CSMethod |
-						/* accept management/data */
-						RCR_AMF | RCR_ADF |
-						/* accept control frame for SW
-						 * AP needs PS-poll
-						 */
-						RCR_ACF |
-						/* accept BC/MC/UC */
-						RCR_AB | RCR_AM | RCR_APM |
-						/* accept ICV/CRC error
-						 * packet
-						 */
-						RCR_AICV | RCR_ACRC32 |
-						/* Max DMA Burst Size per Tx
-						 * DMA Burst, 7: unlimited.
-						 */
-						((u32)7 << RCR_MXDMA_OFFSET) |
-						/* Rx FIFO Threshold,
-						 * 7: No Rx threshold.
-						 */
-						(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
-						(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
+		pHalData->ReceiveConfig =
+			pHalData->CSMethod |
+			/* accept management/data */
+			RCR_AMF | RCR_ADF |
+			/* accept control frame for SW
+			 * AP needs PS-poll
+			 */
+			RCR_ACF |
+			/* accept BC/MC/UC */
+			RCR_AB | RCR_AM | RCR_APM |
+			/* accept ICV/CRC error
+			 * packet
+			 */
+			RCR_AICV | RCR_ACRC32 |
+			/* Max DMA Burst Size per Tx
+			 * DMA Burst, 7: unlimited.
+			 */
+			((u32)7 << RCR_MXDMA_OFFSET) |
+			/* Rx FIFO Threshold,
+			 * 7: No Rx threshold.
+			 */
+			(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
+			(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
 	else
 
 #endif
@@ -2318,11 +2382,16 @@ static void rtl8192_init_priv_task(struct net_device *dev)
 
 	INIT_WORK(&priv->reset_wq, rtl8192_restart);
 
-	INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback);
-	INIT_DELAYED_WORK(&priv->txpower_tracking_wq,  dm_txpower_trackingcallback);
-	INIT_DELAYED_WORK(&priv->rfpath_check_wq,  dm_rf_pathcheck_workitemcallback);
-	INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon);
-	INIT_DELAYED_WORK(&priv->initialgain_operate_wq, InitialGainOperateWorkItemCallBack);
+	INIT_DELAYED_WORK(&priv->watch_dog_wq,
+			  rtl819x_watchdog_wqcallback);
+	INIT_DELAYED_WORK(&priv->txpower_tracking_wq,
+			  dm_txpower_trackingcallback);
+	INIT_DELAYED_WORK(&priv->rfpath_check_wq,
+			  dm_rf_pathcheck_workitemcallback);
+	INIT_DELAYED_WORK(&priv->update_beacon_wq,
+			  rtl8192_update_beacon);
+	INIT_DELAYED_WORK(&priv->initialgain_operate_wq,
+			  InitialGainOperateWorkItemCallBack);
 	INIT_WORK(&priv->qos_activate, rtl8192_qos_activate);
 
 	tasklet_init(&priv->irq_rx_tasklet,
@@ -2337,10 +2406,13 @@ static void rtl8192_get_eeprom_size(struct net_device *dev)
 
 	RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__);
 	read_nic_word_E(dev, EPROM_CMD, &curCR);
-	RT_TRACE(COMP_EPROM, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
+	RT_TRACE(COMP_EPROM,
+		 "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
 	/* whether need I consider BIT5? */
-	priv->epromtype = (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
-	RT_TRACE(COMP_EPROM, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype);
+	priv->epromtype =
+		(curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
+	RT_TRACE(COMP_EPROM,
+		 "<===========%s(), epromtype:%d\n", __func__, priv->epromtype);
 }
 
 /* used to swap endian. as ntohl & htonl are not necessary
@@ -2366,7 +2438,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 	RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", wEPROM_ID);
 
 	if (wEPROM_ID != RTL8190_EEPROM_ID)
-		RT_TRACE(COMP_ERR, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", wEPROM_ID, RTL8190_EEPROM_ID);
+		RT_TRACE(COMP_ERR,
+			 "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n",
+			 wEPROM_ID, RTL8190_EEPROM_ID);
 	else
 		bLoad_From_EEPOM = true;
 
@@ -2377,7 +2451,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		tmpValue = eprom_read(dev, EEPROM_ChannelPlan >> 1);
 		priv->eeprom_ChannelPlan = (tmpValue & 0xff00) >> 8;
 		priv->btxpowerdata_readfromEEPORM = true;
-		priv->eeprom_CustomerID = eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8;
+		priv->eeprom_CustomerID =
+			eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8;
 	} else {
 		priv->eeprom_vid = 0;
 		priv->eeprom_pid = 0;
@@ -2385,7 +2460,10 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		priv->eeprom_ChannelPlan = 0;
 		priv->eeprom_CustomerID = 0;
 	}
-	RT_TRACE(COMP_EPROM, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID, priv->eeprom_ChannelPlan);
+	RT_TRACE(COMP_EPROM,
+		 "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n",
+		 priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID,
+		 priv->eeprom_ChannelPlan);
 	/* set channelplan from eeprom */
 	priv->ChannelPlan = priv->eeprom_ChannelPlan;
 	if (bLoad_From_EEPOM) {
@@ -2518,7 +2596,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		/* Antenna B gain offset to antenna A, bit0~3 */
 		priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
 		/* Antenna C gain offset to antenna A, bit4~7 */
-		priv->AntennaTxPwDiff[1] = (priv->EEPROMTxPowerDiff & 0xf0) >> 4;
+		priv->AntennaTxPwDiff[1] =
+			(priv->EEPROMTxPowerDiff & 0xf0) >> 4;
 		/* CrystalCap, bit12~15 */
 		priv->CrystalCap = priv->EEPROMCrystalCap;
 		/* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
@@ -2577,7 +2656,8 @@ static short rtl8192_get_channel_map(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 
 	if (priv->ChannelPlan > COUNTRY_CODE_GLOBAL_DOMAIN) {
-		netdev_err(dev, "rtl8180_init: Error channel plan! Set to default.\n");
+		netdev_err(dev,
+			   "rtl8180_init: Error channel plan! Set to default.\n");
 		priv->ChannelPlan = 0;
 	}
 	RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan);
@@ -2666,7 +2746,8 @@ static void rtl8192_hwconfig(struct net_device *dev)
 #endif
 		{
 			regBwOpMode = BW_OPMODE_20MHZ;
-			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
+				  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
 			regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		}
 		break;
@@ -2675,12 +2756,14 @@ static void rtl8192_hwconfig(struct net_device *dev)
 		 * out only when associated AP does not support it.
 		 */
 		regBwOpMode = BW_OPMODE_20MHZ;
-		regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+		regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
+			  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
 		regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		break;
 	case WIRELESS_MODE_N_5G:
 		regBwOpMode = BW_OPMODE_5G;
-		regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+		regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS |
+			  RATE_ALL_OFDM_2SS;
 		regRRSR = RATE_ALL_OFDM_AG;
 		break;
 	}
@@ -2739,7 +2822,9 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
 		dwRegRead |= CPU_GEN_FIRMWARE_RESET;
 	else
-		RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__,   priv->pFirmware->firmware_status);
+		RT_TRACE(COMP_ERR,
+			 "ERROR in %s(): undefined firmware state(%d)\n",
+			 __func__,   priv->pFirmware->firmware_status);
 
 	write_nic_dword(dev, CPU_GEN, dwRegRead);
 	/* config BB. */
@@ -2750,11 +2835,14 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 
 	read_nic_dword(dev, CPU_GEN, &dwRegRead);
 	if (priv->LoopbackMode == RTL819xU_NO_LOOPBACK)
-		dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET;
+		dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) |
+			    CPU_GEN_NO_LOOPBACK_SET;
 	else if (priv->LoopbackMode == RTL819xU_MAC_LOOPBACK)
 		dwRegRead |= CPU_CCK_LOOPBACK;
 	else
-		RT_TRACE(COMP_ERR, "Serious error in %s(): wrong loopback mode setting(%d)\n", __func__,  priv->LoopbackMode);
+		RT_TRACE(COMP_ERR,
+			 "Serious error in %s(): wrong loopback mode setting(%d)\n",
+			 __func__,  priv->LoopbackMode);
 
 	write_nic_dword(dev, CPU_GEN, dwRegRead);
 
@@ -2779,14 +2867,17 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	write_nic_dword(dev, RCR, priv->ReceiveConfig);
 
 	/* Initialize Number of Reserved Pages in Firmware Queue */
-	write_nic_dword(dev, RQPN1,  NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_VO << RSVD_FW_QUEUE_PAGE_VO_SHIFT);
-	write_nic_dword(dev, RQPN2, NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_CMD << RSVD_FW_QUEUE_PAGE_CMD_SHIFT);
-	write_nic_dword(dev, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW |
-			NUM_OF_PAGE_IN_FW_QUEUE_BCN << RSVD_FW_QUEUE_PAGE_BCN_SHIFT);
+	write_nic_dword(dev, RQPN1,
+		NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_VO << RSVD_FW_QUEUE_PAGE_VO_SHIFT);
+	write_nic_dword(dev, RQPN2,
+		NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_CMD << RSVD_FW_QUEUE_PAGE_CMD_SHIFT);
+	write_nic_dword(dev, RQPN3,
+		APPLIED_RESERVED_QUEUE_IN_FW |
+		NUM_OF_PAGE_IN_FW_QUEUE_BCN << RSVD_FW_QUEUE_PAGE_BCN_SHIFT);
 	write_nic_dword(dev, RATR0 + 4 * 7, (RATE_ALL_OFDM_AG | RATE_ALL_CCK));
 
 	/* Set AckTimeout */
@@ -2825,7 +2916,8 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	/* Firmware download */
 	init_status = init_firmware(dev);
 	if (!init_status) {
-		RT_TRACE(COMP_ERR, "ERR!!! %s(): Firmware download is failed\n", __func__);
+		RT_TRACE(COMP_ERR, "ERR!!! %s(): Firmware download is failed\n",
+			 __func__);
 		return init_status;
 	}
 	RT_TRACE(COMP_INIT, "%s():after firmware download\n", __func__);
@@ -2833,30 +2925,42 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 #ifdef TO_DO_LIST
 	if (Adapter->ResetProgress == RESET_TYPE_NORESET) {
 		if (pMgntInfo->RegRfOff) { /* User disable RF via registry. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
+			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
+				 ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
 			MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
 			/* Those actions will be discard in MgntActSet_RF_State
 			 * because of the same state
 			 */
 			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+				PHY_SetRFReg(Adapter,
+					     (RF90_RADIO_PATH_E)eRFPath,
+					     0x4, 0xC00, 0x0);
 		} else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) {
 			/* H/W or S/W RF OFF before sleep. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", pMgntInfo->RfOffReason));
-			MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
+			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
+				 ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n",
+				  pMgntInfo->RfOffReason));
+			MgntActSet_RF_State(Adapter,
+					    eRfOff,
+					    pMgntInfo->RfOffReason);
 		} else {
 			pHalData->eRFPowerState = eRfOn;
 			pMgntInfo->RfOffReason = 0;
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): RF is on ----------\n"));
+			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
+				 ("InitializeAdapter819xUsb(): RF is on ----------\n"));
 		}
 	} else {
 		if (pHalData->eRFPowerState == eRfOff) {
-			MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
+			MgntActSet_RF_State(Adapter,
+					    eRfOff,
+					    pMgntInfo->RfOffReason);
 			/* Those actions will be discard in MgntActSet_RF_State
 			 * because of the same state
 			 */
 			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+				PHY_SetRFReg(Adapter,
+					     (RF90_RADIO_PATH_E)eRFPath,
+					     0x4, 0xC00, 0x0);
 		}
 	}
 #endif
@@ -2895,18 +2999,24 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 
 		if (priv->bDcut) {
 			u32 i, TempCCk;
-			u32 tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
+			u32 tmpRegA = rtl8192_QueryBBReg(dev,
+							 rOFDM0_XATxIQImbalance,
+							 bMaskDWord);
 
 			for (i = 0; i < TxBBGainTableLength; i++) {
 				if (tmpRegA == priv->txbbgain_table[i].txbbgain_value) {
 					priv->rfa_txpowertrackingindex = (u8)i;
-					priv->rfa_txpowertrackingindex_real = (u8)i;
-					priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex;
+					priv->rfa_txpowertrackingindex_real =
+						(u8)i;
+					priv->rfa_txpowertracking_default =
+						priv->rfa_txpowertrackingindex;
 					break;
 				}
 			}
 
-			TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2);
+			TempCCk = rtl8192_QueryBBReg(dev,
+						     rCCK0_TxFilter1,
+						     bMaskByte2);
 
 			for (i = 0; i < CCKTxBBGainTableLength; i++) {
 
@@ -2917,7 +3027,8 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 			}
 			priv->cck_present_attentuation_40Mdefault = 0;
 			priv->cck_present_attentuation_difference = 0;
-			priv->cck_present_attentuation = priv->cck_present_attentuation_20Mdefault;
+			priv->cck_present_attentuation =
+				priv->cck_present_attentuation_20Mdefault;
 
 		}
 	}
@@ -2949,7 +3060,9 @@ static bool HalTxCheckStuck819xUsb(struct net_device *dev)
 	bool		bStuck = false;
 
 	read_nic_word(dev, 0x128, &RegTxCounter);
-	RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", __func__, RegTxCounter, priv->TxCounter);
+	RT_TRACE(COMP_RESET,
+		 "%s():RegTxCounter is %d,TxCounter is %d\n", __func__,
+		 RegTxCounter, priv->TxCounter);
 	if (priv->TxCounter == RegTxCounter)
 		bStuck = true;
 
@@ -2980,7 +3093,8 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev)
 	}
 	if (bCheckFwTxCnt) {
 		if (HalTxCheckStuck819xUsb(dev)) {
-			RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition!\n");
+			RT_TRACE(COMP_RESET,
+				 "TxCheckStuck(): Fw indicates no Tx condition!\n");
 			return RESET_TYPE_SILENT;
 		}
 	}
@@ -2995,7 +3109,9 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	static u8	rx_chk_cnt;
 
 	read_nic_word(dev, 0x130, &RegRxCounter);
-	RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__, RegRxCounter, priv->RxCounter);
+	RT_TRACE(COMP_RESET,
+		 "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__,
+		 RegRxCounter, priv->RxCounter);
 	/* If rssi is small, we should check rx for long time because of bad rx.
 	 * or maybe it will continuous silent reset every 2 seconds.
 	 */
@@ -3088,9 +3204,11 @@ static RESET_TYPE rtl819x_ifcheck_resetornot(struct net_device *dev)
 		 */
 		RxResetType = RxCheckStuck(dev);
 	}
-	if (TxResetType == RESET_TYPE_NORMAL || RxResetType == RESET_TYPE_NORMAL) {
+	if (TxResetType == RESET_TYPE_NORMAL ||
+	    RxResetType == RESET_TYPE_NORMAL) {
 		return RESET_TYPE_NORMAL;
-	} else if (TxResetType == RESET_TYPE_SILENT || RxResetType == RESET_TYPE_SILENT) {
+	} else if (TxResetType == RESET_TYPE_SILENT ||
+		   RxResetType == RESET_TYPE_SILENT) {
 		RT_TRACE(COMP_RESET, "%s():silent reset\n", __func__);
 		return RESET_TYPE_SILENT;
 	} else {
@@ -3200,12 +3318,16 @@ RESET_START:
 		priv->ResetProgress = RESET_TYPE_SILENT;
 		down(&priv->wx_sem);
 		if (priv->up == 0) {
-			RT_TRACE(COMP_ERR, "%s():the driver is not up! return\n", __func__);
+			RT_TRACE(COMP_ERR,
+				 "%s():the driver is not up! return\n",
+				 __func__);
 			up(&priv->wx_sem);
 			return;
 		}
 		priv->up = 0;
-		RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():======>start to down the driver\n",
+			 __func__);
 
 		rtl8192_rtx_disable(dev);
 		rtl8192_cancel_deferred_work(priv);
@@ -3227,28 +3349,40 @@ RESET_START:
 			ieee80211_softmac_stop_protocol(priv->ieee80211);
 		}
 		up(&priv->wx_sem);
-		RT_TRACE(COMP_RESET, "%s():<==========down process is finished\n", __func__);
-		RT_TRACE(COMP_RESET, "%s():===========>start up the driver\n", __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():<==========down process is finished\n",
+			 __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():===========>start up the driver\n",
+			 __func__);
 		reset_status = _rtl8192_up(dev);
 
-		RT_TRACE(COMP_RESET, "%s():<===========up process is finished\n", __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():<===========up process is finished\n",
+			 __func__);
 		if (reset_status == -EAGAIN) {
 			if (reset_times < 3) {
 				reset_times++;
 				goto RESET_START;
 			} else {
-				RT_TRACE(COMP_ERR, " ERR!!! %s():  Reset Failed!!\n", __func__);
+				RT_TRACE(COMP_ERR,
+					 " ERR!!! %s():  Reset Failed!!\n",
+					 __func__);
 			}
 		}
 		ieee->is_silent_reset = 1;
 		EnableHWSecurityConfig8192(dev);
-		if (ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) {
-			ieee->set_chan(ieee->dev, ieee->current_network.channel);
+		if (ieee->state == IEEE80211_LINKED &&
+		    ieee->iw_mode == IW_MODE_INFRA) {
+			ieee->set_chan(ieee->dev,
+				       ieee->current_network.channel);
 
 			queue_work(ieee->wq, &ieee->associate_complete_wq);
 
-		} else if (ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_ADHOC) {
-			ieee->set_chan(ieee->dev, ieee->current_network.channel);
+		} else if (ieee->state == IEEE80211_LINKED &&
+			   ieee->iw_mode == IW_MODE_ADHOC) {
+			ieee->set_chan(ieee->dev,
+				       ieee->current_network.channel);
 			ieee->link_change(ieee->dev);
 
 			ieee80211_start_send_beacons(ieee);
@@ -3268,7 +3402,9 @@ RESET_START:
 
 		/* For test --> force write UFWP. */
 		write_nic_byte(dev, UFWP, 1);
-		RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count);
+		RT_TRACE(COMP_RESET,
+			 "Reset finished!! ====>[%d]\n",
+			 priv->reset_count);
 	}
 }
 
@@ -3281,9 +3417,12 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
 	*TotalRxBcnNum = 0;
 	*TotalRxDataNum = 0;
 
-	SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++) % (priv->ieee80211->LinkDetectInfo.SlotNum);
-	priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
-	priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
+	SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++) %
+		    (priv->ieee80211->LinkDetectInfo.SlotNum);
+	priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] =
+		priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
+	priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] =
+		priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
 	for (i = 0; i < priv->ieee80211->LinkDetectInfo.SlotNum; i++) {
 		*TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i];
 		*TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i];
@@ -3293,8 +3432,10 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
 
 static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 {
-	struct delayed_work *dwork = container_of(work, struct delayed_work, work);
-	struct r8192_priv *priv = container_of(dwork, struct r8192_priv, watch_dog_wq);
+	struct delayed_work *dwork = container_of(work,
+						  struct delayed_work, work);
+	struct r8192_priv *priv = container_of(dwork,
+					       struct r8192_priv, watch_dog_wq);
 	struct net_device *dev = priv->ieee80211->dev;
 	struct ieee80211_device *ieee = priv->ieee80211;
 	RESET_TYPE	ResetType = RESET_TYPE_NORESET;
@@ -3318,7 +3459,8 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 		ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
 	}
 	/* for AP roaming */
-	if (priv->ieee80211->state == IEEE80211_LINKED && priv->ieee80211->iw_mode == IW_MODE_INFRA) {
+	if (priv->ieee80211->state == IEEE80211_LINKED &&
+	    priv->ieee80211->iw_mode == IW_MODE_INFRA) {
 
 		rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
 		if ((TotalRxBcnNum + TotalRxDataNum) == 0) {
@@ -3326,12 +3468,16 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 			if (rfState == eRfOff)
 				RT_TRACE(COMP_ERR, "========>%s()\n", __func__);
 #endif
-			netdev_dbg(dev, "===>%s(): AP is power off, connect another one\n", __func__);
+			netdev_dbg(dev,
+				   "===>%s(): AP is power off, connect another one\n",
+				   __func__);
 			priv->ieee80211->state = IEEE80211_ASSOCIATING;
 			notify_wx_assoc_event(priv->ieee80211);
-			RemovePeerTS(priv->ieee80211, priv->ieee80211->current_network.bssid);
+			RemovePeerTS(priv->ieee80211,
+				     priv->ieee80211->current_network.bssid);
 			priv->ieee80211->link_change(dev);
-			queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
+			queue_work(priv->ieee80211->wq,
+				   &priv->ieee80211->associate_procedure_wq);
 
 		}
 	}
@@ -3346,7 +3492,11 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 	if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
 	    (priv->bForcedSilentReset ||
 	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) {
-		RT_TRACE(COMP_RESET, "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n", __func__, priv->force_reset, priv->ResetProgress, priv->bForcedSilentReset, priv->bDisableNormalResetCheck, ResetType);
+		RT_TRACE(COMP_RESET,
+			 "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",
+			 __func__, priv->force_reset, priv->ResetProgress,
+			 priv->bForcedSilentReset,
+			 priv->bDisableNormalResetCheck, ResetType);
 		rtl819x_ifsilentreset(dev);
 	}
 	priv->force_reset = false;
@@ -3361,7 +3511,8 @@ static void watch_dog_timer_callback(unsigned long data)
 	struct r8192_priv *priv = ieee80211_priv((struct net_device *)data);
 
 	queue_delayed_work(priv->priv_wq, &priv->watch_dog_wq, 0);
-	mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
+	mod_timer(&priv->watch_dog_timer,
+		  jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
 }
 static int _rtl8192_up(struct net_device *dev)
 {
@@ -3373,7 +3524,8 @@ static int _rtl8192_up(struct net_device *dev)
 	RT_TRACE(COMP_INIT, "Bringing up iface");
 	init_status = rtl8192_adapter_start(dev);
 	if (!init_status) {
-		RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization failed!\n", __func__);
+		RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization failed!\n",
+			 __func__);
 		priv->up = priv->ieee80211->ieee_up = 0;
 		return -EAGAIN;
 	}
@@ -3466,7 +3618,8 @@ int rtl8192_down(struct net_device *dev)
 
 
 	ieee80211_softmac_stop_protocol(priv->ieee80211);
-	memset(&priv->ieee80211->current_network, 0, offsetof(struct ieee80211_network, list));
+	memset(&priv->ieee80211->current_network, 0,
+	       offsetof(struct ieee80211_network, list));
 	RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__);
 
 	return 0;
@@ -3494,7 +3647,8 @@ void rtl8192_commit(struct net_device *dev)
 
 static void rtl8192_restart(struct work_struct *work)
 {
-	struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
+	struct r8192_priv *priv = container_of(work, struct r8192_priv,
+					       reset_wq);
 	struct net_device *dev = priv->ieee80211->dev;
 
 	down(&priv->wx_sem);
@@ -3587,9 +3741,16 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 					 * so we need index entry for its
 					 * default key serching!
 					 */
-					setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8 *)ieee->ap_mac_addr, 0, key);
+					setKey(dev, 4, ipw->u.crypt.idx,
+					       ieee->pairwise_key_type,
+					       (u8 *)ieee->ap_mac_addr,
+					       0, key);
 					if (ieee->auth_mode != 2)
-						setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8 *)ieee->ap_mac_addr, 0, key);
+						setKey(dev, ipw->u.crypt.idx,
+						       ipw->u.crypt.idx,
+						       ieee->pairwise_key_type,
+						       (u8 *)ieee->ap_mac_addr,
+						       0, key);
 				}
 			} else {
 				memcpy((u8 *)key, ipw->u.crypt.key, 16);
@@ -3621,7 +3782,8 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 				}
 			}
 		}
-		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
+		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
+						     &wrq->u.data);
 		break;
 
 	default:
@@ -3680,7 +3842,9 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
 
 		default:
 			ret_rate = 0xff;
-			RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+			RT_TRACE(COMP_RECV,
+				 "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",
+				 rate, bIsHT);
 			break;
 		}
 
@@ -3740,7 +3904,9 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
 
 		default:
 			ret_rate = 0xff;
-			RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+			RT_TRACE(COMP_RECV,
+				 "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",
+				 rate, bIsHT);
 			break;
 		}
 	}
@@ -3806,7 +3972,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	static u32 slide_evm_index, slide_evm_statistics;
 	static u32 last_rssi, last_evm;
 
-	static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics;
+	static u32 slide_beacon_adc_pwdb_index;
+	static u32 slide_beacon_adc_pwdb_statistics;
 	static u32 last_beacon_adc_pwdb;
 
 	struct rtl_80211_hdr_3addr *hdr;
@@ -3833,7 +4000,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	}
 	priv->stats.slide_rssi_total += pprevious_stats->SignalStrength;
 
-	priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength;
+	priv->stats.slide_signal_strength[slide_rssi_index++] =
+		pprevious_stats->SignalStrength;
 	if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
 		slide_rssi_index = 0;
 
@@ -3865,13 +4033,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	/* <2> Showed on UI for engineering
 	 * hardware does not provide rssi information for each rf path in CCK
 	 */
-	if (!pprevious_stats->bIsCCK && (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) {
+	if (!pprevious_stats->bIsCCK &&
+	    (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) {
 		for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) {
-			if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, rfpath))
+			if (!rtl8192_phy_CheckIsLegalRFPath(
+					priv->ieee80211->dev, rfpath))
 				continue;
 
 			if (priv->stats.rx_rssi_percentage[rfpath] == 0)
-				priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath];
+				priv->stats.rx_rssi_percentage[rfpath] =
+					pprevious_stats->RxMIMOSignalStrength[rfpath];
 			if (pprevious_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
 				priv->stats.rx_rssi_percentage[rfpath] =
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
@@ -3882,7 +4053,9 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
 					 (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
 			}
-			RT_TRACE(COMP_DBG, "priv->stats.rx_rssi_percentage[rfPath]  = %d\n", priv->stats.rx_rssi_percentage[rfpath]);
+			RT_TRACE(COMP_DBG,
+				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
+				 priv->stats.rx_rssi_percentage[rfpath]);
 		}
 	}
 
@@ -3914,10 +4087,13 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		 pprevious_stats->RxPWDBAll);
 
 
-	if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
+	if (pprevious_stats->bPacketToSelf ||
+	    pprevious_stats->bPacketBeacon ||
+	    pprevious_stats->bToSelfBA) {
 		if (priv->undecorated_smoothed_pwdb < 0)
 			/* initialize */
-			priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll;
+			priv->undecorated_smoothed_pwdb =
+				pprevious_stats->RxPWDBAll;
 		if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
 			priv->undecorated_smoothed_pwdb =
 				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
@@ -3934,21 +4110,26 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	/* Check EVM */
 	/* record the general EVM to the sliding window. */
 	if (pprevious_stats->SignalQuality) {
-		if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
+		if (pprevious_stats->bPacketToSelf ||
+		    pprevious_stats->bPacketBeacon ||
+		    pprevious_stats->bToSelfBA) {
 			if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
 				slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
 				last_evm = priv->stats.slide_evm[slide_evm_index];
 				priv->stats.slide_evm_total -= last_evm;
 			}
 
-			priv->stats.slide_evm_total += pprevious_stats->SignalQuality;
+			priv->stats.slide_evm_total +=
+				pprevious_stats->SignalQuality;
 
-			priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality;
+			priv->stats.slide_evm[slide_evm_index++] =
+				pprevious_stats->SignalQuality;
 			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
 				slide_evm_index = 0;
 
 			/* <1> Showed on UI for user, in percentage. */
-			tmp_val = priv->stats.slide_evm_total / slide_evm_statistics;
+			tmp_val = priv->stats.slide_evm_total /
+				  slide_evm_statistics;
 			priv->stats.signal_quality = tmp_val;
 			/* Showed on UI for user in Windows Vista,
 			 * for Link quality.
@@ -3957,7 +4138,9 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		}
 
 		/* <2> Showed on UI for engineering */
-		if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
+		if (pprevious_stats->bPacketToSelf ||
+		    pprevious_stats->bPacketBeacon ||
+		    pprevious_stats->bToSelfBA) {
 			for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */
 				if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
 					if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */
@@ -4069,15 +4252,15 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	phy_sts_ofdm_819xusb_t *pofdm_buf;
 	phy_sts_cck_819xusb_t	*pcck_buf;
 	phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc;
-	u8				*prxpkt;
-	u8				i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
-	char				rx_pwr[4], rx_pwr_all = 0;
-	char				rx_snrX, rx_evmX;
-	u8				evm, pwdb_all;
-	u32				RSSI, total_rssi = 0;
-	u8				is_cck_rate = 0;
-	u8				rf_rx_num = 0;
-	u8				sq;
+	u8	*prxpkt;
+	u8	i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
+	char	rx_pwr[4], rx_pwr_all = 0;
+	char	rx_snrX, rx_evmX;
+	u8	evm, pwdb_all;
+	u32	RSSI, total_rssi = 0;
+	u8	is_cck_rate = 0;
+	u8	rf_rx_num = 0;
+	u8	sq;
 
 
 	priv->stats.numqry_phystatus++;
@@ -4086,7 +4269,8 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 
 	/* Record it for next packet processing */
 	memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats));
-	pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
+	pstats->bPacketMatchBSSID =
+		precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
 	pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself;
 	pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;
 	pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon;
@@ -4171,8 +4355,10 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 				sq = ((64 - sq) * 100) / 44;
 		}
 		pstats->SignalQuality = precord_stats->SignalQuality = sq;
-		pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq;
-		pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1;
+		pstats->RxMIMOSignalQuality[0] =
+			precord_stats->RxMIMOSignalQuality[0] = sq;
+		pstats->RxMIMOSignalQuality[1] =
+			precord_stats->RxMIMOSignalQuality[1] = -1;
 
 	} else {
 		priv->stats.numqry_phystatusHT++;
@@ -4185,10 +4371,12 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 			else
 				continue;
 
-			if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i))
+			if (!rtl8192_phy_CheckIsLegalRFPath(
+					priv->ieee80211->dev, i))
 				continue;
 
-			rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i] & 0x3F) * 2) - 106;
+			rx_pwr[i] =
+				((pofdm_buf->trsw_gain_X[i] & 0x3F) * 2) - 106;
 
 			/* Get Rx snr value in DB */
 			tmp_rxsnr =	pofdm_buf->rxsnr_X[i];
@@ -4242,14 +4430,19 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 				/* Fill value in RFD, Get the first spatial
 				 * stream only
 				 */
-				pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff);
-			pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff);
+				pstats->SignalQuality =
+					precord_stats->SignalQuality =
+					(u8)(evm & 0xff);
+			pstats->RxMIMOSignalQuality[i] =
+				precord_stats->RxMIMOSignalQuality[i] =
+				(u8)(evm & 0xff);
 		}
 
 
 		/* record rx statistics for debug */
 		rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg;
-		prxsc =	(phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg;
+		prxsc =	(phy_ofdm_rx_status_rxsc_sgien_exintfflag *)
+			&rxsc_sgien_exflg;
 		if (pdrvinfo->BW)	/* 40M channel */
 			priv->stats.received_bwtype[1 + prxsc->rxsc]++;
 		else			/* 20M channel */
@@ -4261,16 +4454,22 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	 * GetValueFromBeaconOrProbeRsp().
 	 */
 	if (is_cck_rate) {
-		pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));
+		pstats->SignalStrength =
+			precord_stats->SignalStrength =
+			(u8)(rtl819x_signal_scale_mapping((long)pwdb_all));
 	} else {
 		/* We can judge RX path number now. */
-		if (rf_rx_num != 0)
-			pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+		if (rf_rx_num != 0) {
+			pstats->SignalStrength =
+				precord_stats->SignalStrength =
+				(u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+		}
 	}
 }	/* QueryRxPhyStatus8190Pci */
 
-static void rtl8192_record_rxdesc_forlateruse(struct ieee80211_rx_stats *psrc_stats,
-					      struct ieee80211_rx_stats *ptarget_stats)
+static void rtl8192_record_rxdesc_forlateruse(
+		struct ieee80211_rx_stats *psrc_stats,
+		struct ieee80211_rx_stats *ptarget_stats)
 {
 	ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU;
 	ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU;
@@ -4311,7 +4510,8 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) &&
 			       (eqMacAddr(priv->ieee80211->current_network.bssid,  (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
 			       && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV);
-	bpacket_toself =  bpacket_match_bssid & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
+	bpacket_toself =  bpacket_match_bssid &
+			  (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
 
 	if (WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BEACON)
 		bPacketBeacon = true;
@@ -4331,7 +4531,9 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	 * only, so driver should process phy information of previous packet
 	 */
 	rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats);
-	rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats, bpacket_match_bssid, bpacket_toself, bPacketBeacon, bToSelfBA);
+	rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats,
+				  bpacket_match_bssid, bpacket_toself,
+				  bPacketBeacon, bToSelfBA);
 	rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats);
 
 }
@@ -4504,14 +4706,18 @@ static void query_rxdesc_status(struct sk_buff *skb,
 	 * Driver info are written to the RxBuffer following rx desc
 	 */
 	if (stats->RxDrvInfoSize != 0) {
-		driver_info = (rx_drvinfo_819x_usb *)(skb->data + sizeof(rx_desc_819x_usb) +
-						      stats->RxBufShift);
+		driver_info = (rx_drvinfo_819x_usb *)(
+				skb->data
+				+ sizeof(rx_desc_819x_usb)
+				+ stats->RxBufShift
+			      );
 		/* unit: 0.5M */
 		/* TODO */
 		if (!stats->bHwError) {
 			u8	ret_rate;
 
-			ret_rate = HwRateToMRate90(driver_info->RxHT, driver_info->RxRate);
+			ret_rate = HwRateToMRate90(driver_info->RxHT,
+						   driver_info->RxRate);
 			if (ret_rate == 0xff) {
 				/* Abnormal Case: Receive CRC OK packet with Rx
 				 * descriptor indicating non supported rate.
@@ -4534,14 +4740,16 @@ static void query_rxdesc_status(struct sk_buff *skb,
 		UpdateReceivedRateHistogramStatistics8190(dev, stats);
 
 		stats->bIsAMPDU = (driver_info->PartAggr == 1);
-		stats->bFirstMPDU = (driver_info->PartAggr == 1) && (driver_info->FirstAGGR == 1);
+		stats->bFirstMPDU = (driver_info->PartAggr == 1) &&
+				    (driver_info->FirstAGGR == 1);
 		stats->TimeStampLow = driver_info->TSFL;
 
 		UpdateRxPktTimeStamp8190(dev, stats);
 
 		/* Rx A-MPDU */
 		if (driver_info->FirstAGGR == 1 || driver_info->PartAggr == 1)
-			RT_TRACE(COMP_RXDESC, "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n",
+			RT_TRACE(COMP_RXDESC,
+				"driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n",
 				 driver_info->FirstAGGR, driver_info->PartAggr);
 
 	}
@@ -4610,8 +4818,9 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 
 }
 
-static void rtl819xusb_process_received_packet(struct net_device *dev,
-					       struct ieee80211_rx_stats *pstats)
+static void rtl819xusb_process_received_packet(
+		struct net_device *dev,
+		struct ieee80211_rx_stats *pstats)
 {
 	u8	*frame;
 	u16     frame_len = 0;
@@ -4631,7 +4840,8 @@ static void rtl819xusb_process_received_packet(struct net_device *dev,
 	 * reason, ie. there may be a duration while sw switch is changed and
 	 * hw switch is being changed.
 	 */
-	Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (u8 *)(&rtState));
+	Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE,
+					 (u8 *)(&rtState));
 	if (rtState == eRfOff)
 		return;
 #endif
@@ -4765,14 +4975,16 @@ static int rtl8192_usb_probe(struct usb_interface *intf,
 
 	dev->netdev_ops = &rtl8192_netdev_ops;
 
-	dev->wireless_handlers = (struct iw_handler_def *)&r8192_wx_handlers_def;
+	dev->wireless_handlers =
+		(struct iw_handler_def *)&r8192_wx_handlers_def;
 
 	dev->type = ARPHRD_ETHER;
 
 	dev->watchdog_timeo = HZ * 3;
 
 	if (dev_alloc_name(dev, ifname) < 0) {
-		RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n");
+		RT_TRACE(COMP_INIT,
+			 "Oops: devname already taken! Trying wlan%%d...\n");
 		ifname = "wlan%d";
 		dev_alloc_name(dev, ifname);
 	}
@@ -4832,7 +5044,8 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf)
 	if (dev) {
 		unregister_netdev(dev);
 
-		RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n");
+		RT_TRACE(COMP_DOWN,
+			 "=============>wlan driver to be removed\n");
 		rtl8192_proc_remove_one(dev);
 
 		rtl8192_down(dev);
@@ -4940,8 +5153,9 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 		ieee->hwsec_active = 0;
 		SECR_value &= ~SCR_RxDecEnable;
 	}
-	RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__,
-		 ieee->hwsec_active, ieee->pairwise_key_type, SECR_value);
+	RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n",
+		 __func__, ieee->hwsec_active, ieee->pairwise_key_type,
+		 SECR_value);
 	write_nic_byte(dev, SECR,  SECR_value);
 }
 
@@ -4957,7 +5171,9 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
 	if (EntryNo >= TOTAL_CAM_ENTRY)
 		RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n");
 
-	RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", dev, EntryNo, KeyIndex, KeyType, MacAddr);
+	RT_TRACE(COMP_SEC,
+		 "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n",
+		 dev, EntryNo, KeyIndex, KeyType, MacAddr);
 
 	if (DefaultKey)
 		usConfig |= BIT15 | (KeyType << 2);
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under " Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-17  4:57   ` Greg Kroah-Hartman
  2015-09-11  7:29 ` [PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get " Raphaël Beamonte
                   ` (28 subsequent siblings)
  31 siblings, 1 reply; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Add some temporary variables to reduce line length under the maximum
of 80 characters, as per the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
 1 file changed, 94 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 37c17eb..c8724cd 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -177,6 +177,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 {
 	int i, max_chan = -1, min_chan = -1;
 	struct ieee80211_device *ieee = priv->ieee80211;
+	struct CHANNEL_LIST cl;
 
 	switch (channel_plan) {
 	case COUNTRY_CODE_FCC:
@@ -200,15 +201,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 				 "unknown rf chip, can't set channel map in function:%s()\n",
 				 __func__);
 		}
-		if (ChannelPlan[channel_plan].Len != 0) {
+		cl = ChannelPlan[channel_plan];
+		if (cl.Len != 0) {
 			/* Clear old channel map */
 			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
 			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
 			/* Set new channel map */
-			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
-				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
+			for (i = 0; i < cl.Len; i++) {
+				u8 chan = cl.Channel[i];
+
+				if (chan < min_chan || chan > max_chan)
 					break;
-				GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
+				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
 			}
 		}
 		break;
@@ -1699,9 +1703,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 					  &zero, 0, tx_zero_isr, dev);
 			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
 			if (status) {
+				atomic_t tx =
+					priv->tx_pending[tcb_desc->queue_index];
+
 				RT_TRACE(COMP_ERR,
 					 "Error TX URB for zero byte %d, error %d",
-					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+					 atomic_read(&tx),
 					 status);
 				return -1;
 			}
@@ -1748,8 +1755,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 		oldaddr = priv->oldaddr;
 		align = ((long)oldaddr) & 3;
 		if (align) {
-			newaddr = oldaddr + 4 - align;
-			priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
+			align = 4 - align;
+			newaddr = oldaddr + align;
+			priv->rx_urb[16]->transfer_buffer_length = 16 - align;
 		} else {
 			newaddr = oldaddr;
 			priv->rx_urb[16]->transfer_buffer_length = 16;
@@ -1913,7 +1921,9 @@ static void rtl8192_qos_activate(struct work_struct *work)
 	 */
 	for (i = 0; i <  QOS_QUEUE_NUM; i++) {
 		/* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
-		u1bAIFS = qos_parameters->aifs[i] * ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20) + aSifsTime;
+		int slotTimeTimer = ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20);
+
+		u1bAIFS = qos_parameters->aifs[i] * slotTimeTimer + aSifsTime;
 		u1bAIFS <<= AC_PARAM_AIFS_OFFSET;
 		op_limit = (u32)le16_to_cpu(qos_parameters->tx_op_limit[i]);
 		op_limit <<= AC_PARAM_TXOP_LIMIT_OFFSET;
@@ -2121,10 +2131,12 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
 		return false;
 	} else if ((wpa_ie_len != 0)) {
 		/* parse pairwise key type */
-		if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
-			return true;
-		else
-			return false;
+		bool wpaie_dd = (ieee->wpa_ie[0] == 0xdd &&
+				 !memcmp(&ieee->wpa_ie[14], ccmp_ie, 4));
+		bool wpaie_30 = (ieee->wpa_ie[0] == 0x30 &&
+				 !memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4));
+
+		return (wpaie_dd || wpaie_30);
 	} else {
 		return true;
 	}
@@ -2470,9 +2482,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		int i;
 
 		for (i = 0; i < 6; i += 2) {
-			u16 tmp = 0;
+			u16 tmp = ((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
 
-			tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1));
+			tmp = eprom_read(dev, tmp);
 			*(u16 *)(&dev->dev_addr[i]) = tmp;
 		}
 	} else {
@@ -3002,9 +3014,11 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 			u32 tmpRegA = rtl8192_QueryBBReg(dev,
 							 rOFDM0_XATxIQImbalance,
 							 bMaskDWord);
+			txbbgain_struct *tx = priv->txbbgain_table;
+			ccktxbbgain_struct *cck = priv->cck_txbbgain_table;
 
 			for (i = 0; i < TxBBGainTableLength; i++) {
-				if (tmpRegA == priv->txbbgain_table[i].txbbgain_value) {
+				if (tmpRegA == tx[i].txbbgain_value) {
 					priv->rfa_txpowertrackingindex = (u8)i;
 					priv->rfa_txpowertrackingindex_real =
 						(u8)i;
@@ -3019,8 +3033,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 						     bMaskByte2);
 
 			for (i = 0; i < CCKTxBBGainTableLength; i++) {
-
-				if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) {
+				if (TempCCk == cck[i].ccktxbb_valuearray[0]) {
 					priv->cck_present_attentuation_20Mdefault = (u8)i;
 					break;
 				}
@@ -3080,13 +3093,15 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	u8			QueueID;
 	bool			bCheckFwTxCnt = false;
+	struct ieee80211_device *ieee = priv->ieee80211;
 
 	/* Decide such threshold according to current power save mode */
 
 	for (QueueID = 0; QueueID <= BEACON_QUEUE; QueueID++) {
 		if (QueueID == TXCMD_QUEUE)
 			continue;
-		if ((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0)  && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
+		if (skb_queue_len(&ieee->skb_waitQ[QueueID]) == 0 &&
+		    skb_queue_len(&ieee->skb_aggQ[QueueID]) == 0)
 			continue;
 
 		bCheckFwTxCnt = true;
@@ -3107,6 +3122,8 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	bool bStuck = false;
 	static u8	rx_chk_cnt;
+	long pwdb = priv->undecorated_smoothed_pwdb;
+	bool channelWidth20;
 
 	read_nic_word(dev, 0x130, &RegRxCounter);
 	RT_TRACE(COMP_RESET,
@@ -3116,18 +3133,21 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	 * or maybe it will continuous silent reset every 2 seconds.
 	 */
 	rx_chk_cnt++;
-	if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High + 5)) {
+
+	channelWidth20 = (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20);
+
+	if (pwdb >= (RateAdaptiveTH_High + 5)) {
 		rx_chk_cnt = 0;	/* high rssi, check rx stuck right now. */
-	} else if (priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5) &&
-		   ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M) ||
-		    (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M))) {
+	} else if (pwdb < (RateAdaptiveTH_High + 5) &&
+		   ((!channelWidth20 && pwdb >= RateAdaptiveTH_Low_40M) ||
+		    (channelWidth20 && pwdb >= RateAdaptiveTH_Low_20M))) {
 		if (rx_chk_cnt < 2)
 			return bStuck;
 
 		rx_chk_cnt = 0;
-	} else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M) ||
-		    (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M)) &&
-		     priv->undecorated_smoothed_pwdb >= VeryLowRSSI) {
+	} else if (((!channelWidth20 && pwdb < RateAdaptiveTH_Low_40M) ||
+		    (channelWidth20 && pwdb < RateAdaptiveTH_Low_20M)) &&
+		     pwdb >= VeryLowRSSI) {
 		if (rx_chk_cnt < 4)
 			return bStuck;
 
@@ -3443,6 +3463,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 	bool bBusyTraffic = false;
 	u32	TotalRxBcnNum = 0;
 	u32	TotalRxDataNum = 0;
+	bool resetSilent;
 
 	if (!priv->up)
 		return;
@@ -3488,10 +3509,14 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 		ResetType = rtl819x_ifcheck_resetornot(dev);
 		check_reset_cnt = 3;
 	}
+
 	/* This is control by OID set in Pomelo */
-	if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
-	    (priv->bForcedSilentReset ||
-	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) {
+	resetSilent = (!priv->bDisableNormalResetCheck &&
+		       ResetType == RESET_TYPE_SILENT);
+	resetSilent = (priv->bForcedSilentReset || resetSilent);
+
+	if (priv->force_reset ||
+	    (priv->ResetProgress == RESET_TYPE_NORESET && resetSilent)) {
 		RT_TRACE(COMP_RESET,
 			 "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",
 			 __func__, priv->force_reset, priv->ResetProgress,
@@ -4254,7 +4279,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc;
 	u8	*prxpkt;
 	u8	i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
-	char	rx_pwr[4], rx_pwr_all = 0;
+	char	rx_pwr[4], rx_pwr_all = 0, tmp;
 	char	rx_snrX, rx_evmX;
 	u8	evm, pwdb_all;
 	u32	RSSI, total_rssi = 0;
@@ -4303,35 +4328,37 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 		if (!priv->bCckHighPower) {
 			report = pcck_buf->cck_agc_rpt & 0xc0;
 			report >>= 6;
+			tmp = pcck_buf->cck_agc_rpt & 0x3e;
 			switch (report) {
 			case 0x3:
-				rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -35 - tmp;
 				break;
 			case 0x2:
-				rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -23 - tmp;
 				break;
 			case 0x1:
-				rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -11 - tmp;
 				break;
 			case 0x0:
-				rx_pwr_all = 6 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = 6 - tmp;
 				break;
 			}
 		} else {
 			report = pcck_buf->cck_agc_rpt & 0x60;
 			report >>= 5;
+			tmp = (pcck_buf->cck_agc_rpt & 0x1f) << 1;
 			switch (report) {
 			case 0x3:
-				rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -35 - tmp;
 				break;
 			case 0x2:
-				rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -23 - tmp;
 				break;
 			case 0x1:
-				rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -11 - tmp;
 				break;
 			case 0x0:
-				rx_pwr_all = 6 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = 6 - tmp;
 				break;
 			}
 		}
@@ -4460,9 +4487,11 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	} else {
 		/* We can judge RX path number now. */
 		if (rf_rx_num != 0) {
+			long currsig = (total_rssi /= rf_rx_num);
+
 			pstats->SignalStrength =
 				precord_stats->SignalStrength =
-				(u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+				(u8)(rtl819x_signal_scale_mapping(currsig));
 		}
 	}
 }	/* QueryRxPhyStatus8190Pci */
@@ -4492,6 +4521,8 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	static struct ieee80211_rx_stats  previous_stats;
 	struct rtl_80211_hdr_3addr *hdr;
 	u16 fc, type;
+	u8 *addr;
+	bool bssid_eq_addr;
 
 	/* Get Signal Quality for only RX data queue (but not command queue) */
 
@@ -4506,10 +4537,19 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	type = WLAN_FC_GET_TYPE(fc);
 	praddr = hdr->addr1;
 
+	if (fc & IEEE80211_FCTL_TODS)
+		addr = hdr->addr1;
+	else if (fc & IEEE80211_FCTL_FROMDS)
+		addr = hdr->addr2;
+	else
+		addr = hdr->addr3;
+
+	bssid_eq_addr = eqMacAddr(priv->ieee80211->current_network.bssid, addr);
+
 	/* Check if the received packet is acceptable. */
 	bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) &&
-			       (eqMacAddr(priv->ieee80211->current_network.bssid,  (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
-			       && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV);
+			       bssid_eq_addr && (!pstats->bHwError) &&
+			       (!pstats->bCRC) && (!pstats->bICV);
 	bpacket_toself =  bpacket_match_bssid &
 			  (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
 
@@ -4781,9 +4821,10 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 	u32 rx_pkt_len = 0;
 	struct rtl_80211_hdr_1addr *ieee80211_hdr = NULL;
 	bool unicast_packet = false;
+	int size = 20 + sizeof(rx_desc_819x_usb);
 
 	/* 20 is for ps-poll */
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= size) && (skb->len < RX_URB_SIZE)) {
 		/* first packet should not contain Rx aggregation header */
 		query_rxdesc_status(skb, &stats, false);
 		/* TODO */
@@ -4889,8 +4930,9 @@ static void rtl8192_rx_cmd(struct sk_buff *skb)
 		.rate = 0,
 		.freq = IEEE80211_24GHZ_BAND,
 	};
+	int size = 20 + sizeof(rx_desc_819x_usb);
 
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= size) && (skb->len < RX_URB_SIZE)) {
 
 		query_rx_cmdpkt_desc_status(skb, &stats);
 		/* prfd->queue_id = 1; */
@@ -5131,11 +5173,17 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 	struct ieee80211_device *ieee = priv->ieee80211;
 
+	bool ktype_wep = (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
+			 (KEY_TYPE_WEP104 == ieee->pairwise_key_type);
+	bool ktype_ccmp_tkip = ieee->pairwise_key_type
+			       & (KEY_TYPE_CCMP | KEY_TYPE_TKIP);
+
 	SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
-	if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) {
+
+	if (ktype_wep && (priv->ieee80211->auth_mode != 2)) {
 		SECR_value |= SCR_RxUseDK;
 		SECR_value |= SCR_TxUseDK;
-	} else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) {
+	} else if (ktype_ccmp_tkip && (ieee->iw_mode == IW_MODE_ADHOC)) {
 		SECR_value |= SCR_RxUseDK;
 		SECR_value |= SCR_TxUseDK;
 	}
@@ -5202,7 +5250,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
 		} else {
 			/* Key Material */
 			if (KeyContent != NULL) {
-				write_nic_dword(dev, WCAMI, (u32)(*(KeyContent + i - 2)));
+				TargetContent = (u32)(*(KeyContent + i - 2));
+				write_nic_dword(dev, WCAMI, TargetContent);
 				write_nic_dword(dev, RWCAM, TargetCommand);
 			}
 		}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (2 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte
                   ` (27 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Reverse some conditions to clean the code and allow to have lines
under 80 characters, as to follow the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 48 ++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index c8724cd..85dfcbb 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -202,18 +202,19 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 				 __func__);
 		}
 		cl = ChannelPlan[channel_plan];
-		if (cl.Len != 0) {
-			/* Clear old channel map */
-			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
-			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
-			/* Set new channel map */
-			for (i = 0; i < cl.Len; i++) {
-				u8 chan = cl.Channel[i];
-
-				if (chan < min_chan || chan > max_chan)
-					break;
-				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
-			}
+		if (cl.Len == 0)
+			break;
+
+		/* Clear old channel map */
+		memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
+		       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
+		/* Set new channel map */
+		for (i = 0; i < cl.Len; i++) {
+			u8 chan = cl.Channel[i];
+
+			if (chan < min_chan || chan > max_chan)
+				break;
+			GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
 		}
 		break;
 
@@ -1088,17 +1089,18 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 	 */
 
 	/* Handle MPDU in wait queue. */
-	if (queue_index != BEACON_QUEUE) {
-		/* Don't send data frame during scanning.*/
-		if ((skb_queue_len(&priv->ieee80211->skb_waitQ[queue_index]) != 0) &&
-		    (!(priv->ieee80211->queue_stop))) {
-			skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]));
-			if (skb)
-				priv->ieee80211->softmac_hard_start_xmit(skb,
-									 dev);
-
-			return; /* avoid further processing AMSDU */
-		}
+	if (queue_index == BEACON_QUEUE)
+		return;
+
+	/* Don't send data frame during scanning.*/
+	if ((skb_queue_len(&priv->ieee80211->skb_waitQ[queue_index]) != 0) &&
+	    (!(priv->ieee80211->queue_stop))) {
+		skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]));
+		if (skb)
+			priv->ieee80211->softmac_hard_start_xmit(skb,
+								 dev);
+
+		return; /* avoid further processing AMSDU */
 	}
 
 }
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (3 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get " Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: " Raphaël Beamonte
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Reverse conditions and use goto in the function rtl8192_adapter_start
to have most of it under 80 characters per line.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 91 ++++++++++++++++++----------------
 1 file changed, 47 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 85dfcbb..5573c50 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2816,6 +2816,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	bool init_status = true;
 	u8 SECR_value = 0x0;
 	u8 tmp;
+	u32 i, TempCCk, tmpRegA;
 
 	RT_TRACE(COMP_INIT, "====>%s()\n", __func__);
 	priv->Rf_Mode = RF_OP_By_SW_3wire;
@@ -2997,59 +2998,61 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
 	rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
 
-	if (priv->ResetProgress == RESET_TYPE_NORESET) {
-		/* if D or C cut */
-		u8 tmpvalue;
+	if (priv->ResetProgress != RESET_TYPE_NORESET)
+		goto end;
 
-		read_nic_byte(dev, 0x301, &tmpvalue);
-		if (tmpvalue == 0x03) {
-			priv->bDcut = true;
-			RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
-		} else {
-			priv->bDcut = false;
-			RT_TRACE(COMP_POWER_TRACKING, "C-cut\n");
+	/* if D or C cut */
+	read_nic_byte(dev, 0x301, &tmp);
+	if (tmp == 0x03) {
+		priv->bDcut = true;
+		RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
+	} else {
+		priv->bDcut = false;
+		RT_TRACE(COMP_POWER_TRACKING, "C-cut\n");
+	}
+	dm_initialize_txpower_tracking(dev);
+
+	if (!priv->bDcut)
+		goto end;
+
+	tmpRegA = rtl8192_QueryBBReg(dev,
+				     rOFDM0_XATxIQImbalance,
+				      bMaskDWord);
+
+	for (i = 0; i < TxBBGainTableLength; i++) {
+		txbbgain_struct tx = priv->txbbgain_table[i];
+
+		if (tmpRegA == tx.txbbgain_value) {
+			priv->rfa_txpowertrackingindex = (u8)i;
+			priv->rfa_txpowertrackingindex_real =
+				(u8)i;
+			priv->rfa_txpowertracking_default =
+				priv->rfa_txpowertrackingindex;
+			break;
 		}
-		dm_initialize_txpower_tracking(dev);
-
-		if (priv->bDcut) {
-			u32 i, TempCCk;
-			u32 tmpRegA = rtl8192_QueryBBReg(dev,
-							 rOFDM0_XATxIQImbalance,
-							 bMaskDWord);
-			txbbgain_struct *tx = priv->txbbgain_table;
-			ccktxbbgain_struct *cck = priv->cck_txbbgain_table;
-
-			for (i = 0; i < TxBBGainTableLength; i++) {
-				if (tmpRegA == tx[i].txbbgain_value) {
-					priv->rfa_txpowertrackingindex = (u8)i;
-					priv->rfa_txpowertrackingindex_real =
-						(u8)i;
-					priv->rfa_txpowertracking_default =
-						priv->rfa_txpowertrackingindex;
-					break;
-				}
-			}
+	}
 
-			TempCCk = rtl8192_QueryBBReg(dev,
-						     rCCK0_TxFilter1,
-						     bMaskByte2);
+	TempCCk = rtl8192_QueryBBReg(dev,
+				     rCCK0_TxFilter1,
+				     bMaskByte2);
 
-			for (i = 0; i < CCKTxBBGainTableLength; i++) {
-				if (TempCCk == cck[i].ccktxbb_valuearray[0]) {
-					priv->cck_present_attentuation_20Mdefault = (u8)i;
-					break;
-				}
-			}
-			priv->cck_present_attentuation_40Mdefault = 0;
-			priv->cck_present_attentuation_difference = 0;
-			priv->cck_present_attentuation =
-				priv->cck_present_attentuation_20Mdefault;
+	for (i = 0; i < CCKTxBBGainTableLength; i++) {
+		ccktxbbgain_struct cck = priv->cck_txbbgain_table[i];
 
+		if (TempCCk == cck.ccktxbb_valuearray[0]) {
+			priv->cck_present_attentuation_20Mdefault = (u8)i;
+			break;
 		}
 	}
-	write_nic_byte(dev, 0x87, 0x0);
+	priv->cck_present_attentuation_40Mdefault = 0;
+	priv->cck_present_attentuation_difference = 0;
+	priv->cck_present_attentuation =
+		priv->cck_present_attentuation_20Mdefault;
 
 
+end:
+	write_nic_byte(dev, 0x87, 0x0);
+
 	return init_status;
 }
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (4 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Refactor code to avoid multiple check of same boolean value, and to
make the code clearer. This patches also implements the necessary
changes for the code lines in this function to be under 80 chars.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 259 ++++++++++++++++++++-------------
 1 file changed, 155 insertions(+), 104 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 5573c50..acb8f97 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2497,129 +2497,180 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 	priv->rf_type = RTL819X_DEFAULT_RF_TYPE; /* default 1T2R */
 	priv->rf_chip = RF_8256;
 
-	if (priv->card_8192_version == (u8)VERSION_819xU_A) {
+	/* if version mismatch VERSION_819xU_A, go directly to the led section
+	 */
+	if (priv->card_8192_version != (u8)VERSION_819xU_A)
+		goto led;
+
+	if (bLoad_From_EEPOM) {
 		/* read Tx power gain offset of legacy OFDM to HT rate */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMTxPowerDiff = (eprom_read(dev, (EEPROM_TxPowerDiff >> 1)) & 0xff00) >> 8;
-		else
-			priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower;
-		RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff);
+		tmpValue = eprom_read(dev, (EEPROM_TxPowerDiff >> 1));
+		priv->EEPROMTxPowerDiff = (tmpValue & 0xff00) >> 8;
+
 		/* read ThermalMeter from EEPROM */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMThermalMeter = (u8)(eprom_read(dev, (EEPROM_ThermalMeter >> 1)) & 0x00ff);
-		else
-			priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
-		RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter);
-		/* for tx power track */
-		priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100;
+		tmpValue = eprom_read(dev, (EEPROM_ThermalMeter >> 1));
+		priv->EEPROMThermalMeter = (u8)(tmpValue & 0x00ff);
+
 		/* read antenna tx power offset of B/C/D to A from EEPROM */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMPwDiff = (eprom_read(dev, (EEPROM_PwDiff >> 1)) & 0x0f00) >> 8;
-		else
-			priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
-		RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff);
+		tmpValue = eprom_read(dev, (EEPROM_PwDiff >> 1));
+		priv->EEPROMPwDiff = (tmpValue & 0x0f00) >> 8;
+
 		/* Read CrystalCap from EEPROM */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMCrystalCap = (eprom_read(dev, (EEPROM_CrystalCap >> 1)) & 0x0f);
-		else
-			priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
-		RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap);
+		tmpValue = eprom_read(dev, (EEPROM_CrystalCap >> 1));
+		priv->EEPROMCrystalCap = (tmpValue & 0x0f);
+
 		/* get per-channel Tx power level */
-		if (bLoad_From_EEPOM)
-			priv->EEPROM_Def_Ver = (eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1)) & 0xff00) >> 8;
-		else
-			priv->EEPROM_Def_Ver = 1;
-		RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver);
+		tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1));
+		priv->EEPROM_Def_Ver = (tmpValue & 0xff00) >> 8;
+	} else {
+		/* read Tx power gain offset of legacy OFDM to HT rate */
+		priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower;
+
+		/* read ThermalMeter from EEPROM */
+		priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+
+		/* read antenna tx power offset of B/C/D to A from EEPROM */
+		priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
+
+		/* Read CrystalCap from EEPROM */
+		priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+
+		/* get per-channel Tx power level */
+		priv->EEPROM_Def_Ver = 1;
+	}
+
+	/* for tx power track */
+	priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100;
+
+	RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff);
+	RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter);
+	RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff);
+	RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap);
+	RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver);
+
+	if (bLoad_From_EEPOM) {
 		if (priv->EEPROM_Def_Ver == 0) { /* old eeprom definition */
 			int i;
 
-			if (bLoad_From_EEPOM)
-				priv->EEPROMTxPowerLevelCCK = (eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1)) & 0xff) >> 8;
-			else
-				priv->EEPROMTxPowerLevelCCK = 0x10;
-			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
+			tmpValue = (EEPROM_TxPwIndex_CCK >> 1) & 0xff;
+			tmpValue = eprom_read(dev, tmpValue);
+			priv->EEPROMTxPowerLevelCCK = tmpValue >> 8;
+
+			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n",
+				 priv->EEPROMTxPowerLevelCCK);
+
 			for (i = 0; i < 3; i++) {
-				if (bLoad_From_EEPOM) {
-					tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1);
-					if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0)
-						tmpValue = tmpValue & 0x00ff;
-					else
-						tmpValue = (tmpValue & 0xff00) >> 8;
-				} else {
-					tmpValue = 0x10;
-				}
-				priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)tmpValue;
-				RT_TRACE(COMP_EPROM, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK);
+				tmpValue = (EEPROM_TxPwIndex_OFDM_24G + i) >> 1;
+				tmpValue = eprom_read(dev, tmpValue);
+				if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0)
+					tmpValue = tmpValue & 0x00ff;
+				else
+					tmpValue = (tmpValue & 0xff00) >> 8;
+
+				priv->EEPROMTxPowerLevelOFDM24G[i] =
+					(u8)tmpValue;
+
+				RT_TRACE(COMP_EPROM,
+					 "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n",
+					 i, priv->EEPROMTxPowerLevelCCK);
 			}
 		} else if (priv->EEPROM_Def_Ver == 1) {
-			if (bLoad_From_EEPOM) {
-				tmpValue = eprom_read(dev,
-						EEPROM_TxPwIndex_CCK_V1 >> 1);
-				tmpValue = (tmpValue & 0xff00) >> 8;
-			} else {
-				tmpValue = 0x10;
-			}
+			tmpValue = EEPROM_TxPwIndex_CCK_V1 >> 1;
+			tmpValue = eprom_read(dev, tmpValue);
+			tmpValue = (tmpValue & 0xff00) >> 8;
 			priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)tmpValue;
 
-			if (bLoad_From_EEPOM)
-				tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1);
-			else
-				tmpValue = 0x1010;
-			*((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = tmpValue;
-			if (bLoad_From_EEPOM)
-				tmpValue = eprom_read(dev,
-					EEPROM_TxPwIndex_OFDM_24G_V1 >> 1);
-			else
-				tmpValue = 0x1010;
-			*((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) = tmpValue;
-			if (bLoad_From_EEPOM)
-				tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1 + 2) >> 1);
-			else
-				tmpValue = 0x10;
+			tmpValue = (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1;
+			*((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) =
+				eprom_read(dev, tmpValue);
+
+			tmpValue = EEPROM_TxPwIndex_OFDM_24G_V1 >> 1;
+			*((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) =
+				eprom_read(dev, tmpValue);
+
+			tmpValue = (EEPROM_TxPwIndex_OFDM_24G_V1 + 2) >> 1;
+			tmpValue = eprom_read(dev, tmpValue);
 			priv->EEPROMTxPowerLevelOFDM24G[2] = (u8)tmpValue;
 		} /* endif EEPROM_Def_Ver == 1 */
+	} else {
+		if (priv->EEPROM_Def_Ver == 0) { /* old eeprom definition */
+			int i;
 
-		/* update HAL variables */
-		for (i = 0; i < 14; i++) {
-			if (i <= 3)
-				priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[0];
-			else if (i >= 4 && i <= 9)
-				priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[1];
-			else
-				priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[2];
-		}
+			priv->EEPROMTxPowerLevelCCK = 0x10;
 
-		for (i = 0; i < 14; i++) {
-			if (priv->EEPROM_Def_Ver == 0) {
-				if (i <= 3)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelOFDM24G[0] + (priv->EEPROMTxPowerLevelCCK - priv->EEPROMTxPowerLevelOFDM24G[1]);
-				else if (i >= 4 && i <= 9)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK;
-				else
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelOFDM24G[2] + (priv->EEPROMTxPowerLevelCCK - priv->EEPROMTxPowerLevelOFDM24G[1]);
-			} else if (priv->EEPROM_Def_Ver == 1) {
-				if (i <= 3)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[0];
-				else if (i >= 4 && i <= 9)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[1];
-				else
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[2];
+			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n",
+				 priv->EEPROMTxPowerLevelCCK);
+
+			for (i = 0; i < 3; i++) {
+				priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)0x10;
+				RT_TRACE(COMP_EPROM,
+					 "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n",
+					 i, priv->EEPROMTxPowerLevelCCK);
 			}
-		}
-		priv->TxPowerDiff = priv->EEPROMPwDiff;
-		/* Antenna B gain offset to antenna A, bit0~3 */
-		priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
-		/* Antenna C gain offset to antenna A, bit4~7 */
-		priv->AntennaTxPwDiff[1] =
-			(priv->EEPROMTxPowerDiff & 0xf0) >> 4;
-		/* CrystalCap, bit12~15 */
-		priv->CrystalCap = priv->EEPROMCrystalCap;
-		/* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
-		 * 92U does not enable TX power tracking.
-		 */
-		priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
-	} /* end if VersionID == VERSION_819xU_A */
+		} else if (priv->EEPROM_Def_Ver == 1) {
+			priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)0x10;
+			*((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = 0x1010;
+			*((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) =
+				0x1010;
+			priv->EEPROMTxPowerLevelOFDM24G[2] = (u8)0x10;
+		} /* endif EEPROM_Def_Ver == 1 */
+	}
+
+	/* update HAL variables */
+	for (i = 0; i < 4; i++) {
+		priv->TxPowerLevelOFDM24G[i] =
+			priv->EEPROMTxPowerLevelOFDM24G[0];
+
+		if (priv->EEPROM_Def_Ver == 0)
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelOFDM24G[0] +
+				priv->EEPROMTxPowerLevelCCK -
+				priv->EEPROMTxPowerLevelOFDM24G[1];
+		else
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK_V1[0];
+	}
+
+	for (i = 4; i < 10; i++) {
+		priv->TxPowerLevelOFDM24G[i] =
+			priv->EEPROMTxPowerLevelOFDM24G[1];
+
+		if (priv->EEPROM_Def_Ver == 0)
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK;
+		else
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK_V1[1];
+	}
+
+	for (i = 10; i < 14; i++) {
+		priv->TxPowerLevelOFDM24G[i] =
+			priv->EEPROMTxPowerLevelOFDM24G[2];
+
+		if (priv->EEPROM_Def_Ver == 0)
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelOFDM24G[2] +
+				priv->EEPROMTxPowerLevelCCK -
+				priv->EEPROMTxPowerLevelOFDM24G[1];
+		else
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK_V1[2];
+	}
+
+	priv->TxPowerDiff = priv->EEPROMPwDiff;
+	/* Antenna B gain offset to antenna A, bit0~3 */
+	priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
+	/* Antenna C gain offset to antenna A, bit4~7 */
+	priv->AntennaTxPwDiff[1] =
+		(priv->EEPROMTxPowerDiff & 0xf0) >> 4;
+	/* CrystalCap, bit12~15 */
+	priv->CrystalCap = priv->EEPROMCrystalCap;
+	/* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+	 * 92U does not enable TX power tracking.
+	 */
+	priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
 
+led:
 	/* for dlink led */
 	switch (priv->eeprom_CustomerID) {
 	case EEPROM_CID_RUNTOP:
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (5 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: " Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte
                   ` (24 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Rename variable to a shorter name to allow easier code refactoring
in following patch.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 84 +++++++++++++++++-----------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index acb8f97..2a7d46d 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4043,7 +4043,7 @@ static long rtl819x_translate_todbm(u8 signal_strength_index)
  * and it will be reinitialized when returned from S3/S4.
  */
 static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
-				    struct ieee80211_rx_stats *pprevious_stats,
+				    struct ieee80211_rx_stats *prev_stats,
 				    struct ieee80211_rx_stats *pcurrent_stats)
 {
 	bool bcheck = false;
@@ -4069,7 +4069,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	pcurrent_stats->Seq_Num = seq;
 
 	/* Check whether we should take the previous packet into accounting */
-	if (!pprevious_stats->bIsAMPDU) {
+	if (!prev_stats->bIsAMPDU) {
 		/* if previous packet is not aggregated packet */
 		bcheck = true;
 	}
@@ -4079,10 +4079,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		last_rssi = priv->stats.slide_signal_strength[slide_rssi_index];
 		priv->stats.slide_rssi_total -= last_rssi;
 	}
-	priv->stats.slide_rssi_total += pprevious_stats->SignalStrength;
+	priv->stats.slide_rssi_total += prev_stats->SignalStrength;
 
 	priv->stats.slide_signal_strength[slide_rssi_index++] =
-		pprevious_stats->SignalStrength;
+		prev_stats->SignalStrength;
 	if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
 		slide_rssi_index = 0;
 
@@ -4092,8 +4092,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	pcurrent_stats->rssi = priv->stats.signal_strength;
 
 	/* If the previous packet does not match the criteria, neglect it */
-	if (!pprevious_stats->bPacketMatchBSSID) {
-		if (!pprevious_stats->bToSelfBA)
+	if (!prev_stats->bPacketMatchBSSID) {
+		if (!prev_stats->bToSelfBA)
 			return;
 	}
 
@@ -4102,7 +4102,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 
 	/* only rtl8190 supported
-	 * rtl8190_process_cck_rxpathsel(priv,pprevious_stats);
+	 * rtl8190_process_cck_rxpathsel(priv,prev_stats);
 	 */
 
 	/* Check RSSI */
@@ -4114,8 +4114,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	/* <2> Showed on UI for engineering
 	 * hardware does not provide rssi information for each rf path in CCK
 	 */
-	if (!pprevious_stats->bIsCCK &&
-	    (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) {
+	if (!prev_stats->bIsCCK &&
+	    (prev_stats->bPacketToSelf || prev_stats->bToSelfBA)) {
 		for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) {
 			if (!rtl8192_phy_CheckIsLegalRFPath(
 					priv->ieee80211->dev, rfpath))
@@ -4123,16 +4123,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 			if (priv->stats.rx_rssi_percentage[rfpath] == 0)
 				priv->stats.rx_rssi_percentage[rfpath] =
-					pprevious_stats->RxMIMOSignalStrength[rfpath];
-			if (pprevious_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
+					prev_stats->RxMIMOSignalStrength[rfpath];
+			if (prev_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
 				priv->stats.rx_rssi_percentage[rfpath] =
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
+					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
 				priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath]  + 1;
 			} else {
 				priv->stats.rx_rssi_percentage[rfpath] =
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
+					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
 			}
 			RT_TRACE(COMP_DBG,
 				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
@@ -4143,57 +4143,57 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	/* Check PWDB. */
 	RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
-		 pprevious_stats->bIsCCK ? "CCK" : "OFDM",
-		 pprevious_stats->RxPWDBAll);
+		 prev_stats->bIsCCK ? "CCK" : "OFDM",
+		 prev_stats->RxPWDBAll);
 
-	if (pprevious_stats->bPacketBeacon) {
+	if (prev_stats->bPacketBeacon) {
 		/* record the beacon pwdb to the sliding window. */
 		if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
 			slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
 			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
 			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
-		priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll;
-		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll;
+		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
+		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = prev_stats->RxPWDBAll;
 		slide_beacon_adc_pwdb_index++;
 		if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			slide_beacon_adc_pwdb_index = 0;
-		pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
-		if (pprevious_stats->RxPWDBAll >= 3)
-			pprevious_stats->RxPWDBAll -= 3;
+		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
+		if (prev_stats->RxPWDBAll >= 3)
+			prev_stats->RxPWDBAll -= 3;
 	}
 
 	RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
-		 pprevious_stats->bIsCCK ? "CCK" : "OFDM",
-		 pprevious_stats->RxPWDBAll);
+		 prev_stats->bIsCCK ? "CCK" : "OFDM",
+		 prev_stats->RxPWDBAll);
 
 
-	if (pprevious_stats->bPacketToSelf ||
-	    pprevious_stats->bPacketBeacon ||
-	    pprevious_stats->bToSelfBA) {
+	if (prev_stats->bPacketToSelf ||
+	    prev_stats->bPacketBeacon ||
+	    prev_stats->bToSelfBA) {
 		if (priv->undecorated_smoothed_pwdb < 0)
 			/* initialize */
 			priv->undecorated_smoothed_pwdb =
-				pprevious_stats->RxPWDBAll;
-		if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
+				prev_stats->RxPWDBAll;
+		if (prev_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
 			priv->undecorated_smoothed_pwdb =
 				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (pprevious_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
+				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
 			priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1;
 		} else {
 			priv->undecorated_smoothed_pwdb =
 				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (pprevious_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
+				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
 		}
 
 	}
 
 	/* Check EVM */
 	/* record the general EVM to the sliding window. */
-	if (pprevious_stats->SignalQuality) {
-		if (pprevious_stats->bPacketToSelf ||
-		    pprevious_stats->bPacketBeacon ||
-		    pprevious_stats->bToSelfBA) {
+	if (prev_stats->SignalQuality) {
+		if (prev_stats->bPacketToSelf ||
+		    prev_stats->bPacketBeacon ||
+		    prev_stats->bToSelfBA) {
 			if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
 				slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
 				last_evm = priv->stats.slide_evm[slide_evm_index];
@@ -4201,10 +4201,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 			}
 
 			priv->stats.slide_evm_total +=
-				pprevious_stats->SignalQuality;
+				prev_stats->SignalQuality;
 
 			priv->stats.slide_evm[slide_evm_index++] =
-				pprevious_stats->SignalQuality;
+				prev_stats->SignalQuality;
 			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
 				slide_evm_index = 0;
 
@@ -4219,16 +4219,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		}
 
 		/* <2> Showed on UI for engineering */
-		if (pprevious_stats->bPacketToSelf ||
-		    pprevious_stats->bPacketBeacon ||
-		    pprevious_stats->bToSelfBA) {
+		if (prev_stats->bPacketToSelf ||
+		    prev_stats->bPacketBeacon ||
+		    prev_stats->bToSelfBA) {
 			for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */
-				if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
+				if (prev_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
 					if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */
-						priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream];
+						priv->stats.rx_evm_percentage[nspatial_stream] = prev_stats->RxMIMOSignalQuality[nspatial_stream];
 					priv->stats.rx_evm_percentage[nspatial_stream] =
 						((priv->stats.rx_evm_percentage[nspatial_stream] * (Rx_Smooth_Factor - 1)) +
-						 (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor);
+						 (prev_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor);
 				}
 			}
 		}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (6 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 09/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte
                   ` (23 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Rename variable to a shorter name to allow easier code
refactoring in following patch.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 2a7d46d..25c4cbd 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4053,7 +4053,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	static u32 slide_evm_index, slide_evm_statistics;
 	static u32 last_rssi, last_evm;
 
-	static u32 slide_beacon_adc_pwdb_index;
+	static u32 sb_index;
 	static u32 slide_beacon_adc_pwdb_statistics;
 	static u32 last_beacon_adc_pwdb;
 
@@ -4150,14 +4150,14 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		/* record the beacon pwdb to the sliding window. */
 		if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
 			slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
-			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
+			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[sb_index];
 			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
 		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
-		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = prev_stats->RxPWDBAll;
-		slide_beacon_adc_pwdb_index++;
-		if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
-			slide_beacon_adc_pwdb_index = 0;
+		priv->stats.Slide_Beacon_pwdb[sb_index] = prev_stats->RxPWDBAll;
+		sb_index++;
+		if (sb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
+			sb_index = 0;
 		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
 		if (prev_stats->RxPWDBAll >= 3)
 			prev_stats->RxPWDBAll -= 3;
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 09/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (7 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Rename variable to a shorter name to allow easier code
refactoring in following patch.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 25c4cbd..d779506 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4054,7 +4054,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	static u32 last_rssi, last_evm;
 
 	static u32 sb_index;
-	static u32 slide_beacon_adc_pwdb_statistics;
+	static u32 sb_stats;
 	static u32 last_beacon_adc_pwdb;
 
 	struct rtl_80211_hdr_3addr *hdr;
@@ -4148,8 +4148,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	if (prev_stats->bPacketBeacon) {
 		/* record the beacon pwdb to the sliding window. */
-		if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
-			slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
+		if (sb_stats++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
+			sb_stats = PHY_Beacon_RSSI_SLID_WIN_MAX;
 			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[sb_index];
 			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
@@ -4158,7 +4158,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		sb_index++;
 		if (sb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			sb_index = 0;
-		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
+		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / sb_stats;
 		if (prev_stats->RxPWDBAll >= 3)
 			prev_stats->RxPWDBAll -= 3;
 	}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (8 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 09/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte
                   ` (21 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Local variable last_beacon_adc_pwdb was used to store a value that wasn't
used after. This patch removes that variable.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index d779506..100fbbe 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4055,7 +4055,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	static u32 sb_index;
 	static u32 sb_stats;
-	static u32 last_beacon_adc_pwdb;
 
 	struct rtl_80211_hdr_3addr *hdr;
 	u16 sc;
@@ -4150,8 +4149,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		/* record the beacon pwdb to the sliding window. */
 		if (sb_stats++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
 			sb_stats = PHY_Beacon_RSSI_SLID_WIN_MAX;
-			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[sb_index];
-			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
+			priv->stats.Slide_Beacon_Total -=
+				priv->stats.Slide_Beacon_pwdb[sb_index];
 		}
 		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
 		priv->stats.Slide_Beacon_pwdb[sb_index] = prev_stats->RxPWDBAll;
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (9 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte
                   ` (20 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Rename variable to a shorter name to allow easier code
refactoring in following patches.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 100fbbe..6bc92a7 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4047,7 +4047,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 				    struct ieee80211_rx_stats *pcurrent_stats)
 {
 	bool bcheck = false;
-	u8	rfpath;
+	u8 rfp;
 	u32	nspatial_stream, tmp_val;
 	static u32 slide_rssi_index, slide_rssi_statistics;
 	static u32 slide_evm_index, slide_evm_statistics;
@@ -4115,27 +4115,28 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	 */
 	if (!prev_stats->bIsCCK &&
 	    (prev_stats->bPacketToSelf || prev_stats->bToSelfBA)) {
-		for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) {
+		for (rfp = RF90_PATH_A; rfp < priv->NumTotalRFPath; rfp++) {
 			if (!rtl8192_phy_CheckIsLegalRFPath(
-					priv->ieee80211->dev, rfpath))
+					priv->ieee80211->dev, rfp))
 				continue;
 
-			if (priv->stats.rx_rssi_percentage[rfpath] == 0)
-				priv->stats.rx_rssi_percentage[rfpath] =
-					prev_stats->RxMIMOSignalStrength[rfpath];
-			if (prev_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
-				priv->stats.rx_rssi_percentage[rfpath] =
-					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
-				priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath]  + 1;
+			if (priv->stats.rx_rssi_percentage[rfp] == 0)
+				priv->stats.rx_rssi_percentage[rfp] =
+					prev_stats->RxMIMOSignalStrength[rfp];
+
+			if (prev_stats->RxMIMOSignalStrength[rfp]  > priv->stats.rx_rssi_percentage[rfp]) {
+				priv->stats.rx_rssi_percentage[rfp] =
+					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
+					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
+				priv->stats.rx_rssi_percentage[rfp] = priv->stats.rx_rssi_percentage[rfp]  + 1;
 			} else {
-				priv->stats.rx_rssi_percentage[rfpath] =
-					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
+				priv->stats.rx_rssi_percentage[rfp] =
+					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
+					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
 			}
 			RT_TRACE(COMP_DBG,
 				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
-				 priv->stats.rx_rssi_percentage[rfpath]);
+				 priv->stats.rx_rssi_percentage[rfp]);
 		}
 	}
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (10 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte
                   ` (19 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Reorganize function to make it cleaner, and respect the 80 characters
kernel code style rule.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 140 +++++++++++++++++++--------------
 1 file changed, 81 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 6bc92a7..ba33b96 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4116,6 +4116,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	if (!prev_stats->bIsCCK &&
 	    (prev_stats->bPacketToSelf || prev_stats->bToSelfBA)) {
 		for (rfp = RF90_PATH_A; rfp < priv->NumTotalRFPath; rfp++) {
+			u8 rx, add = 0;
+
 			if (!rtl8192_phy_CheckIsLegalRFPath(
 					priv->ieee80211->dev, rfp))
 				continue;
@@ -4124,16 +4126,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 				priv->stats.rx_rssi_percentage[rfp] =
 					prev_stats->RxMIMOSignalStrength[rfp];
 
-			if (prev_stats->RxMIMOSignalStrength[rfp]  > priv->stats.rx_rssi_percentage[rfp]) {
-				priv->stats.rx_rssi_percentage[rfp] =
-					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
-				priv->stats.rx_rssi_percentage[rfp] = priv->stats.rx_rssi_percentage[rfp]  + 1;
-			} else {
-				priv->stats.rx_rssi_percentage[rfp] =
-					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
-			}
+			rx = priv->stats.rx_rssi_percentage[rfp];
+			if (prev_stats->RxMIMOSignalStrength[rfp] > rx)
+				add = 1;
+
+			rx *= Rx_Smooth_Factor - 1;
+			rx += prev_stats->RxMIMOSignalStrength[rfp];
+			rx /= Rx_Smooth_Factor;
+
+			priv->stats.rx_rssi_percentage[rfp] = rx + add;
+
 			RT_TRACE(COMP_DBG,
 				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
 				 priv->stats.rx_rssi_percentage[rfp]);
@@ -4153,12 +4155,17 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 			priv->stats.Slide_Beacon_Total -=
 				priv->stats.Slide_Beacon_pwdb[sb_index];
 		}
+
 		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
 		priv->stats.Slide_Beacon_pwdb[sb_index] = prev_stats->RxPWDBAll;
+
 		sb_index++;
 		if (sb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			sb_index = 0;
-		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / sb_stats;
+
+		prev_stats->RxPWDBAll =
+			priv->stats.Slide_Beacon_Total / sb_stats;
+
 		if (prev_stats->RxPWDBAll >= 3)
 			prev_stats->RxPWDBAll -= 3;
 	}
@@ -4171,69 +4178,84 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	if (prev_stats->bPacketToSelf ||
 	    prev_stats->bPacketBeacon ||
 	    prev_stats->bToSelfBA) {
+		long pwdb, add = 0;
+
 		if (priv->undecorated_smoothed_pwdb < 0)
 			/* initialize */
 			priv->undecorated_smoothed_pwdb =
 				prev_stats->RxPWDBAll;
-		if (prev_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
-			priv->undecorated_smoothed_pwdb =
-				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
-			priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1;
-		} else {
-			priv->undecorated_smoothed_pwdb =
-				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
-		}
 
+		pwdb = priv->undecorated_smoothed_pwdb;
+
+		if (prev_stats->RxPWDBAll > (u32)pwdb)
+			add = 1;
+
+		pwdb *= Rx_Smooth_Factor - 1;
+		pwdb += prev_stats->RxPWDBAll;
+		pwdb /= Rx_Smooth_Factor;
+
+		priv->undecorated_smoothed_pwdb = pwdb + add;
 	}
 
+
 	/* Check EVM */
+	if (!prev_stats->SignalQuality)
+		return;
+
 	/* record the general EVM to the sliding window. */
-	if (prev_stats->SignalQuality) {
-		if (prev_stats->bPacketToSelf ||
-		    prev_stats->bPacketBeacon ||
-		    prev_stats->bToSelfBA) {
-			if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
-				slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
-				last_evm = priv->stats.slide_evm[slide_evm_index];
-				priv->stats.slide_evm_total -= last_evm;
-			}
+	if (prev_stats->bPacketToSelf ||
+	    prev_stats->bPacketBeacon ||
+	    prev_stats->bToSelfBA) {
+		if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
+			slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
+			last_evm = priv->stats.slide_evm[slide_evm_index];
+			priv->stats.slide_evm_total -= last_evm;
+		}
 
-			priv->stats.slide_evm_total +=
-				prev_stats->SignalQuality;
+		priv->stats.slide_evm_total += prev_stats->SignalQuality;
 
-			priv->stats.slide_evm[slide_evm_index++] =
-				prev_stats->SignalQuality;
-			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
-				slide_evm_index = 0;
+		priv->stats.slide_evm[slide_evm_index++] =
+			prev_stats->SignalQuality;
+		if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
+			slide_evm_index = 0;
 
-			/* <1> Showed on UI for user, in percentage. */
-			tmp_val = priv->stats.slide_evm_total /
-				  slide_evm_statistics;
-			priv->stats.signal_quality = tmp_val;
-			/* Showed on UI for user in Windows Vista,
-			 * for Link quality.
-			 */
-			priv->stats.last_signal_strength_inpercent = tmp_val;
-		}
+		/* <1> Showed on UI for user, in percentage. */
+		tmp_val = priv->stats.slide_evm_total / slide_evm_statistics;
+		priv->stats.signal_quality = tmp_val;
+		/* Showed on UI for user in Windows Vista,
+		 * for Link quality.
+		 */
+		priv->stats.last_signal_strength_inpercent = tmp_val;
+	}
 
-		/* <2> Showed on UI for engineering */
-		if (prev_stats->bPacketToSelf ||
-		    prev_stats->bPacketBeacon ||
-		    prev_stats->bToSelfBA) {
-			for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */
-				if (prev_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
-					if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */
-						priv->stats.rx_evm_percentage[nspatial_stream] = prev_stats->RxMIMOSignalQuality[nspatial_stream];
-					priv->stats.rx_evm_percentage[nspatial_stream] =
-						((priv->stats.rx_evm_percentage[nspatial_stream] * (Rx_Smooth_Factor - 1)) +
-						 (prev_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor);
-				}
-			}
+	/* <2> Showed on UI for engineering */
+	if (!prev_stats->bPacketToSelf &&
+	    !prev_stats->bPacketBeacon &&
+	    !prev_stats->bToSelfBA)
+		return;
+
+	/* 2 spatial stream */
+	for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) {
+		u8 utmp;
+		s8 stmp;
+
+		if (prev_stats->RxMIMOSignalQuality[nspatial_stream] == -1)
+			continue;
+
+		/* initialize */
+		if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) {
+			stmp = prev_stats->RxMIMOSignalQuality[nspatial_stream];
+			priv->stats.rx_evm_percentage[nspatial_stream] = stmp;
 		}
-	}
 
+		utmp = priv->stats.rx_evm_percentage[nspatial_stream];
+		utmp *= Rx_Smooth_Factor - 1;
+
+		stmp = prev_stats->RxMIMOSignalQuality[nspatial_stream];
+
+		priv->stats.rx_evm_percentage[nspatial_stream] =
+			(utmp + stmp) / Rx_Smooth_Factor;
+	}
 
 }
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (11 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 14/16] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte
                   ` (18 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Replace some inline conditions by a full if-else statement to make
the source clearer and follow the 80 characters kernel code style
rule.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index ba33b96..189de56 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1596,12 +1596,18 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	tx_fwinfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0;
 	tx_fwinfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0;
 	tx_fwinfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0;
-	tx_fwinfo->RtsHT = (tcb_desc->rts_rate & 0x80) ? 1 : 0;
 	tx_fwinfo->RtsRate =  MRateToHwRate8190Pci((u8)tcb_desc->rts_rate);
-	tx_fwinfo->RtsSubcarrier = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->RTSSC) : 0;
-	tx_fwinfo->RtsBandwidth = (tx_fwinfo->RtsHT == 1) ? ((tcb_desc->bRTSBW) ? 1 : 0) : 0;
-	tx_fwinfo->RtsShort = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) :
-			      (tcb_desc->bRTSUseShortGI ? 1 : 0);
+	if (tcb_desc->rts_rate & 0x80) {
+		tx_fwinfo->RtsHT = 1;
+		tx_fwinfo->RtsSubcarrier = 0;
+		tx_fwinfo->RtsBandwidth = (tcb_desc->bRTSBW) ? 1 : 0;
+		tx_fwinfo->RtsShort = (tcb_desc->bRTSUseShortGI ? 1 : 0);
+	} else {
+		tx_fwinfo->RtsHT = 0;
+		tx_fwinfo->RtsSubcarrier = tcb_desc->RTSSC;
+		tx_fwinfo->RtsBandwidth = 0;
+		tx_fwinfo->RtsShort = (tcb_desc->bRTSUseShortPreamble ? 1 : 0);
+	}
 
 	/* Set Bandwidth and sub-channel settings. */
 	if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) {
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 14/16] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (12 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte
                   ` (17 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

Reorganize function rtl8192_ioctl to replace a switch with only
one case besides the default by an if statement. This also allows
to follow the 80 characters kernel code style rule.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 141 ++++++++++++++++-----------------
 1 file changed, 68 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 189de56..f81f267 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3801,82 +3801,77 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 		goto out;
 	}
 
-	switch (cmd) {
-	case RTL_IOCTL_WPA_SUPPLICANT:
-		/* parse here for HW security */
-		if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) {
-			if (ipw->u.crypt.set_tx) {
-				if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
-					ieee->pairwise_key_type = KEY_TYPE_CCMP;
-				} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
-					ieee->pairwise_key_type = KEY_TYPE_TKIP;
-				} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
-					if (ipw->u.crypt.key_len == 13)
-						ieee->pairwise_key_type = KEY_TYPE_WEP104;
-					else if (ipw->u.crypt.key_len == 5)
-						ieee->pairwise_key_type = KEY_TYPE_WEP40;
-				} else {
-					ieee->pairwise_key_type = KEY_TYPE_NA;
-				}
-
-				if (ieee->pairwise_key_type) {
-					memcpy((u8 *)key, ipw->u.crypt.key, 16);
-					EnableHWSecurityConfig8192(dev);
-					/* We fill both index entry and 4th
-					 * entry for pairwise key as in IPW
-					 * interface, adhoc will only get here,
-					 * so we need index entry for its
-					 * default key serching!
-					 */
-					setKey(dev, 4, ipw->u.crypt.idx,
-					       ieee->pairwise_key_type,
-					       (u8 *)ieee->ap_mac_addr,
-					       0, key);
-					if (ieee->auth_mode != 2)
-						setKey(dev, ipw->u.crypt.idx,
-						       ipw->u.crypt.idx,
-						       ieee->pairwise_key_type,
-						       (u8 *)ieee->ap_mac_addr,
-						       0, key);
-				}
-			} else {
-				memcpy((u8 *)key, ipw->u.crypt.key, 16);
-				if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
-					ieee->group_key_type = KEY_TYPE_CCMP;
-				} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
-					ieee->group_key_type = KEY_TYPE_TKIP;
-				} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
-					if (ipw->u.crypt.key_len == 13)
-						ieee->group_key_type = KEY_TYPE_WEP104;
-					else if (ipw->u.crypt.key_len == 5)
-						ieee->group_key_type = KEY_TYPE_WEP40;
-				} else {
-					ieee->group_key_type = KEY_TYPE_NA;
-				}
-
-				if (ieee->group_key_type) {
-					setKey(dev, ipw->u.crypt.idx,
-					       /* KeyIndex */
-					       ipw->u.crypt.idx,
-					       /* KeyType */
-					       ieee->group_key_type,
-					       /* MacAddr */
-					       broadcast_addr,
-					       /* DefaultKey */
-					       0,
-					       /* KeyContent */
-					       key);
-				}
-			}
+	if (cmd != RTL_IOCTL_WPA_SUPPLICANT) {
+		ret = -EOPNOTSUPP;
+		goto kfree;
+	}
+
+	/* parse here for HW security */
+	if (ipw->cmd != IEEE_CMD_SET_ENCRYPTION)
+		goto ret;
+
+	if (ipw->u.crypt.set_tx) {
+		if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
+			ieee->pairwise_key_type = KEY_TYPE_CCMP;
+		} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
+			ieee->pairwise_key_type = KEY_TYPE_TKIP;
+		} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
+			if (ipw->u.crypt.key_len == 13)
+				ieee->pairwise_key_type = KEY_TYPE_WEP104;
+			else if (ipw->u.crypt.key_len == 5)
+				ieee->pairwise_key_type = KEY_TYPE_WEP40;
+		} else {
+			ieee->pairwise_key_type = KEY_TYPE_NA;
 		}
-		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
-						     &wrq->u.data);
-		break;
 
-	default:
-		ret = -EOPNOTSUPP;
-		break;
+		if (ieee->pairwise_key_type) {
+			memcpy((u8 *)key, ipw->u.crypt.key, 16);
+			EnableHWSecurityConfig8192(dev);
+			/* We fill both index entry and 4th
+			 * entry for pairwise key as in IPW
+			 * interface, adhoc will only get here,
+			 * so we need index entry for its
+			 * default key serching!
+			 */
+			setKey(dev, 4, ipw->u.crypt.idx,
+			       ieee->pairwise_key_type,
+			       (u8 *)ieee->ap_mac_addr, 0, key);
+			if (ieee->auth_mode != 2)
+				setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx,
+				       ieee->pairwise_key_type,
+				       (u8 *)ieee->ap_mac_addr, 0, key);
+		}
+	} else {
+		memcpy((u8 *)key, ipw->u.crypt.key, 16);
+		if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
+			ieee->group_key_type = KEY_TYPE_CCMP;
+		} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
+			ieee->group_key_type = KEY_TYPE_TKIP;
+		} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
+			if (ipw->u.crypt.key_len == 13)
+				ieee->group_key_type = KEY_TYPE_WEP104;
+			else if (ipw->u.crypt.key_len == 5)
+				ieee->group_key_type = KEY_TYPE_WEP40;
+		} else {
+			ieee->group_key_type = KEY_TYPE_NA;
+		}
+
+		if (ieee->group_key_type) {
+			setKey(dev, ipw->u.crypt.idx,
+			       ipw->u.crypt.idx, /* KeyIndex */
+			       ieee->group_key_type, /* KeyType */
+			       broadcast_addr, /* MacAddr */
+			       0, /* DefaultKey */
+			       key); /* KeyContent */
+
+		}
 	}
+
+ret:
+	ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
+					     &wrq->u.data);
+
+kfree:
 	kfree(ipw);
 	ipw = NULL;
 out:
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {}
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (13 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 14/16] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-11  7:29 ` [PATCHv2 16/16] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte
                   ` (16 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Cristina Opriceana, devel,
	linux-kernel

An else block only contained an if statement. Replace that else
block by an else if block instead.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index f81f267..0d169d0 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4563,15 +4563,13 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 		pstats->SignalStrength =
 			precord_stats->SignalStrength =
 			(u8)(rtl819x_signal_scale_mapping((long)pwdb_all));
-	} else {
+	} else if (rf_rx_num != 0) {
 		/* We can judge RX path number now. */
-		if (rf_rx_num != 0) {
-			long currsig = (total_rssi /= rf_rx_num);
+		long currsig = (total_rssi /= rf_rx_num);
 
-			pstats->SignalStrength =
-				precord_stats->SignalStrength =
-				(u8)(rtl819x_signal_scale_mapping(currsig));
-		}
+		pstats->SignalStrength =
+			precord_stats->SignalStrength =
+			(u8)(rtl819x_signal_scale_mapping(currsig));
 	}
 }	/* QueryRxPhyStatus8190Pci */
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv2 16/16] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (14 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte
@ 2015-09-11  7:29 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 00/15] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (15 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-11  7:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dan Carpenter, Raphaël Beamonte, Paul Gortmaker,
	Cristina Opriceana, Marti Bolivar, Ragnar B. Johannsson,
	Andy Shevchenko, Joe Perches, Navya Sri Nizamkari,
	Luis de Bethencourt, Arnd Bergmann, Greg Donald,
	Ksenija Stanojevic, Aya Mahfouz, Haneen Mohammed, Rene Kolarik,
	Somya Anand, Vaishali Thakkar, Hatice ERTÜRK,
	Melike Yurtoglu, devel, linux-kernel

The symbol TO_DO_LIST was used in the code to frame sections
of code unused or unusable. This patch remove all code framed
by that symbol in this driver.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h     |   4 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |  23 -----
 .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c    |   4 -
 .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c    |   5 +-
 drivers/staging/rtl8192u/r8192U_core.c             | 102 ++-------------------
 drivers/staging/rtl8192u/r819xU_phy.c              |  57 ------------
 6 files changed, 9 insertions(+), 186 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index d481a26..28ba7d2 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -1654,10 +1654,10 @@ struct ieee80211_device {
 	struct list_head		Rx_TS_Pending_List;
 	struct list_head		Rx_TS_Unused_List;
 	RX_TS_RECORD		RxTsRecord[TOTAL_TS_NUM];
-//#ifdef TO_DO_LIST
+	
 	RX_REORDER_ENTRY	RxReorderEntry[128];
 	struct list_head		RxReorder_Unused_List;
-//#endif
+	
 	// Qos related. Added by Annie, 2005-11-01.
 //	PSTA_QOS			pStaQos;
 	u8				ForcedPriority;		// Force per-packet priority 1~7. (default: 0, not to force it.)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index fff8d58..7bbe934 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -318,13 +318,6 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee,
 	if (is_multicast_ether_addr(hdr->addr1))
 		return;
 	//check packet and mode later
-#ifdef TO_DO_LIST
-	if(pTcb->PacketLength >= 4096)
-		return;
-	// For RTL819X, if pairwisekey = wep/tkip, we don't aggrregation.
-	if(!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter))
-		return;
-#endif
 	if(!ieee->GetNmodeSupportBySecCfg(ieee->dev))
 	{
 		return;
@@ -550,22 +543,6 @@ NO_PROTECTION:
 static void ieee80211_txrate_selectmode(struct ieee80211_device *ieee,
 					cb_desc *tcb_desc)
 {
-#ifdef TO_DO_LIST
-	if(!IsDataFrame(pFrame))
-	{
-		pTcb->bTxDisableRateFallBack = true;
-		pTcb->bTxUseDriverAssingedRate = true;
-		pTcb->RATRIndex = 7;
-		return;
-	}
-
-	if(pMgntInfo->ForcedDataRate!= 0)
-	{
-		pTcb->bTxDisableRateFallBack = true;
-		pTcb->bTxUseDriverAssingedRate = true;
-		return;
-	}
-#endif
 	if(ieee->bTxDisableRateFallBack)
 		tcb_desc->bTxDisableRateFallBack = true;
 
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
index c27397b..87b1bb9 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
@@ -88,10 +88,6 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee)
 	ieee->bTxDisableRateFallBack = 0;
 	ieee->bTxUseDriverAssingedRate = 0;
 
-#ifdef	TO_DO_LIST
-	// 8190 only. Assign duration operation mode to firmware
-	pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
-#endif
 	// 8190 only, Realtek proprietary aggregation mode
 	// Set MPDUDensity=2,   1: Set MPDUDensity=2(32k)  for Realtek AP and set MPDUDensity=0(8k) for others
 	pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2,   1: Set MPDUDensity=2(32k)  for Realtek AP and set MPDUDensity=0(8k) for others
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index f33c743..fb493a2 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -193,7 +193,7 @@ void TSInitialize(struct ieee80211_device *ieee)
 	}
 	// Initialize unused Rx Reorder List.
 	INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
-//#ifdef TO_DO_LIST
+
 	for(count = 0; count < REORDER_ENTRY_NUM; count++)
 	{
 		list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
@@ -201,7 +201,6 @@ void TSInitialize(struct ieee80211_device *ieee)
 			break;
 		pRxReorderEntry = &ieee->RxReorderEntry[count+1];
 	}
-//#endif
 
 }
 
@@ -461,7 +460,6 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs,
 
 	if(TxRxSelect == RX_DIR)
 	{
-//#ifdef TO_DO_LIST
 		PRX_REORDER_ENTRY	pRxReorderEntry;
 		PRX_TS_RECORD		pRxTS = (PRX_TS_RECORD)pTs;
 		if(timer_pending(&pRxTS->RxPktPendingTimer))
@@ -493,7 +491,6 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs,
 			spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
 		}
 
-//#endif
 	}
 	else
 	{
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 0d169d0..8b7efc2 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2217,14 +2217,7 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 			wireless_mode = WIRELESS_MODE_B;
 		}
 	}
-#ifdef TO_DO_LIST
-	/* TODO: this function doesn't work well at this time,
-	 * we should wait for FPGA
-	 */
-	ActUpdateChannelAccessSetting(
-			pAdapter, pHalData->CurrentWirelessMode,
-			&pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
-#endif
+
 	priv->ieee80211->mode = wireless_mode;
 
 	if (wireless_mode == WIRELESS_MODE_N_24G ||
@@ -2300,12 +2293,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 
 	priv->ieee80211->InitialGainHandler = InitialGain819xUsb;
 	priv->card_type = USB;
-#ifdef TO_DO_LIST
-	if (Adapter->bInHctTest) {
-		pHalData->ShortRetryLimit = 7;
-		pHalData->LongRetryLimit = 7;
-	}
-#endif
+
 	priv->ShortRetryLimit = 0x30;
 	priv->LongRetryLimit = 0x30;
 	priv->EarlyRxThreshold = 7;
@@ -2321,34 +2309,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 		 * TRUE: SW provides them
 		 */
 		(false ? TCR_SAT : 0);
-#ifdef TO_DO_LIST
-	if (Adapter->bInHctTest)
-		pHalData->ReceiveConfig =
-			pHalData->CSMethod |
-			/* accept management/data */
-			RCR_AMF | RCR_ADF |
-			/* accept control frame for SW
-			 * AP needs PS-poll
-			 */
-			RCR_ACF |
-			/* accept BC/MC/UC */
-			RCR_AB | RCR_AM | RCR_APM |
-			/* accept ICV/CRC error
-			 * packet
-			 */
-			RCR_AICV | RCR_ACRC32 |
-			/* Max DMA Burst Size per Tx
-			 * DMA Burst, 7: unlimited.
-			 */
-			((u32)7 << RCR_MXDMA_OFFSET) |
-			/* Rx FIFO Threshold,
-			 * 7: No Rx threshold.
-			 */
-			(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
-			(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
-	else
 
-#endif
 	priv->ReceiveConfig	=
 		/* accept management/data */
 		RCR_AMF | RCR_ADF |
@@ -2808,19 +2769,10 @@ static void rtl8192_hwconfig(struct net_device *dev)
 		regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		break;
 	case WIRELESS_MODE_AUTO:
-#ifdef TO_DO_LIST
-		if (Adapter->bInHctTest) {
-			regBwOpMode = BW_OPMODE_20MHZ;
-			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
-			regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
-		} else
-#endif
-		{
-			regBwOpMode = BW_OPMODE_20MHZ;
-			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
-				  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
-			regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
-		}
+		regBwOpMode = BW_OPMODE_20MHZ;
+		regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
+			  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+		regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		break;
 	case WIRELESS_MODE_N_24G:
 		/* It support CCK rate by default. CCK rate will be filtered
@@ -2994,48 +2946,6 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	}
 	RT_TRACE(COMP_INIT, "%s():after firmware download\n", __func__);
 
-#ifdef TO_DO_LIST
-	if (Adapter->ResetProgress == RESET_TYPE_NORESET) {
-		if (pMgntInfo->RegRfOff) { /* User disable RF via registry. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
-				 ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
-			MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
-			/* Those actions will be discard in MgntActSet_RF_State
-			 * because of the same state
-			 */
-			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter,
-					     (RF90_RADIO_PATH_E)eRFPath,
-					     0x4, 0xC00, 0x0);
-		} else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) {
-			/* H/W or S/W RF OFF before sleep. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
-				 ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n",
-				  pMgntInfo->RfOffReason));
-			MgntActSet_RF_State(Adapter,
-					    eRfOff,
-					    pMgntInfo->RfOffReason);
-		} else {
-			pHalData->eRFPowerState = eRfOn;
-			pMgntInfo->RfOffReason = 0;
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
-				 ("InitializeAdapter819xUsb(): RF is on ----------\n"));
-		}
-	} else {
-		if (pHalData->eRFPowerState == eRfOff) {
-			MgntActSet_RF_State(Adapter,
-					    eRfOff,
-					    pMgntInfo->RfOffReason);
-			/* Those actions will be discard in MgntActSet_RF_State
-			 * because of the same state
-			 */
-			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter,
-					     (RF90_RADIO_PATH_E)eRFPath,
-					     0x4, 0xC00, 0x0);
-		}
-	}
-#endif
 	/* config RF. */
 	if (priv->ResetProgress == RESET_TYPE_NORESET) {
 		rtl8192_phy_RFConfig(dev);
diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c
index e5dbaca..55c3577 100644
--- a/drivers/staging/rtl8192u/r819xU_phy.c
+++ b/drivers/staging/rtl8192u/r819xU_phy.c
@@ -523,16 +523,6 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType)
 {
 	u32 i;
 
-#ifdef TO_DO_LIST
-	u32 *rtl8192PhyRegArrayTable = NULL, *rtl8192AgcTabArrayTable = NULL;
-
-	if (Adapter->bInHctTest) {
-		PHY_REGArrayLen = PHY_REGArrayLengthDTM;
-		AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM;
-		Rtl8190PHY_REGArray_Table = Rtl819XPHY_REGArrayDTM;
-		Rtl8190AGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM;
-	}
-#endif
 	if (ConfigType == BaseBand_Config_PHY_REG) {
 		for (i = 0; i < PHY_REG_1T2RArrayLength; i += 2) {
 			rtl8192_setBBreg(dev, rtl819XPHY_REG_1T2RArray[i],
@@ -1063,10 +1053,6 @@ static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
 
 	switch (priv->rf_chip) {
 	case RF_8225:
-#ifdef TO_DO_LIST
-		PHY_SetRF8225CckTxPower(Adapter, powerlevel);
-		PHY_SetRF8225OfdmTxPower(Adapter, powerlevelOFDM24G);
-#endif
 		break;
 
 	case RF_8256:
@@ -1164,47 +1150,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev,
 		RT_TRACE(COMP_ERR, "Not support rf_chip(%x)\n", priv->rf_chip);
 		break;
 	}
-#ifdef TO_DO_LIST
-	if (bResult) {
-		/* Update current RF state variable. */
-		pHalData->eRFPowerState = eRFPowerState;
-		switch (pHalData->RFChipID) {
-		case RF_8256:
-			switch (pHalData->eRFPowerState) {
-			case eRfOff:
-				/* If Rf off reason is from IPS,
-				   LED should blink with no link */
-				if (pMgntInfo->RfOffReason == RF_CHANGE_BY_IPS)
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK);
-				else
-					/* Turn off LED if RF is not ON. */
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF);
-				break;
-
-			case eRfOn:
-				/* Turn on RF we are still linked, which might
-				   happen when we quickly turn off and on HW RF.
-				 */
-				if (pMgntInfo->bMediaConnect)
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK);
-				else
-					/* Turn off LED if RF is not ON. */
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK);
-				break;
-
-			default:
-				break;
-			}
-			break;
-
-		default:
-			RT_TRACE(COMP_RF, DBG_LOUD, "%s(): Unknown RF type\n",
-				 __func__);
-			break;
-		}
 
-	}
-#endif
 	priv->SetRFPowerStateInProgress = false;
 
 	return bResult;
@@ -1629,9 +1575,6 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
 	/* <3> Set RF related register */
 	switch (priv->rf_chip) {
 	case RF_8225:
-#ifdef TO_DO_LIST
-		PHY_SetRF8225Bandwidth(Adapter, pHalData->CurrentChannelBW);
-#endif
 		break;
 
 	case RF_8256:
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters
  2015-09-11  7:29 ` [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under " Raphaël Beamonte
@ 2015-09-17  4:55   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 40+ messages in thread
From: Greg Kroah-Hartman @ 2015-09-17  4:55 UTC (permalink / raw)
  To: Raphaël Beamonte
  Cc: Cristina Opriceana, devel, linux-kernel, Dan Carpenter

On Fri, Sep 11, 2015 at 03:29:10AM -0400, Raphaël Beamonte wrote:
> Add line breaks in multiple lines to keep them under 80 characters,
> as to follow the kernel code style.
> 
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 626 ++++++++++++++++++++++-----------
>  1 file changed, 421 insertions(+), 205 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 5e9d0ac..37c17eb 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -144,25 +144,31 @@ struct CHANNEL_LIST {
>  
>  static struct CHANNEL_LIST ChannelPlan[] = {
>  	/* FCC */
> -	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24},
> +	{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64,
> +	  149, 153, 157, 161, 165}, 24},

But now these look worse than before.  I say just leave these long
variables as-is.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-11  7:29 ` [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
@ 2015-09-17  4:57   ` Greg Kroah-Hartman
  2015-09-17  5:06     ` Raphaël Beamonte
  0 siblings, 1 reply; 40+ messages in thread
From: Greg Kroah-Hartman @ 2015-09-17  4:57 UTC (permalink / raw)
  To: Raphaël Beamonte
  Cc: Cristina Opriceana, devel, linux-kernel, Dan Carpenter

On Fri, Sep 11, 2015 at 03:29:11AM -0400, Raphaël Beamonte wrote:
> Add some temporary variables to reduce line length under the maximum
> of 80 characters, as per the kernel code style.
> 
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
>  1 file changed, 94 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 37c17eb..c8724cd 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -177,6 +177,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>  {
>  	int i, max_chan = -1, min_chan = -1;
>  	struct ieee80211_device *ieee = priv->ieee80211;
> +	struct CHANNEL_LIST cl;
>  
>  	switch (channel_plan) {
>  	case COUNTRY_CODE_FCC:
> @@ -200,15 +201,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>  				 "unknown rf chip, can't set channel map in function:%s()\n",
>  				 __func__);
>  		}
> -		if (ChannelPlan[channel_plan].Len != 0) {
> +		cl = ChannelPlan[channel_plan];
> +		if (cl.Len != 0) {
>  			/* Clear old channel map */
>  			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
>  			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
>  			/* Set new channel map */
> -			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
> -				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
> +			for (i = 0; i < cl.Len; i++) {
> +				u8 chan = cl.Channel[i];
> +
> +				if (chan < min_chan || chan > max_chan)
>  					break;
> -				GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
> +				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
>  			}
>  		}
>  		break;
> @@ -1699,9 +1703,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  					  &zero, 0, tx_zero_isr, dev);
>  			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
>  			if (status) {
> +				atomic_t tx =
> +					priv->tx_pending[tcb_desc->queue_index];
> +
>  				RT_TRACE(COMP_ERR,
>  					 "Error TX URB for zero byte %d, error %d",
> -					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
> +					 atomic_read(&tx),
>  					 status);
>  				return -1;
>  			}
> @@ -1748,8 +1755,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
>  		oldaddr = priv->oldaddr;
>  		align = ((long)oldaddr) & 3;
>  		if (align) {
> -			newaddr = oldaddr + 4 - align;
> -			priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
> +			align = 4 - align;
> +			newaddr = oldaddr + align;
> +			priv->rx_urb[16]->transfer_buffer_length = 16 - align;

At a quick glance, this conversion looks wrong...

And it's not what your changelog text said you were doing :(


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-17  4:57   ` Greg Kroah-Hartman
@ 2015-09-17  5:06     ` Raphaël Beamonte
  2015-09-17  5:18       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-17  5:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Cristina Opriceana, devel, lkml, Dan Carpenter

2015-09-17 0:57 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
<SNIP>
>> @@ -1748,8 +1755,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
>>               oldaddr = priv->oldaddr;
>>               align = ((long)oldaddr) & 3;
>>               if (align) {
>> -                     newaddr = oldaddr + 4 - align;
>> -                     priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
>> +                     align = 4 - align;
>> +                     newaddr = oldaddr + align;
>> +                     priv->rx_urb[16]->transfer_buffer_length = 16 - align;
>
> At a quick glance, this conversion looks wrong...

What is wrong with it?

oldaddr + 4 - align;
can also be read:
oldaddr + (4 - align);

as well as
16 - 4 + align;
can also be read
16 - (4 - align);
as when we remove the parenthesis, the - sign invert the parenthesis
elements signs.

Calculating (4 - align) previously thus preserve the logic here!

> And it's not what your changelog text said you were doing :(

It's true that I didn't add a new temporary variable here but instead
re-used one that is not used after, but I thought it went in the same
idea as the rest of this patch. Should I separate that as another
patch?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-17  5:06     ` Raphaël Beamonte
@ 2015-09-17  5:18       ` Greg Kroah-Hartman
  2015-09-17 18:26         ` Raphaël Beamonte
  0 siblings, 1 reply; 40+ messages in thread
From: Greg Kroah-Hartman @ 2015-09-17  5:18 UTC (permalink / raw)
  To: Raphaël Beamonte; +Cc: Cristina Opriceana, devel, lkml, Dan Carpenter

On Thu, Sep 17, 2015 at 01:06:33AM -0400, Raphaël Beamonte wrote:
> 2015-09-17 0:57 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
> <SNIP>
> >> @@ -1748,8 +1755,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
> >>               oldaddr = priv->oldaddr;
> >>               align = ((long)oldaddr) & 3;
> >>               if (align) {
> >> -                     newaddr = oldaddr + 4 - align;
> >> -                     priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
> >> +                     align = 4 - align;
> >> +                     newaddr = oldaddr + align;
> >> +                     priv->rx_urb[16]->transfer_buffer_length = 16 - align;
> >
> > At a quick glance, this conversion looks wrong...
> 
> What is wrong with it?
> 
> oldaddr + 4 - align;
> can also be read:
> oldaddr + (4 - align);
> 
> as well as
> 16 - 4 + align;
> can also be read
> 16 - (4 - align);
> as when we remove the parenthesis, the - sign invert the parenthesis
> elements signs.
> 
> Calculating (4 - align) previously thus preserve the logic here!

Ugh, it's been a long day, yeah, ok, this is the same, you are right.

But step back please, what exactly is this trying to do?  I think it's a
round_up type function, perhaps that should be what we do instead (the
kernel has such functions already.)

> > And it's not what your changelog text said you were doing :(
> 
> It's true that I didn't add a new temporary variable here but instead
> re-used one that is not used after, but I thought it went in the same
> idea as the rest of this patch. Should I separate that as another
> patch?

It might be the same "idea", but it's not what you did, so don't try to
sneak it in.

greg k-h

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-17  5:18       ` Greg Kroah-Hartman
@ 2015-09-17 18:26         ` Raphaël Beamonte
  0 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-17 18:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Cristina Opriceana, devel, lkml, Dan Carpenter

2015-09-17 1:18 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
> On Thu, Sep 17, 2015 at 01:06:33AM -0400, Raphaël Beamonte wrote:
>> 2015-09-17 0:57 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
>> <SNIP>
>> >> @@ -1748,8 +1755,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
>> >>               oldaddr = priv->oldaddr;
>> >>               align = ((long)oldaddr) & 3;
>> >>               if (align) {
>> >> -                     newaddr = oldaddr + 4 - align;
>> >> -                     priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
>> >> +                     align = 4 - align;
>> >> +                     newaddr = oldaddr + align;
>> >> +                     priv->rx_urb[16]->transfer_buffer_length = 16 - align;
>> >
<SNIP>
>
> But step back please, what exactly is this trying to do?  I think it's a
> round_up type function, perhaps that should be what we do instead (the
> kernel has such functions already.)

I think it's trying to get a 4-alignment for the transfer_buffer
stored in priv->rx_urb[16].
If our alignment is not correct, and there is for instance X needed to
align (X < 4), we move the address of X, and reduce the buffer size of
X.
I looked at the code of round_up (also round_down and __round_mask) in
the kernel, but I'm not totally sure how we would use it here?

> It might be the same "idea", but it's not what you did, so don't try to
> sneak it in.

That wasn't my intention. Sorry for that.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCHv3 00/15] staging: rtl8192u: code clean up
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (15 preceding siblings ...)
  2015-09-11  7:29 ` [PATCHv2 16/16] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 01/15] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters Raphaël Beamonte
                   ` (14 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Paul Gortmaker, Cristina Opriceana,
	Andrew Morton, Joe Perches, Marti Bolivar, Andy Shevchenko,
	Ksenija Stanojevic, Greg Donald, Arnd Bergmann,
	Luis de Bethencourt, Shraddha Barke, Navya Sri Nizamkari,
	Haneen Mohammed, Aya Mahfouz, Vaishali Thakkar, Somya Anand,
	Rene Kolarik, Melike Yurtoglu, Hatice ERTÜRK, devel,
	linux-kernel

Hi,

Following Greg's comments on the previous version, here's an
updated and rebased one without the already committed patch.

Difference with v2:
 - Some line breaks were removed as it was less readable with
   them (patch 01)
 - A temporary variable has been created instead of reusing an
   existing variable (patch 02)

Thanks,
- R.


Raphaël Beamonte (15):
  staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80
    characters
  staging: rtl8192u: r8192U_core: add temporary variables to keep lines
    under 80 characters
  staging: rtl8192u: r8192U_core: reverse conditions to get lines under
    80 characters
  staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize
    function
  staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize
    function
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable pprevious_stats to prev_stats
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable slide_beacon_adc_pwdb_index to sb_index
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable slide_beacon_adc_pwdb_statistics to sb_stats
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove
    unneeded variable
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename
    variable rfpath to rfp
  staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize
    function
  staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline
    conditions
  staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function
  staging: rtl8192u: r8192U_core: replace else { if() {} } by else if ()
    {}
  staging: rtl8192u: remove all code framed by symbol TO_DO_LIST

 drivers/staging/rtl8192u/ieee80211/ieee80211.h     |    4 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |   23 -
 .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c    |    4 -
 .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c    |    5 +-
 drivers/staging/rtl8192u/r8192U_core.c             | 1392 ++++++++++++--------
 drivers/staging/rtl8192u/r819xU_phy.c              |   57 -
 6 files changed, 822 insertions(+), 663 deletions(-)

-- 
2.5.1


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCHv3 01/15] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (16 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 00/15] staging: rtl8192u: code clean up Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Add line breaks in multiple lines to keep them under 80 characters,
as to follow the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 608 ++++++++++++++++++++++-----------
 1 file changed, 409 insertions(+), 199 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index d243989..28b54ba 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -190,11 +190,14 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 			min_chan = 1;
 			max_chan = 14;
 		} else {
-			RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __func__);
+			RT_TRACE(COMP_ERR,
+				 "unknown rf chip, can't set channel map in function:%s()\n",
+				 __func__);
 		}
 		if (ChannelPlan[channel_plan].Len != 0) {
 			/* Clear old channel map */
-			memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map));
+			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
+			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
 			/* Set new channel map */
 			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
 				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
@@ -262,7 +265,8 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
 				 indx | 0xfe00, 0, &data, 1, HZ / 2);
 
 	if (status < 0)
-		netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n", status);
+		netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n",
+			   status);
 }
 
 int read_nic_byte_E(struct net_device *dev, int indx, u8 *data)
@@ -292,7 +296,8 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data)
 
 	status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, &data, 1, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 &data, 1, HZ / 2);
 
 	if (status < 0)
 		netdev_err(dev, "write_nic_byte TimeOut! status: %d\n", status);
@@ -311,7 +316,8 @@ void write_nic_word(struct net_device *dev, int indx, u16 data)
 
 	status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, &data, 2, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 &data, 2, HZ / 2);
 
 	if (status < 0)
 		netdev_err(dev, "write_nic_word TimeOut! status: %d\n", status);
@@ -329,11 +335,13 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data)
 
 	status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, &data, 4, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 &data, 4, HZ / 2);
 
 
 	if (status < 0)
-		netdev_err(dev, "write_nic_dword TimeOut! status: %d\n", status);
+		netdev_err(dev, "write_nic_dword TimeOut! status: %d\n",
+			   status);
 
 }
 
@@ -347,7 +355,8 @@ int read_nic_byte(struct net_device *dev, int indx, u8 *data)
 
 	status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
 				 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
-				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, data, 1, HZ / 2);
+				 (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f,
+				 data, 1, HZ / 2);
 
 	if (status < 0) {
 		netdev_err(dev, "%s failure status: %d\n", __func__, status);
@@ -619,7 +628,8 @@ static void rtl8192_proc_init_one(struct net_device *dev)
 	if (rtl8192_proc) {
 		dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
 		if (!dir) {
-			RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
+			RT_TRACE(COMP_ERR,
+				 "Unable to initialize /proc/net/rtl8192/%s\n",
 				 dev->name);
 			return;
 		}
@@ -732,7 +742,8 @@ static int rtl8192_rx_initiate(struct net_device *dev)
 			break;
 		}
 		usb_fill_bulk_urb(entry, priv->udev,
-				  usb_rcvbulkpipe(priv->udev, 3), skb_tail_pointer(skb),
+				  usb_rcvbulkpipe(priv->udev, 3),
+				  skb_tail_pointer(skb),
 				  RX_URB_SIZE, rtl8192_rx_isr, skb);
 		info = (struct rtl8192_rx_info *)skb->cb;
 		info->urb = entry;
@@ -753,7 +764,8 @@ static int rtl8192_rx_initiate(struct net_device *dev)
 			break;
 		}
 		usb_fill_bulk_urb(entry, priv->udev,
-				  usb_rcvbulkpipe(priv->udev, 9), skb_tail_pointer(skb),
+				  usb_rcvbulkpipe(priv->udev, 9),
+				  skb_tail_pointer(skb),
 				  RX_URB_SIZE, rtl8192_rx_isr, skb);
 		info = (struct rtl8192_rx_info *)skb->cb;
 		info->urb = entry;
@@ -924,7 +936,8 @@ static void rtl8192_rx_isr(struct urb *urb)
 	}
 
 	usb_fill_bulk_urb(urb, priv->udev,
-			  usb_rcvbulkpipe(priv->udev, out_pipe), skb_tail_pointer(skb),
+			  usb_rcvbulkpipe(priv->udev, out_pipe),
+			  skb_tail_pointer(skb),
 			  RX_URB_SIZE, rtl8192_rx_isr, skb);
 
 	info = (struct rtl8192_rx_info *)skb->cb;
@@ -937,7 +950,9 @@ static void rtl8192_rx_isr(struct urb *urb)
 	skb_queue_tail(&priv->rx_queue, skb);
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err && err != EPERM)
-		netdev_err(dev, "can not submit rxurb, err is %x, URB status is %x\n", err, urb->status);
+		netdev_err(dev,
+			   "can not submit rxurb, err is %x, URB status is %x\n",
+			   err, urb->status);
 }
 
 static u32 rtl819xusb_rx_command_packet(struct net_device *dev,
@@ -967,7 +982,8 @@ static void rtl8192_data_hard_resume(struct net_device *dev)
 /* this function TX data frames when the ieee80211 stack requires this.
  * It checks also if we need to stop the ieee tx queue, eventually do it
  */
-static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
+static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
+				   int rate)
 {
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 	int ret;
@@ -1034,7 +1050,8 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 			dev->trans_start = jiffies;
 			priv->stats.txoktotal++;
 			priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++;
-			priv->stats.txbytesunicast += (skb->len - priv->ieee80211->tx_headroom);
+			priv->stats.txbytesunicast +=
+				(skb->len - priv->ieee80211->tx_headroom);
 		} else {
 			priv->ieee80211->stats.tx_errors++;
 			/* TODO */
@@ -1067,7 +1084,8 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 		    (!(priv->ieee80211->queue_stop))) {
 			skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]));
 			if (skb)
-				priv->ieee80211->softmac_hard_start_xmit(skb, dev);
+				priv->ieee80211->softmac_hard_start_xmit(skb,
+									 dev);
 
 			return; /* avoid further processing AMSDU */
 		}
@@ -1186,7 +1204,8 @@ static void rtl8192_update_cap(struct net_device *dev, u16 cap)
 	if (net->mode & (IEEE_G | IEEE_N_24G)) {
 		u8 slot_time = 0;
 
-		if ((cap & WLAN_CAPABILITY_SHORT_SLOT) && (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
+		if ((cap & WLAN_CAPABILITY_SHORT_SLOT) &&
+		    (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
 			/* short slot time */
 			slot_time = SHORT_SLOT_TIME;
 		else	/* long slot time */
@@ -1276,7 +1295,8 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 	 *---------------------------------------------------------------------
 	 */
 	idx_pipe = 0x04;
-	usb_fill_bulk_urb(tx_urb, priv->udev, usb_sndbulkpipe(priv->udev, idx_pipe),
+	usb_fill_bulk_urb(tx_urb, priv->udev,
+			  usb_sndbulkpipe(priv->udev, idx_pipe),
 			  skb->data, skb->len, rtl8192_tx_isr, skb);
 
 	status = usb_submit_urb(tx_urb, GFP_ATOMIC);
@@ -1333,7 +1353,9 @@ static u8 MapHwQueueToFirmwareQueue(u8 QueueID)
 		break;
 
 	default:
-		RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d\n", QueueID);
+		RT_TRACE(COMP_ERR,
+			 "TransmitTCB(): Impossible Queue Selection: %d\n",
+			 QueueID);
 		break;
 	}
 	return QueueSelect;
@@ -1445,7 +1467,9 @@ static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
 {
 	u8   tmp_Short;
 
-	tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) : ((tcb_desc->bUseShortPreamble) ? 1 : 0);
+	tmp_Short = (TxHT == 1) ?
+			((tcb_desc->bUseShortGI) ? 1 : 0) :
+			((tcb_desc->bUseShortPreamble) ? 1 : 0);
 
 	if (TxHT == 1 && TxRate != DESC90_RATEMCS15)
 		tmp_Short = 0;
@@ -1467,7 +1491,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
 	tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
-	tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
+	tx_fwinfo_819x_usb *tx_fwinfo =
+		(tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
 	struct usb_device *udev = priv->udev;
 	int pend;
 	int status;
@@ -1497,7 +1522,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	tx_fwinfo->TxHT = (tcb_desc->data_rate & 0x80) ? 1 : 0;
 	tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
 	tx_fwinfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
-	tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, tcb_desc);
+	tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate,
+					tcb_desc);
 	if (tcb_desc->bAMPDUEnable) { /* AMPDU enabled */
 		tx_fwinfo->AllowAggregation = 1;
 		/* DWORD 1 */
@@ -1614,15 +1640,19 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 		if (bSend0Byte) {
 			tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
 			if (!tx_urb_zero) {
-				RT_TRACE(COMP_ERR, "can't alloc urb for zero byte\n");
+				RT_TRACE(COMP_ERR,
+					 "can't alloc urb for zero byte\n");
 				return -ENOMEM;
 			}
 			usb_fill_bulk_urb(tx_urb_zero, udev,
-					  usb_sndbulkpipe(udev, idx_pipe), &zero,
-					  0, tx_zero_isr, dev);
+					  usb_sndbulkpipe(udev, idx_pipe),
+					  &zero, 0, tx_zero_isr, dev);
 			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
 			if (status) {
-				RT_TRACE(COMP_ERR, "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status);
+				RT_TRACE(COMP_ERR,
+					 "Error TX URB for zero byte %d, error %d",
+					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+					 status);
 				return -1;
 			}
 		}
@@ -1631,7 +1661,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 		return 0;
 	}
 
-	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+	RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
+		 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
 		 status);
 	return -1;
 }
@@ -1650,7 +1681,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 
 		priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
 
-		priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
+		priv->rx_urb[i]->transfer_buffer =
+			kmalloc(RX_URB_SIZE, GFP_KERNEL);
 
 		priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
 	}
@@ -1757,7 +1789,8 @@ static void rtl8192_link_change(struct net_device *dev)
 		 * way, but there is no chance to set this as wep will not set
 		 * group key in wext.
 		 */
-		if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type))
+		if (KEY_TYPE_WEP40 == ieee->pairwise_key_type ||
+		    KEY_TYPE_WEP104 == ieee->pairwise_key_type)
 			EnableHWSecurityConfig8192(dev);
 	}
 	/*update timing params*/
@@ -1784,25 +1817,30 @@ static struct ieee80211_qos_parameters def_qos_parameters = {
 
 static void rtl8192_update_beacon(struct work_struct *work)
 {
-	struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
+	struct r8192_priv *priv = container_of(work, struct r8192_priv,
+					       update_beacon_wq.work);
 	struct net_device *dev = priv->ieee80211->dev;
 	struct ieee80211_device *ieee = priv->ieee80211;
 	struct ieee80211_network *net = &ieee->current_network;
 
 	if (ieee->pHTInfo->bCurrentHTSupport)
 		HTUpdateSelfAndPeerSetting(ieee, net);
-	ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime;
+	ieee->pHTInfo->bCurrentRT2RTLongSlotTime =
+		net->bssht.bdRT2RTLongSlotTime;
 	rtl8192_update_cap(dev, net->capability);
 }
 /*
 * background support to run QoS activate functionality
 */
-static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO};
+static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK,
+			     EDCAPARA_VI, EDCAPARA_VO};
 static void rtl8192_qos_activate(struct work_struct *work)
 {
-	struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate);
+	struct r8192_priv *priv = container_of(work, struct r8192_priv,
+					       qos_activate);
 	struct net_device *dev = priv->ieee80211->dev;
-	struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
+	struct ieee80211_qos_parameters *qos_parameters =
+		&priv->ieee80211->current_network.qos_data.parameters;
 	u8 mode = priv->ieee80211->current_network.mode;
 	u32  u1bAIFS;
 	u32 u4bAcParam;
@@ -1814,7 +1852,8 @@ static void rtl8192_qos_activate(struct work_struct *work)
 	mutex_lock(&priv->mutex);
 	if (priv->ieee80211->state != IEEE80211_LINKED)
 		goto success;
-	RT_TRACE(COMP_QOS, "qos active process with associate response received\n");
+	RT_TRACE(COMP_QOS,
+		 "qos active process with associate response received\n");
 	/* It better set slot time at first
 	 *
 	 * For we just support b/g mode at present, let the slot time at
@@ -1874,7 +1913,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
 
 		if ((network->qos_data.active == 1) && (active_network == 1)) {
 			queue_work(priv->priv_wq, &priv->qos_activate);
-			RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate\n");
+			RT_TRACE(COMP_QOS,
+				 "QoS was disabled call qos_activate\n");
 		}
 		network->qos_data.active = 0;
 		network->qos_data.supported = 0;
@@ -1939,7 +1979,9 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
 
 	spin_unlock_irqrestore(&priv->ieee80211->lock, flags);
 
-	RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, network->flags, priv->ieee80211->current_network.qos_data.active);
+	RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__,
+		 network->flags,
+		 priv->ieee80211->current_network.qos_data.active);
 	if (set_qos_param == 1)
 		queue_work(priv->priv_wq, &priv->qos_activate);
 
@@ -1948,9 +1990,10 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
 }
 
 
-static int rtl8192_handle_assoc_response(struct net_device *dev,
-					 struct ieee80211_assoc_response_frame *resp,
-					 struct ieee80211_network *network)
+static int rtl8192_handle_assoc_response(
+		struct net_device *dev,
+		struct ieee80211_assoc_response_frame *resp,
+		struct ieee80211_network *network)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
 
@@ -1996,7 +2039,8 @@ static void rtl8192_update_ratr_table(struct net_device *dev)
 	ratr_value &= 0x0FFFFFFF;
 	if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz)
 		ratr_value |= 0x80000000;
-	else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz)
+	else if (!ieee->pHTInfo->bCurTxBW40MHz &&
+		 ieee->pHTInfo->bCurShortGI20MHz)
 		ratr_value |= 0x80000000;
 	write_nic_dword(dev, RATR0 + rate_index * 4, ratr_value);
 	write_nic_byte(dev, UFWP, 1);
@@ -2017,7 +2061,9 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
 	/* we use connecting AP's capability instead of only security config
 	 * on our driver to distinguish whether it should use N mode or G mode
 	 */
-	encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) || (ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP")));
+	encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) ||
+		  (ieee->host_encrypt && crypt && crypt->ops &&
+		   (0 == strcmp(crypt->ops->name, "WEP")));
 
 	/* simply judge  */
 	if (encrypt && (wpa_ie_len == 0)) {
@@ -2049,8 +2095,10 @@ static void rtl8192_refresh_supportrate(struct r8192_priv *priv)
 	/* We do not consider set support rate for ABG mode, only
 	 * HT MCS rate is set here.
 	 */
-	if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G)
-		memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16);
+	if (ieee->mode == WIRELESS_MODE_N_24G ||
+	    ieee->mode == WIRELESS_MODE_N_5G)
+		memcpy(ieee->Regdot11HTOperationalRateSet,
+		       ieee->RegHTSuppRateSet, 16);
 	else
 		memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
 }
@@ -2080,7 +2128,8 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev);
 
-	if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode & bSupportMode) == 0)) {
+	if (wireless_mode == WIRELESS_MODE_AUTO ||
+	    (wireless_mode & bSupportMode) == 0) {
 		if (bSupportMode & WIRELESS_MODE_N_24G) {
 			wireless_mode = WIRELESS_MODE_N_24G;
 		} else if (bSupportMode & WIRELESS_MODE_N_5G) {
@@ -2092,7 +2141,9 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 		} else if ((bSupportMode & WIRELESS_MODE_B)) {
 			wireless_mode = WIRELESS_MODE_B;
 		} else {
-			RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __func__, bSupportMode);
+			RT_TRACE(COMP_ERR,
+				 "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n",
+				 __func__, bSupportMode);
 			wireless_mode = WIRELESS_MODE_B;
 		}
 	}
@@ -2100,11 +2151,14 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 	/* TODO: this function doesn't work well at this time,
 	 * we should wait for FPGA
 	 */
-	ActUpdateChannelAccessSetting(pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
+	ActUpdateChannelAccessSetting(
+			pAdapter, pHalData->CurrentWirelessMode,
+			&pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
 #endif
 	priv->ieee80211->mode = wireless_mode;
 
-	if ((wireless_mode == WIRELESS_MODE_N_24G) ||  (wireless_mode == WIRELESS_MODE_N_5G))
+	if (wireless_mode == WIRELESS_MODE_N_24G ||
+	    wireless_mode == WIRELESS_MODE_N_5G)
 		priv->ieee80211->pHTInfo->bEnableHT = 1;
 	else
 		priv->ieee80211->pHTInfo->bEnableHT = 0;
@@ -2139,14 +2193,16 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 
 	/* we don't use FW read/write RF until stable firmware is available. */
 	priv->ieee80211->FwRWRF = 0;
-	priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
+	priv->ieee80211->current_network.beacon_interval =
+		DEFAULT_BEACONINTERVAL;
 	priv->ieee80211->softmac_features  = IEEE_SOFTMAC_SCAN |
 		IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
 		IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
 		IEEE_SOFTMAC_BEACONS;
 
 	priv->ieee80211->active_scan = 1;
-	priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
+	priv->ieee80211->modulation =
+		IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
 	priv->ieee80211->host_encrypt = 1;
 	priv->ieee80211->host_decrypt = 1;
 	priv->ieee80211->start_send_beacons = NULL;
@@ -2168,7 +2224,8 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 	priv->ieee80211->handle_beacon = rtl8192_handle_beacon;
 
 	priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8192;
-	priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xUsb;
+	priv->ieee80211->GetHalfNmodeSupportByAPsHandler =
+		GetHalfNmodeSupportByAPs819xUsb;
 	priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode;
 
 	priv->ieee80211->InitialGainHandler = InitialGain819xUsb;
@@ -2196,28 +2253,29 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 		(false ? TCR_SAT : 0);
 #ifdef TO_DO_LIST
 	if (Adapter->bInHctTest)
-		pHalData->ReceiveConfig	=	pHalData->CSMethod |
-						/* accept management/data */
-						RCR_AMF | RCR_ADF |
-						/* accept control frame for SW
-						 * AP needs PS-poll
-						 */
-						RCR_ACF |
-						/* accept BC/MC/UC */
-						RCR_AB | RCR_AM | RCR_APM |
-						/* accept ICV/CRC error
-						 * packet
-						 */
-						RCR_AICV | RCR_ACRC32 |
-						/* Max DMA Burst Size per Tx
-						 * DMA Burst, 7: unlimited.
-						 */
-						((u32)7 << RCR_MXDMA_OFFSET) |
-						/* Rx FIFO Threshold,
-						 * 7: No Rx threshold.
-						 */
-						(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
-						(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
+		pHalData->ReceiveConfig =
+			pHalData->CSMethod |
+			/* accept management/data */
+			RCR_AMF | RCR_ADF |
+			/* accept control frame for SW
+			 * AP needs PS-poll
+			 */
+			RCR_ACF |
+			/* accept BC/MC/UC */
+			RCR_AB | RCR_AM | RCR_APM |
+			/* accept ICV/CRC error
+			 * packet
+			 */
+			RCR_AICV | RCR_ACRC32 |
+			/* Max DMA Burst Size per Tx
+			 * DMA Burst, 7: unlimited.
+			 */
+			((u32)7 << RCR_MXDMA_OFFSET) |
+			/* Rx FIFO Threshold,
+			 * 7: No Rx threshold.
+			 */
+			(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
+			(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
 	else
 
 #endif
@@ -2274,11 +2332,16 @@ static void rtl8192_init_priv_task(struct net_device *dev)
 
 	INIT_WORK(&priv->reset_wq, rtl8192_restart);
 
-	INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback);
-	INIT_DELAYED_WORK(&priv->txpower_tracking_wq,  dm_txpower_trackingcallback);
-	INIT_DELAYED_WORK(&priv->rfpath_check_wq,  dm_rf_pathcheck_workitemcallback);
-	INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon);
-	INIT_DELAYED_WORK(&priv->initialgain_operate_wq, InitialGainOperateWorkItemCallBack);
+	INIT_DELAYED_WORK(&priv->watch_dog_wq,
+			  rtl819x_watchdog_wqcallback);
+	INIT_DELAYED_WORK(&priv->txpower_tracking_wq,
+			  dm_txpower_trackingcallback);
+	INIT_DELAYED_WORK(&priv->rfpath_check_wq,
+			  dm_rf_pathcheck_workitemcallback);
+	INIT_DELAYED_WORK(&priv->update_beacon_wq,
+			  rtl8192_update_beacon);
+	INIT_DELAYED_WORK(&priv->initialgain_operate_wq,
+			  InitialGainOperateWorkItemCallBack);
 	INIT_WORK(&priv->qos_activate, rtl8192_qos_activate);
 
 	tasklet_init(&priv->irq_rx_tasklet,
@@ -2293,10 +2356,13 @@ static void rtl8192_get_eeprom_size(struct net_device *dev)
 
 	RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__);
 	read_nic_word_E(dev, EPROM_CMD, &curCR);
-	RT_TRACE(COMP_EPROM, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
+	RT_TRACE(COMP_EPROM,
+		 "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR);
 	/* whether need I consider BIT5? */
-	priv->epromtype = (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
-	RT_TRACE(COMP_EPROM, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype);
+	priv->epromtype =
+		(curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46;
+	RT_TRACE(COMP_EPROM,
+		 "<===========%s(), epromtype:%d\n", __func__, priv->epromtype);
 }
 
 /* used to swap endian. as ntohl & htonl are not necessary
@@ -2322,7 +2388,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 	RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", wEPROM_ID);
 
 	if (wEPROM_ID != RTL8190_EEPROM_ID)
-		RT_TRACE(COMP_ERR, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", wEPROM_ID, RTL8190_EEPROM_ID);
+		RT_TRACE(COMP_ERR,
+			 "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n",
+			 wEPROM_ID, RTL8190_EEPROM_ID);
 	else
 		bLoad_From_EEPOM = true;
 
@@ -2333,7 +2401,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		tmpValue = eprom_read(dev, EEPROM_ChannelPlan >> 1);
 		priv->eeprom_ChannelPlan = (tmpValue & 0xff00) >> 8;
 		priv->btxpowerdata_readfromEEPORM = true;
-		priv->eeprom_CustomerID = eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8;
+		priv->eeprom_CustomerID =
+			eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8;
 	} else {
 		priv->eeprom_vid = 0;
 		priv->eeprom_pid = 0;
@@ -2341,7 +2410,10 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		priv->eeprom_ChannelPlan = 0;
 		priv->eeprom_CustomerID = 0;
 	}
-	RT_TRACE(COMP_EPROM, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID, priv->eeprom_ChannelPlan);
+	RT_TRACE(COMP_EPROM,
+		 "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n",
+		 priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID,
+		 priv->eeprom_ChannelPlan);
 	/* set channelplan from eeprom */
 	priv->ChannelPlan = priv->eeprom_ChannelPlan;
 	if (bLoad_From_EEPOM) {
@@ -2474,7 +2546,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		/* Antenna B gain offset to antenna A, bit0~3 */
 		priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
 		/* Antenna C gain offset to antenna A, bit4~7 */
-		priv->AntennaTxPwDiff[1] = (priv->EEPROMTxPowerDiff & 0xf0) >> 4;
+		priv->AntennaTxPwDiff[1] =
+			(priv->EEPROMTxPowerDiff & 0xf0) >> 4;
 		/* CrystalCap, bit12~15 */
 		priv->CrystalCap = priv->EEPROMCrystalCap;
 		/* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
@@ -2533,7 +2606,8 @@ static short rtl8192_get_channel_map(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 
 	if (priv->ChannelPlan > COUNTRY_CODE_GLOBAL_DOMAIN) {
-		netdev_err(dev, "rtl8180_init: Error channel plan! Set to default.\n");
+		netdev_err(dev,
+			   "rtl8180_init: Error channel plan! Set to default.\n");
 		priv->ChannelPlan = 0;
 	}
 	RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan);
@@ -2622,7 +2696,8 @@ static void rtl8192_hwconfig(struct net_device *dev)
 #endif
 		{
 			regBwOpMode = BW_OPMODE_20MHZ;
-			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
+				  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
 			regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		}
 		break;
@@ -2631,12 +2706,14 @@ static void rtl8192_hwconfig(struct net_device *dev)
 		 * out only when associated AP does not support it.
 		 */
 		regBwOpMode = BW_OPMODE_20MHZ;
-		regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+		regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
+			  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
 		regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		break;
 	case WIRELESS_MODE_N_5G:
 		regBwOpMode = BW_OPMODE_5G;
-		regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+		regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS |
+			  RATE_ALL_OFDM_2SS;
 		regRRSR = RATE_ALL_OFDM_AG;
 		break;
 	}
@@ -2695,7 +2772,9 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
 		dwRegRead |= CPU_GEN_FIRMWARE_RESET;
 	else
-		RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__,   priv->pFirmware->firmware_status);
+		RT_TRACE(COMP_ERR,
+			 "ERROR in %s(): undefined firmware state(%d)\n",
+			 __func__,   priv->pFirmware->firmware_status);
 
 	write_nic_dword(dev, CPU_GEN, dwRegRead);
 	/* config BB. */
@@ -2706,11 +2785,14 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 
 	read_nic_dword(dev, CPU_GEN, &dwRegRead);
 	if (priv->LoopbackMode == RTL819xU_NO_LOOPBACK)
-		dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET;
+		dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) |
+			    CPU_GEN_NO_LOOPBACK_SET;
 	else if (priv->LoopbackMode == RTL819xU_MAC_LOOPBACK)
 		dwRegRead |= CPU_CCK_LOOPBACK;
 	else
-		RT_TRACE(COMP_ERR, "Serious error in %s(): wrong loopback mode setting(%d)\n", __func__,  priv->LoopbackMode);
+		RT_TRACE(COMP_ERR,
+			 "Serious error in %s(): wrong loopback mode setting(%d)\n",
+			 __func__,  priv->LoopbackMode);
 
 	write_nic_dword(dev, CPU_GEN, dwRegRead);
 
@@ -2735,14 +2817,17 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	write_nic_dword(dev, RCR, priv->ReceiveConfig);
 
 	/* Initialize Number of Reserved Pages in Firmware Queue */
-	write_nic_dword(dev, RQPN1,  NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_VO << RSVD_FW_QUEUE_PAGE_VO_SHIFT);
-	write_nic_dword(dev, RQPN2, NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT |
-			NUM_OF_PAGE_IN_FW_QUEUE_CMD << RSVD_FW_QUEUE_PAGE_CMD_SHIFT);
-	write_nic_dword(dev, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW |
-			NUM_OF_PAGE_IN_FW_QUEUE_BCN << RSVD_FW_QUEUE_PAGE_BCN_SHIFT);
+	write_nic_dword(dev, RQPN1,
+		NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_VO << RSVD_FW_QUEUE_PAGE_VO_SHIFT);
+	write_nic_dword(dev, RQPN2,
+		NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT |
+		NUM_OF_PAGE_IN_FW_QUEUE_CMD << RSVD_FW_QUEUE_PAGE_CMD_SHIFT);
+	write_nic_dword(dev, RQPN3,
+		APPLIED_RESERVED_QUEUE_IN_FW |
+		NUM_OF_PAGE_IN_FW_QUEUE_BCN << RSVD_FW_QUEUE_PAGE_BCN_SHIFT);
 	write_nic_dword(dev, RATR0 + 4 * 7, (RATE_ALL_OFDM_AG | RATE_ALL_CCK));
 
 	/* Set AckTimeout */
@@ -2781,7 +2866,8 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	/* Firmware download */
 	init_status = init_firmware(dev);
 	if (!init_status) {
-		RT_TRACE(COMP_ERR, "ERR!!! %s(): Firmware download is failed\n", __func__);
+		RT_TRACE(COMP_ERR, "ERR!!! %s(): Firmware download is failed\n",
+			 __func__);
 		return init_status;
 	}
 	RT_TRACE(COMP_INIT, "%s():after firmware download\n", __func__);
@@ -2789,30 +2875,42 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 #ifdef TO_DO_LIST
 	if (Adapter->ResetProgress == RESET_TYPE_NORESET) {
 		if (pMgntInfo->RegRfOff) { /* User disable RF via registry. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
+			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
+				 ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
 			MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
 			/* Those actions will be discard in MgntActSet_RF_State
 			 * because of the same state
 			 */
 			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+				PHY_SetRFReg(Adapter,
+					     (RF90_RADIO_PATH_E)eRFPath,
+					     0x4, 0xC00, 0x0);
 		} else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) {
 			/* H/W or S/W RF OFF before sleep. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", pMgntInfo->RfOffReason));
-			MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
+			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
+				 ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n",
+				  pMgntInfo->RfOffReason));
+			MgntActSet_RF_State(Adapter,
+					    eRfOff,
+					    pMgntInfo->RfOffReason);
 		} else {
 			pHalData->eRFPowerState = eRfOn;
 			pMgntInfo->RfOffReason = 0;
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): RF is on ----------\n"));
+			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
+				 ("InitializeAdapter819xUsb(): RF is on ----------\n"));
 		}
 	} else {
 		if (pHalData->eRFPowerState == eRfOff) {
-			MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
+			MgntActSet_RF_State(Adapter,
+					    eRfOff,
+					    pMgntInfo->RfOffReason);
 			/* Those actions will be discard in MgntActSet_RF_State
 			 * because of the same state
 			 */
 			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
+				PHY_SetRFReg(Adapter,
+					     (RF90_RADIO_PATH_E)eRFPath,
+					     0x4, 0xC00, 0x0);
 		}
 	}
 #endif
@@ -2851,18 +2949,24 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 
 		if (priv->bDcut) {
 			u32 i, TempCCk;
-			u32 tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
+			u32 tmpRegA = rtl8192_QueryBBReg(dev,
+							 rOFDM0_XATxIQImbalance,
+							 bMaskDWord);
 
 			for (i = 0; i < TxBBGainTableLength; i++) {
 				if (tmpRegA == priv->txbbgain_table[i].txbbgain_value) {
 					priv->rfa_txpowertrackingindex = (u8)i;
-					priv->rfa_txpowertrackingindex_real = (u8)i;
-					priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex;
+					priv->rfa_txpowertrackingindex_real =
+						(u8)i;
+					priv->rfa_txpowertracking_default =
+						priv->rfa_txpowertrackingindex;
 					break;
 				}
 			}
 
-			TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2);
+			TempCCk = rtl8192_QueryBBReg(dev,
+						     rCCK0_TxFilter1,
+						     bMaskByte2);
 
 			for (i = 0; i < CCKTxBBGainTableLength; i++) {
 
@@ -2873,7 +2977,8 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 			}
 			priv->cck_present_attentuation_40Mdefault = 0;
 			priv->cck_present_attentuation_difference = 0;
-			priv->cck_present_attentuation = priv->cck_present_attentuation_20Mdefault;
+			priv->cck_present_attentuation =
+				priv->cck_present_attentuation_20Mdefault;
 
 		}
 	}
@@ -2905,7 +3010,9 @@ static bool HalTxCheckStuck819xUsb(struct net_device *dev)
 	bool		bStuck = false;
 
 	read_nic_word(dev, 0x128, &RegTxCounter);
-	RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", __func__, RegTxCounter, priv->TxCounter);
+	RT_TRACE(COMP_RESET,
+		 "%s():RegTxCounter is %d,TxCounter is %d\n", __func__,
+		 RegTxCounter, priv->TxCounter);
 	if (priv->TxCounter == RegTxCounter)
 		bStuck = true;
 
@@ -2936,7 +3043,8 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev)
 	}
 	if (bCheckFwTxCnt) {
 		if (HalTxCheckStuck819xUsb(dev)) {
-			RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition!\n");
+			RT_TRACE(COMP_RESET,
+				 "TxCheckStuck(): Fw indicates no Tx condition!\n");
 			return RESET_TYPE_SILENT;
 		}
 	}
@@ -2951,7 +3059,9 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	static u8	rx_chk_cnt;
 
 	read_nic_word(dev, 0x130, &RegRxCounter);
-	RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__, RegRxCounter, priv->RxCounter);
+	RT_TRACE(COMP_RESET,
+		 "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__,
+		 RegRxCounter, priv->RxCounter);
 	/* If rssi is small, we should check rx for long time because of bad rx.
 	 * or maybe it will continuous silent reset every 2 seconds.
 	 */
@@ -3044,9 +3154,11 @@ static RESET_TYPE rtl819x_ifcheck_resetornot(struct net_device *dev)
 		 */
 		RxResetType = RxCheckStuck(dev);
 	}
-	if (TxResetType == RESET_TYPE_NORMAL || RxResetType == RESET_TYPE_NORMAL) {
+	if (TxResetType == RESET_TYPE_NORMAL ||
+	    RxResetType == RESET_TYPE_NORMAL) {
 		return RESET_TYPE_NORMAL;
-	} else if (TxResetType == RESET_TYPE_SILENT || RxResetType == RESET_TYPE_SILENT) {
+	} else if (TxResetType == RESET_TYPE_SILENT ||
+		   RxResetType == RESET_TYPE_SILENT) {
 		RT_TRACE(COMP_RESET, "%s():silent reset\n", __func__);
 		return RESET_TYPE_SILENT;
 	} else {
@@ -3156,12 +3268,16 @@ RESET_START:
 		priv->ResetProgress = RESET_TYPE_SILENT;
 		down(&priv->wx_sem);
 		if (priv->up == 0) {
-			RT_TRACE(COMP_ERR, "%s():the driver is not up! return\n", __func__);
+			RT_TRACE(COMP_ERR,
+				 "%s():the driver is not up! return\n",
+				 __func__);
 			up(&priv->wx_sem);
 			return;
 		}
 		priv->up = 0;
-		RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():======>start to down the driver\n",
+			 __func__);
 
 		rtl8192_rtx_disable(dev);
 		rtl8192_cancel_deferred_work(priv);
@@ -3183,28 +3299,40 @@ RESET_START:
 			ieee80211_softmac_stop_protocol(priv->ieee80211);
 		}
 		up(&priv->wx_sem);
-		RT_TRACE(COMP_RESET, "%s():<==========down process is finished\n", __func__);
-		RT_TRACE(COMP_RESET, "%s():===========>start up the driver\n", __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():<==========down process is finished\n",
+			 __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():===========>start up the driver\n",
+			 __func__);
 		reset_status = _rtl8192_up(dev);
 
-		RT_TRACE(COMP_RESET, "%s():<===========up process is finished\n", __func__);
+		RT_TRACE(COMP_RESET,
+			 "%s():<===========up process is finished\n",
+			 __func__);
 		if (reset_status == -EAGAIN) {
 			if (reset_times < 3) {
 				reset_times++;
 				goto RESET_START;
 			} else {
-				RT_TRACE(COMP_ERR, " ERR!!! %s():  Reset Failed!!\n", __func__);
+				RT_TRACE(COMP_ERR,
+					 " ERR!!! %s():  Reset Failed!!\n",
+					 __func__);
 			}
 		}
 		ieee->is_silent_reset = 1;
 		EnableHWSecurityConfig8192(dev);
-		if (ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) {
-			ieee->set_chan(ieee->dev, ieee->current_network.channel);
+		if (ieee->state == IEEE80211_LINKED &&
+		    ieee->iw_mode == IW_MODE_INFRA) {
+			ieee->set_chan(ieee->dev,
+				       ieee->current_network.channel);
 
 			queue_work(ieee->wq, &ieee->associate_complete_wq);
 
-		} else if (ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_ADHOC) {
-			ieee->set_chan(ieee->dev, ieee->current_network.channel);
+		} else if (ieee->state == IEEE80211_LINKED &&
+			   ieee->iw_mode == IW_MODE_ADHOC) {
+			ieee->set_chan(ieee->dev,
+				       ieee->current_network.channel);
 			ieee->link_change(ieee->dev);
 
 			ieee80211_start_send_beacons(ieee);
@@ -3224,7 +3352,9 @@ RESET_START:
 
 		/* For test --> force write UFWP. */
 		write_nic_byte(dev, UFWP, 1);
-		RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count);
+		RT_TRACE(COMP_RESET,
+			 "Reset finished!! ====>[%d]\n",
+			 priv->reset_count);
 	}
 }
 
@@ -3237,9 +3367,12 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
 	*TotalRxBcnNum = 0;
 	*TotalRxDataNum = 0;
 
-	SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++) % (priv->ieee80211->LinkDetectInfo.SlotNum);
-	priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
-	priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
+	SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++) %
+		    (priv->ieee80211->LinkDetectInfo.SlotNum);
+	priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] =
+		priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
+	priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] =
+		priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
 	for (i = 0; i < priv->ieee80211->LinkDetectInfo.SlotNum; i++) {
 		*TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i];
 		*TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i];
@@ -3249,8 +3382,10 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
 
 static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 {
-	struct delayed_work *dwork = container_of(work, struct delayed_work, work);
-	struct r8192_priv *priv = container_of(dwork, struct r8192_priv, watch_dog_wq);
+	struct delayed_work *dwork = container_of(work,
+						  struct delayed_work, work);
+	struct r8192_priv *priv = container_of(dwork,
+					       struct r8192_priv, watch_dog_wq);
 	struct net_device *dev = priv->ieee80211->dev;
 	struct ieee80211_device *ieee = priv->ieee80211;
 	RESET_TYPE	ResetType = RESET_TYPE_NORESET;
@@ -3274,7 +3409,8 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 		ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
 	}
 	/* for AP roaming */
-	if (priv->ieee80211->state == IEEE80211_LINKED && priv->ieee80211->iw_mode == IW_MODE_INFRA) {
+	if (priv->ieee80211->state == IEEE80211_LINKED &&
+	    priv->ieee80211->iw_mode == IW_MODE_INFRA) {
 
 		rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
 		if ((TotalRxBcnNum + TotalRxDataNum) == 0) {
@@ -3282,12 +3418,16 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 			if (rfState == eRfOff)
 				RT_TRACE(COMP_ERR, "========>%s()\n", __func__);
 #endif
-			netdev_dbg(dev, "===>%s(): AP is power off, connect another one\n", __func__);
+			netdev_dbg(dev,
+				   "===>%s(): AP is power off, connect another one\n",
+				   __func__);
 			priv->ieee80211->state = IEEE80211_ASSOCIATING;
 			notify_wx_assoc_event(priv->ieee80211);
-			RemovePeerTS(priv->ieee80211, priv->ieee80211->current_network.bssid);
+			RemovePeerTS(priv->ieee80211,
+				     priv->ieee80211->current_network.bssid);
 			priv->ieee80211->link_change(dev);
-			queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
+			queue_work(priv->ieee80211->wq,
+				   &priv->ieee80211->associate_procedure_wq);
 
 		}
 	}
@@ -3302,7 +3442,11 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 	if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
 	    (priv->bForcedSilentReset ||
 	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) {
-		RT_TRACE(COMP_RESET, "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n", __func__, priv->force_reset, priv->ResetProgress, priv->bForcedSilentReset, priv->bDisableNormalResetCheck, ResetType);
+		RT_TRACE(COMP_RESET,
+			 "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",
+			 __func__, priv->force_reset, priv->ResetProgress,
+			 priv->bForcedSilentReset,
+			 priv->bDisableNormalResetCheck, ResetType);
 		rtl819x_ifsilentreset(dev);
 	}
 	priv->force_reset = false;
@@ -3317,7 +3461,8 @@ static void watch_dog_timer_callback(unsigned long data)
 	struct r8192_priv *priv = ieee80211_priv((struct net_device *)data);
 
 	queue_delayed_work(priv->priv_wq, &priv->watch_dog_wq, 0);
-	mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
+	mod_timer(&priv->watch_dog_timer,
+		  jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
 }
 static int _rtl8192_up(struct net_device *dev)
 {
@@ -3329,7 +3474,8 @@ static int _rtl8192_up(struct net_device *dev)
 	RT_TRACE(COMP_INIT, "Bringing up iface");
 	init_status = rtl8192_adapter_start(dev);
 	if (!init_status) {
-		RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization failed!\n", __func__);
+		RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization failed!\n",
+			 __func__);
 		priv->up = priv->ieee80211->ieee_up = 0;
 		return -EAGAIN;
 	}
@@ -3422,7 +3568,8 @@ int rtl8192_down(struct net_device *dev)
 
 
 	ieee80211_softmac_stop_protocol(priv->ieee80211);
-	memset(&priv->ieee80211->current_network, 0, offsetof(struct ieee80211_network, list));
+	memset(&priv->ieee80211->current_network, 0,
+	       offsetof(struct ieee80211_network, list));
 	RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__);
 
 	return 0;
@@ -3450,7 +3597,8 @@ void rtl8192_commit(struct net_device *dev)
 
 static void rtl8192_restart(struct work_struct *work)
 {
-	struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
+	struct r8192_priv *priv = container_of(work, struct r8192_priv,
+					       reset_wq);
 	struct net_device *dev = priv->ieee80211->dev;
 
 	down(&priv->wx_sem);
@@ -3543,9 +3691,16 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 					 * so we need index entry for its
 					 * default key serching!
 					 */
-					setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8 *)ieee->ap_mac_addr, 0, key);
+					setKey(dev, 4, ipw->u.crypt.idx,
+					       ieee->pairwise_key_type,
+					       (u8 *)ieee->ap_mac_addr,
+					       0, key);
 					if (ieee->auth_mode != 2)
-						setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8 *)ieee->ap_mac_addr, 0, key);
+						setKey(dev, ipw->u.crypt.idx,
+						       ipw->u.crypt.idx,
+						       ieee->pairwise_key_type,
+						       (u8 *)ieee->ap_mac_addr,
+						       0, key);
 				}
 			} else {
 				memcpy((u8 *)key, ipw->u.crypt.key, 16);
@@ -3577,7 +3732,8 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 				}
 			}
 		}
-		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
+		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
+						     &wrq->u.data);
 		break;
 
 	default:
@@ -3636,7 +3792,9 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
 
 		default:
 			ret_rate = 0xff;
-			RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+			RT_TRACE(COMP_RECV,
+				 "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",
+				 rate, bIsHT);
 			break;
 		}
 
@@ -3696,7 +3854,9 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
 
 		default:
 			ret_rate = 0xff;
-			RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+			RT_TRACE(COMP_RECV,
+				 "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",
+				 rate, bIsHT);
 			break;
 		}
 	}
@@ -3762,7 +3922,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	static u32 slide_evm_index, slide_evm_statistics;
 	static u32 last_rssi, last_evm;
 
-	static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics;
+	static u32 slide_beacon_adc_pwdb_index;
+	static u32 slide_beacon_adc_pwdb_statistics;
 	static u32 last_beacon_adc_pwdb;
 
 	struct rtl_80211_hdr_3addr *hdr;
@@ -3789,7 +3950,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	}
 	priv->stats.slide_rssi_total += pprevious_stats->SignalStrength;
 
-	priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength;
+	priv->stats.slide_signal_strength[slide_rssi_index++] =
+		pprevious_stats->SignalStrength;
 	if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
 		slide_rssi_index = 0;
 
@@ -3821,13 +3983,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	/* <2> Showed on UI for engineering
 	 * hardware does not provide rssi information for each rf path in CCK
 	 */
-	if (!pprevious_stats->bIsCCK && (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) {
+	if (!pprevious_stats->bIsCCK &&
+	    (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) {
 		for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) {
-			if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, rfpath))
+			if (!rtl8192_phy_CheckIsLegalRFPath(
+					priv->ieee80211->dev, rfpath))
 				continue;
 
 			if (priv->stats.rx_rssi_percentage[rfpath] == 0)
-				priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath];
+				priv->stats.rx_rssi_percentage[rfpath] =
+					pprevious_stats->RxMIMOSignalStrength[rfpath];
 			if (pprevious_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
 				priv->stats.rx_rssi_percentage[rfpath] =
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
@@ -3838,7 +4003,9 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
 					 (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
 			}
-			RT_TRACE(COMP_DBG, "priv->stats.rx_rssi_percentage[rfPath]  = %d\n", priv->stats.rx_rssi_percentage[rfpath]);
+			RT_TRACE(COMP_DBG,
+				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
+				 priv->stats.rx_rssi_percentage[rfpath]);
 		}
 	}
 
@@ -3870,10 +4037,13 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		 pprevious_stats->RxPWDBAll);
 
 
-	if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
+	if (pprevious_stats->bPacketToSelf ||
+	    pprevious_stats->bPacketBeacon ||
+	    pprevious_stats->bToSelfBA) {
 		if (priv->undecorated_smoothed_pwdb < 0)
 			/* initialize */
-			priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll;
+			priv->undecorated_smoothed_pwdb =
+				pprevious_stats->RxPWDBAll;
 		if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
 			priv->undecorated_smoothed_pwdb =
 				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
@@ -3890,21 +4060,26 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	/* Check EVM */
 	/* record the general EVM to the sliding window. */
 	if (pprevious_stats->SignalQuality) {
-		if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
+		if (pprevious_stats->bPacketToSelf ||
+		    pprevious_stats->bPacketBeacon ||
+		    pprevious_stats->bToSelfBA) {
 			if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
 				slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
 				last_evm = priv->stats.slide_evm[slide_evm_index];
 				priv->stats.slide_evm_total -= last_evm;
 			}
 
-			priv->stats.slide_evm_total += pprevious_stats->SignalQuality;
+			priv->stats.slide_evm_total +=
+				pprevious_stats->SignalQuality;
 
-			priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality;
+			priv->stats.slide_evm[slide_evm_index++] =
+				pprevious_stats->SignalQuality;
 			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
 				slide_evm_index = 0;
 
 			/* <1> Showed on UI for user, in percentage. */
-			tmp_val = priv->stats.slide_evm_total / slide_evm_statistics;
+			tmp_val = priv->stats.slide_evm_total /
+				  slide_evm_statistics;
 			priv->stats.signal_quality = tmp_val;
 			/* Showed on UI for user in Windows Vista,
 			 * for Link quality.
@@ -3913,7 +4088,9 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		}
 
 		/* <2> Showed on UI for engineering */
-		if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) {
+		if (pprevious_stats->bPacketToSelf ||
+		    pprevious_stats->bPacketBeacon ||
+		    pprevious_stats->bToSelfBA) {
 			for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */
 				if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
 					if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */
@@ -4025,15 +4202,15 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	phy_sts_ofdm_819xusb_t *pofdm_buf;
 	phy_sts_cck_819xusb_t	*pcck_buf;
 	phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc;
-	u8				*prxpkt;
-	u8				i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
-	char				rx_pwr[4], rx_pwr_all = 0;
-	char				rx_snrX, rx_evmX;
-	u8				evm, pwdb_all;
-	u32				RSSI, total_rssi = 0;
-	u8				is_cck_rate = 0;
-	u8				rf_rx_num = 0;
-	u8				sq;
+	u8	*prxpkt;
+	u8	i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
+	char	rx_pwr[4], rx_pwr_all = 0;
+	char	rx_snrX, rx_evmX;
+	u8	evm, pwdb_all;
+	u32	RSSI, total_rssi = 0;
+	u8	is_cck_rate = 0;
+	u8	rf_rx_num = 0;
+	u8	sq;
 
 
 	priv->stats.numqry_phystatus++;
@@ -4042,7 +4219,8 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 
 	/* Record it for next packet processing */
 	memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats));
-	pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
+	pstats->bPacketMatchBSSID =
+		precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
 	pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself;
 	pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;
 	pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon;
@@ -4127,8 +4305,10 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 				sq = ((64 - sq) * 100) / 44;
 		}
 		pstats->SignalQuality = precord_stats->SignalQuality = sq;
-		pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq;
-		pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1;
+		pstats->RxMIMOSignalQuality[0] =
+			precord_stats->RxMIMOSignalQuality[0] = sq;
+		pstats->RxMIMOSignalQuality[1] =
+			precord_stats->RxMIMOSignalQuality[1] = -1;
 
 	} else {
 		priv->stats.numqry_phystatusHT++;
@@ -4141,10 +4321,12 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 			else
 				continue;
 
-			if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i))
+			if (!rtl8192_phy_CheckIsLegalRFPath(
+					priv->ieee80211->dev, i))
 				continue;
 
-			rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i] & 0x3F) * 2) - 106;
+			rx_pwr[i] =
+				((pofdm_buf->trsw_gain_X[i] & 0x3F) * 2) - 106;
 
 			/* Get Rx snr value in DB */
 			tmp_rxsnr =	pofdm_buf->rxsnr_X[i];
@@ -4198,14 +4380,19 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 				/* Fill value in RFD, Get the first spatial
 				 * stream only
 				 */
-				pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff);
-			pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff);
+				pstats->SignalQuality =
+					precord_stats->SignalQuality =
+					(u8)(evm & 0xff);
+			pstats->RxMIMOSignalQuality[i] =
+				precord_stats->RxMIMOSignalQuality[i] =
+				(u8)(evm & 0xff);
 		}
 
 
 		/* record rx statistics for debug */
 		rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg;
-		prxsc =	(phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg;
+		prxsc =	(phy_ofdm_rx_status_rxsc_sgien_exintfflag *)
+			&rxsc_sgien_exflg;
 		if (pdrvinfo->BW)	/* 40M channel */
 			priv->stats.received_bwtype[1 + prxsc->rxsc]++;
 		else			/* 20M channel */
@@ -4217,16 +4404,22 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	 * GetValueFromBeaconOrProbeRsp().
 	 */
 	if (is_cck_rate) {
-		pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));
+		pstats->SignalStrength =
+			precord_stats->SignalStrength =
+			(u8)(rtl819x_signal_scale_mapping((long)pwdb_all));
 	} else {
 		/* We can judge RX path number now. */
-		if (rf_rx_num != 0)
-			pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+		if (rf_rx_num != 0) {
+			pstats->SignalStrength =
+				precord_stats->SignalStrength =
+				(u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+		}
 	}
 }	/* QueryRxPhyStatus8190Pci */
 
-static void rtl8192_record_rxdesc_forlateruse(struct ieee80211_rx_stats *psrc_stats,
-					      struct ieee80211_rx_stats *ptarget_stats)
+static void rtl8192_record_rxdesc_forlateruse(
+		struct ieee80211_rx_stats *psrc_stats,
+		struct ieee80211_rx_stats *ptarget_stats)
 {
 	ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU;
 	ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU;
@@ -4267,7 +4460,8 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) &&
 			       (eqMacAddr(priv->ieee80211->current_network.bssid,  (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
 			       && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV);
-	bpacket_toself =  bpacket_match_bssid & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
+	bpacket_toself =  bpacket_match_bssid &
+			  (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
 
 	if (WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BEACON)
 		bPacketBeacon = true;
@@ -4287,7 +4481,9 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	 * only, so driver should process phy information of previous packet
 	 */
 	rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats);
-	rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats, bpacket_match_bssid, bpacket_toself, bPacketBeacon, bToSelfBA);
+	rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats,
+				  bpacket_match_bssid, bpacket_toself,
+				  bPacketBeacon, bToSelfBA);
 	rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats);
 
 }
@@ -4460,14 +4656,18 @@ static void query_rxdesc_status(struct sk_buff *skb,
 	 * Driver info are written to the RxBuffer following rx desc
 	 */
 	if (stats->RxDrvInfoSize != 0) {
-		driver_info = (rx_drvinfo_819x_usb *)(skb->data + sizeof(rx_desc_819x_usb) +
-						      stats->RxBufShift);
+		driver_info = (rx_drvinfo_819x_usb *)(
+				skb->data
+				+ sizeof(rx_desc_819x_usb)
+				+ stats->RxBufShift
+			      );
 		/* unit: 0.5M */
 		/* TODO */
 		if (!stats->bHwError) {
 			u8	ret_rate;
 
-			ret_rate = HwRateToMRate90(driver_info->RxHT, driver_info->RxRate);
+			ret_rate = HwRateToMRate90(driver_info->RxHT,
+						   driver_info->RxRate);
 			if (ret_rate == 0xff) {
 				/* Abnormal Case: Receive CRC OK packet with Rx
 				 * descriptor indicating non supported rate.
@@ -4490,14 +4690,16 @@ static void query_rxdesc_status(struct sk_buff *skb,
 		UpdateReceivedRateHistogramStatistics8190(dev, stats);
 
 		stats->bIsAMPDU = (driver_info->PartAggr == 1);
-		stats->bFirstMPDU = (driver_info->PartAggr == 1) && (driver_info->FirstAGGR == 1);
+		stats->bFirstMPDU = (driver_info->PartAggr == 1) &&
+				    (driver_info->FirstAGGR == 1);
 		stats->TimeStampLow = driver_info->TSFL;
 
 		UpdateRxPktTimeStamp8190(dev, stats);
 
 		/* Rx A-MPDU */
 		if (driver_info->FirstAGGR == 1 || driver_info->PartAggr == 1)
-			RT_TRACE(COMP_RXDESC, "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n",
+			RT_TRACE(COMP_RXDESC,
+				"driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n",
 				 driver_info->FirstAGGR, driver_info->PartAggr);
 
 	}
@@ -4566,8 +4768,9 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 
 }
 
-static void rtl819xusb_process_received_packet(struct net_device *dev,
-					       struct ieee80211_rx_stats *pstats)
+static void rtl819xusb_process_received_packet(
+		struct net_device *dev,
+		struct ieee80211_rx_stats *pstats)
 {
 	u8	*frame;
 	u16     frame_len = 0;
@@ -4587,7 +4790,8 @@ static void rtl819xusb_process_received_packet(struct net_device *dev,
 	 * reason, ie. there may be a duration while sw switch is changed and
 	 * hw switch is being changed.
 	 */
-	Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (u8 *)(&rtState));
+	Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE,
+					 (u8 *)(&rtState));
 	if (rtState == eRfOff)
 		return;
 #endif
@@ -4721,14 +4925,16 @@ static int rtl8192_usb_probe(struct usb_interface *intf,
 
 	dev->netdev_ops = &rtl8192_netdev_ops;
 
-	dev->wireless_handlers = (struct iw_handler_def *)&r8192_wx_handlers_def;
+	dev->wireless_handlers =
+		(struct iw_handler_def *)&r8192_wx_handlers_def;
 
 	dev->type = ARPHRD_ETHER;
 
 	dev->watchdog_timeo = HZ * 3;
 
 	if (dev_alloc_name(dev, ifname) < 0) {
-		RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n");
+		RT_TRACE(COMP_INIT,
+			 "Oops: devname already taken! Trying wlan%%d...\n");
 		ifname = "wlan%d";
 		dev_alloc_name(dev, ifname);
 	}
@@ -4788,7 +4994,8 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf)
 	if (dev) {
 		unregister_netdev(dev);
 
-		RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n");
+		RT_TRACE(COMP_DOWN,
+			 "=============>wlan driver to be removed\n");
 		rtl8192_proc_remove_one(dev);
 
 		rtl8192_down(dev);
@@ -4896,8 +5103,9 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 		ieee->hwsec_active = 0;
 		SECR_value &= ~SCR_RxDecEnable;
 	}
-	RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__,
-		 ieee->hwsec_active, ieee->pairwise_key_type, SECR_value);
+	RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n",
+		 __func__, ieee->hwsec_active, ieee->pairwise_key_type,
+		 SECR_value);
 	write_nic_byte(dev, SECR,  SECR_value);
 }
 
@@ -4913,7 +5121,9 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
 	if (EntryNo >= TOTAL_CAM_ENTRY)
 		RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n");
 
-	RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", dev, EntryNo, KeyIndex, KeyType, MacAddr);
+	RT_TRACE(COMP_SEC,
+		 "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n",
+		 dev, EntryNo, KeyIndex, KeyType, MacAddr);
 
 	if (DefaultKey)
 		usConfig |= BIT15 | (KeyType << 2);
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (17 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 01/15] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-21  2:16   ` Greg Kroah-Hartman
  2015-09-20 17:14 ` [PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get " Raphaël Beamonte
                   ` (12 subsequent siblings)
  31 siblings, 1 reply; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Add some temporary variables to reduce line length under the maximum
of 80 characters, as per the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
 1 file changed, 94 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 28b54ba..2abc3e77 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -171,6 +171,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 {
 	int i, max_chan = -1, min_chan = -1;
 	struct ieee80211_device *ieee = priv->ieee80211;
+	struct CHANNEL_LIST cl;
 
 	switch (channel_plan) {
 	case COUNTRY_CODE_FCC:
@@ -194,15 +195,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 				 "unknown rf chip, can't set channel map in function:%s()\n",
 				 __func__);
 		}
-		if (ChannelPlan[channel_plan].Len != 0) {
+		cl = ChannelPlan[channel_plan];
+		if (cl.Len != 0) {
 			/* Clear old channel map */
 			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
 			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
 			/* Set new channel map */
-			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
-				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
+			for (i = 0; i < cl.Len; i++) {
+				u8 chan = cl.Channel[i];
+
+				if (chan < min_chan || chan > max_chan)
 					break;
-				GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
+				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
 			}
 		}
 		break;
@@ -1649,9 +1653,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 					  &zero, 0, tx_zero_isr, dev);
 			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
 			if (status) {
+				atomic_t tx =
+					priv->tx_pending[tcb_desc->queue_index];
+
 				RT_TRACE(COMP_ERR,
 					 "Error TX URB for zero byte %d, error %d",
-					 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
+					 atomic_read(&tx),
 					 status);
 				return -1;
 			}
@@ -1698,8 +1705,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 		oldaddr = priv->oldaddr;
 		align = ((long)oldaddr) & 3;
 		if (align) {
-			newaddr = oldaddr + 4 - align;
-			priv->rx_urb[16]->transfer_buffer_length = 16 - 4 + align;
+			long nalign = 4 - align;
+			newaddr = oldaddr + nalign;
+			priv->rx_urb[16]->transfer_buffer_length = 16 - nalign;
 		} else {
 			newaddr = oldaddr;
 			priv->rx_urb[16]->transfer_buffer_length = 16;
@@ -1863,7 +1871,9 @@ static void rtl8192_qos_activate(struct work_struct *work)
 	 */
 	for (i = 0; i <  QOS_QUEUE_NUM; i++) {
 		/* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
-		u1bAIFS = qos_parameters->aifs[i] * ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20) + aSifsTime;
+		int slotTimeTimer = ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20);
+
+		u1bAIFS = qos_parameters->aifs[i] * slotTimeTimer + aSifsTime;
 		u1bAIFS <<= AC_PARAM_AIFS_OFFSET;
 		op_limit = (u32)le16_to_cpu(qos_parameters->tx_op_limit[i]);
 		op_limit <<= AC_PARAM_TXOP_LIMIT_OFFSET;
@@ -2071,10 +2081,12 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev)
 		return false;
 	} else if ((wpa_ie_len != 0)) {
 		/* parse pairwise key type */
-		if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4))))
-			return true;
-		else
-			return false;
+		bool wpaie_dd = (ieee->wpa_ie[0] == 0xdd &&
+				 !memcmp(&ieee->wpa_ie[14], ccmp_ie, 4));
+		bool wpaie_30 = (ieee->wpa_ie[0] == 0x30 &&
+				 !memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4));
+
+		return (wpaie_dd || wpaie_30);
 	} else {
 		return true;
 	}
@@ -2420,9 +2432,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 		int i;
 
 		for (i = 0; i < 6; i += 2) {
-			u16 tmp = 0;
+			u16 tmp = ((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
 
-			tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1));
+			tmp = eprom_read(dev, tmp);
 			*(u16 *)(&dev->dev_addr[i]) = tmp;
 		}
 	} else {
@@ -2952,9 +2964,11 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 			u32 tmpRegA = rtl8192_QueryBBReg(dev,
 							 rOFDM0_XATxIQImbalance,
 							 bMaskDWord);
+			txbbgain_struct *tx = priv->txbbgain_table;
+			ccktxbbgain_struct *cck = priv->cck_txbbgain_table;
 
 			for (i = 0; i < TxBBGainTableLength; i++) {
-				if (tmpRegA == priv->txbbgain_table[i].txbbgain_value) {
+				if (tmpRegA == tx[i].txbbgain_value) {
 					priv->rfa_txpowertrackingindex = (u8)i;
 					priv->rfa_txpowertrackingindex_real =
 						(u8)i;
@@ -2969,8 +2983,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 						     bMaskByte2);
 
 			for (i = 0; i < CCKTxBBGainTableLength; i++) {
-
-				if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) {
+				if (TempCCk == cck[i].ccktxbb_valuearray[0]) {
 					priv->cck_present_attentuation_20Mdefault = (u8)i;
 					break;
 				}
@@ -3030,13 +3043,15 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	u8			QueueID;
 	bool			bCheckFwTxCnt = false;
+	struct ieee80211_device *ieee = priv->ieee80211;
 
 	/* Decide such threshold according to current power save mode */
 
 	for (QueueID = 0; QueueID <= BEACON_QUEUE; QueueID++) {
 		if (QueueID == TXCMD_QUEUE)
 			continue;
-		if ((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0)  && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
+		if (skb_queue_len(&ieee->skb_waitQ[QueueID]) == 0 &&
+		    skb_queue_len(&ieee->skb_aggQ[QueueID]) == 0)
 			continue;
 
 		bCheckFwTxCnt = true;
@@ -3057,6 +3072,8 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	bool bStuck = false;
 	static u8	rx_chk_cnt;
+	long pwdb = priv->undecorated_smoothed_pwdb;
+	bool channelWidth20;
 
 	read_nic_word(dev, 0x130, &RegRxCounter);
 	RT_TRACE(COMP_RESET,
@@ -3066,18 +3083,21 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 	 * or maybe it will continuous silent reset every 2 seconds.
 	 */
 	rx_chk_cnt++;
-	if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High + 5)) {
+
+	channelWidth20 = (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20);
+
+	if (pwdb >= (RateAdaptiveTH_High + 5)) {
 		rx_chk_cnt = 0;	/* high rssi, check rx stuck right now. */
-	} else if (priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5) &&
-		   ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M) ||
-		    (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M))) {
+	} else if (pwdb < (RateAdaptiveTH_High + 5) &&
+		   ((!channelWidth20 && pwdb >= RateAdaptiveTH_Low_40M) ||
+		    (channelWidth20 && pwdb >= RateAdaptiveTH_Low_20M))) {
 		if (rx_chk_cnt < 2)
 			return bStuck;
 
 		rx_chk_cnt = 0;
-	} else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M) ||
-		    (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M)) &&
-		     priv->undecorated_smoothed_pwdb >= VeryLowRSSI) {
+	} else if (((!channelWidth20 && pwdb < RateAdaptiveTH_Low_40M) ||
+		    (channelWidth20 && pwdb < RateAdaptiveTH_Low_20M)) &&
+		     pwdb >= VeryLowRSSI) {
 		if (rx_chk_cnt < 4)
 			return bStuck;
 
@@ -3393,6 +3413,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 	bool bBusyTraffic = false;
 	u32	TotalRxBcnNum = 0;
 	u32	TotalRxDataNum = 0;
+	bool resetSilent;
 
 	if (!priv->up)
 		return;
@@ -3438,10 +3459,14 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 		ResetType = rtl819x_ifcheck_resetornot(dev);
 		check_reset_cnt = 3;
 	}
+
 	/* This is control by OID set in Pomelo */
-	if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
-	    (priv->bForcedSilentReset ||
-	    (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) {
+	resetSilent = (!priv->bDisableNormalResetCheck &&
+		       ResetType == RESET_TYPE_SILENT);
+	resetSilent = (priv->bForcedSilentReset || resetSilent);
+
+	if (priv->force_reset ||
+	    (priv->ResetProgress == RESET_TYPE_NORESET && resetSilent)) {
 		RT_TRACE(COMP_RESET,
 			 "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",
 			 __func__, priv->force_reset, priv->ResetProgress,
@@ -4204,7 +4229,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc;
 	u8	*prxpkt;
 	u8	i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
-	char	rx_pwr[4], rx_pwr_all = 0;
+	char	rx_pwr[4], rx_pwr_all = 0, tmp;
 	char	rx_snrX, rx_evmX;
 	u8	evm, pwdb_all;
 	u32	RSSI, total_rssi = 0;
@@ -4253,35 +4278,37 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 		if (!priv->bCckHighPower) {
 			report = pcck_buf->cck_agc_rpt & 0xc0;
 			report >>= 6;
+			tmp = pcck_buf->cck_agc_rpt & 0x3e;
 			switch (report) {
 			case 0x3:
-				rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -35 - tmp;
 				break;
 			case 0x2:
-				rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -23 - tmp;
 				break;
 			case 0x1:
-				rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = -11 - tmp;
 				break;
 			case 0x0:
-				rx_pwr_all = 6 - (pcck_buf->cck_agc_rpt & 0x3e);
+				rx_pwr_all = 6 - tmp;
 				break;
 			}
 		} else {
 			report = pcck_buf->cck_agc_rpt & 0x60;
 			report >>= 5;
+			tmp = (pcck_buf->cck_agc_rpt & 0x1f) << 1;
 			switch (report) {
 			case 0x3:
-				rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -35 - tmp;
 				break;
 			case 0x2:
-				rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -23 - tmp;
 				break;
 			case 0x1:
-				rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = -11 - tmp;
 				break;
 			case 0x0:
-				rx_pwr_all = 6 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1);
+				rx_pwr_all = 6 - tmp;
 				break;
 			}
 		}
@@ -4410,9 +4437,11 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	} else {
 		/* We can judge RX path number now. */
 		if (rf_rx_num != 0) {
+			long currsig = (total_rssi /= rf_rx_num);
+
 			pstats->SignalStrength =
 				precord_stats->SignalStrength =
-				(u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num)));
+				(u8)(rtl819x_signal_scale_mapping(currsig));
 		}
 	}
 }	/* QueryRxPhyStatus8190Pci */
@@ -4442,6 +4471,8 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	static struct ieee80211_rx_stats  previous_stats;
 	struct rtl_80211_hdr_3addr *hdr;
 	u16 fc, type;
+	u8 *addr;
+	bool bssid_eq_addr;
 
 	/* Get Signal Quality for only RX data queue (but not command queue) */
 
@@ -4456,10 +4487,19 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 	type = WLAN_FC_GET_TYPE(fc);
 	praddr = hdr->addr1;
 
+	if (fc & IEEE80211_FCTL_TODS)
+		addr = hdr->addr1;
+	else if (fc & IEEE80211_FCTL_FROMDS)
+		addr = hdr->addr2;
+	else
+		addr = hdr->addr3;
+
+	bssid_eq_addr = eqMacAddr(priv->ieee80211->current_network.bssid, addr);
+
 	/* Check if the received packet is acceptable. */
 	bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) &&
-			       (eqMacAddr(priv->ieee80211->current_network.bssid,  (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
-			       && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV);
+			       bssid_eq_addr && (!pstats->bHwError) &&
+			       (!pstats->bCRC) && (!pstats->bICV);
 	bpacket_toself =  bpacket_match_bssid &
 			  (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
 
@@ -4731,9 +4771,10 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 	u32 rx_pkt_len = 0;
 	struct rtl_80211_hdr_1addr *ieee80211_hdr = NULL;
 	bool unicast_packet = false;
+	int size = 20 + sizeof(rx_desc_819x_usb);
 
 	/* 20 is for ps-poll */
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= size) && (skb->len < RX_URB_SIZE)) {
 		/* first packet should not contain Rx aggregation header */
 		query_rxdesc_status(skb, &stats, false);
 		/* TODO */
@@ -4839,8 +4880,9 @@ static void rtl8192_rx_cmd(struct sk_buff *skb)
 		.rate = 0,
 		.freq = IEEE80211_24GHZ_BAND,
 	};
+	int size = 20 + sizeof(rx_desc_819x_usb);
 
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= size) && (skb->len < RX_URB_SIZE)) {
 
 		query_rx_cmdpkt_desc_status(skb, &stats);
 		/* prfd->queue_id = 1; */
@@ -5081,11 +5123,17 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 	struct ieee80211_device *ieee = priv->ieee80211;
 
+	bool ktype_wep = (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
+			 (KEY_TYPE_WEP104 == ieee->pairwise_key_type);
+	bool ktype_ccmp_tkip = ieee->pairwise_key_type
+			       & (KEY_TYPE_CCMP | KEY_TYPE_TKIP);
+
 	SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
-	if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) {
+
+	if (ktype_wep && (priv->ieee80211->auth_mode != 2)) {
 		SECR_value |= SCR_RxUseDK;
 		SECR_value |= SCR_TxUseDK;
-	} else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) {
+	} else if (ktype_ccmp_tkip && (ieee->iw_mode == IW_MODE_ADHOC)) {
 		SECR_value |= SCR_RxUseDK;
 		SECR_value |= SCR_TxUseDK;
 	}
@@ -5152,7 +5200,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
 		} else {
 			/* Key Material */
 			if (KeyContent != NULL) {
-				write_nic_dword(dev, WCAMI, (u32)(*(KeyContent + i - 2)));
+				TargetContent = (u32)(*(KeyContent + i - 2));
+				write_nic_dword(dev, WCAMI, TargetContent);
 				write_nic_dword(dev, RWCAM, TargetCommand);
 			}
 		}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (18 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Reverse some conditions to clean the code and allow to have lines
under 80 characters, as to follow the kernel code style.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 48 ++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 2abc3e77..7fe86ff 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -196,18 +196,19 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
 				 __func__);
 		}
 		cl = ChannelPlan[channel_plan];
-		if (cl.Len != 0) {
-			/* Clear old channel map */
-			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
-			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
-			/* Set new channel map */
-			for (i = 0; i < cl.Len; i++) {
-				u8 chan = cl.Channel[i];
-
-				if (chan < min_chan || chan > max_chan)
-					break;
-				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
-			}
+		if (cl.Len == 0)
+			break;
+
+		/* Clear old channel map */
+		memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
+		       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
+		/* Set new channel map */
+		for (i = 0; i < cl.Len; i++) {
+			u8 chan = cl.Channel[i];
+
+			if (chan < min_chan || chan > max_chan)
+				break;
+			GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
 		}
 		break;
 
@@ -1082,17 +1083,18 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
 	 */
 
 	/* Handle MPDU in wait queue. */
-	if (queue_index != BEACON_QUEUE) {
-		/* Don't send data frame during scanning.*/
-		if ((skb_queue_len(&priv->ieee80211->skb_waitQ[queue_index]) != 0) &&
-		    (!(priv->ieee80211->queue_stop))) {
-			skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]));
-			if (skb)
-				priv->ieee80211->softmac_hard_start_xmit(skb,
-									 dev);
-
-			return; /* avoid further processing AMSDU */
-		}
+	if (queue_index == BEACON_QUEUE)
+		return;
+
+	/* Don't send data frame during scanning.*/
+	if ((skb_queue_len(&priv->ieee80211->skb_waitQ[queue_index]) != 0) &&
+	    (!(priv->ieee80211->queue_stop))) {
+		skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]));
+		if (skb)
+			priv->ieee80211->softmac_hard_start_xmit(skb,
+								 dev);
+
+		return; /* avoid further processing AMSDU */
 	}
 
 }
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (19 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get " Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: " Raphaël Beamonte
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Reverse conditions and use goto in the function rtl8192_adapter_start
to have most of it under 80 characters per line.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 91 ++++++++++++++++++----------------
 1 file changed, 47 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 7fe86ff..eb9c07e 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2766,6 +2766,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	bool init_status = true;
 	u8 SECR_value = 0x0;
 	u8 tmp;
+	u32 i, TempCCk, tmpRegA;
 
 	RT_TRACE(COMP_INIT, "====>%s()\n", __func__);
 	priv->Rf_Mode = RF_OP_By_SW_3wire;
@@ -2947,59 +2948,61 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
 	rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
 
-	if (priv->ResetProgress == RESET_TYPE_NORESET) {
-		/* if D or C cut */
-		u8 tmpvalue;
+	if (priv->ResetProgress != RESET_TYPE_NORESET)
+		goto end;
 
-		read_nic_byte(dev, 0x301, &tmpvalue);
-		if (tmpvalue == 0x03) {
-			priv->bDcut = true;
-			RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
-		} else {
-			priv->bDcut = false;
-			RT_TRACE(COMP_POWER_TRACKING, "C-cut\n");
+	/* if D or C cut */
+	read_nic_byte(dev, 0x301, &tmp);
+	if (tmp == 0x03) {
+		priv->bDcut = true;
+		RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
+	} else {
+		priv->bDcut = false;
+		RT_TRACE(COMP_POWER_TRACKING, "C-cut\n");
+	}
+	dm_initialize_txpower_tracking(dev);
+
+	if (!priv->bDcut)
+		goto end;
+
+	tmpRegA = rtl8192_QueryBBReg(dev,
+				     rOFDM0_XATxIQImbalance,
+				      bMaskDWord);
+
+	for (i = 0; i < TxBBGainTableLength; i++) {
+		txbbgain_struct tx = priv->txbbgain_table[i];
+
+		if (tmpRegA == tx.txbbgain_value) {
+			priv->rfa_txpowertrackingindex = (u8)i;
+			priv->rfa_txpowertrackingindex_real =
+				(u8)i;
+			priv->rfa_txpowertracking_default =
+				priv->rfa_txpowertrackingindex;
+			break;
 		}
-		dm_initialize_txpower_tracking(dev);
-
-		if (priv->bDcut) {
-			u32 i, TempCCk;
-			u32 tmpRegA = rtl8192_QueryBBReg(dev,
-							 rOFDM0_XATxIQImbalance,
-							 bMaskDWord);
-			txbbgain_struct *tx = priv->txbbgain_table;
-			ccktxbbgain_struct *cck = priv->cck_txbbgain_table;
-
-			for (i = 0; i < TxBBGainTableLength; i++) {
-				if (tmpRegA == tx[i].txbbgain_value) {
-					priv->rfa_txpowertrackingindex = (u8)i;
-					priv->rfa_txpowertrackingindex_real =
-						(u8)i;
-					priv->rfa_txpowertracking_default =
-						priv->rfa_txpowertrackingindex;
-					break;
-				}
-			}
+	}
 
-			TempCCk = rtl8192_QueryBBReg(dev,
-						     rCCK0_TxFilter1,
-						     bMaskByte2);
+	TempCCk = rtl8192_QueryBBReg(dev,
+				     rCCK0_TxFilter1,
+				     bMaskByte2);
 
-			for (i = 0; i < CCKTxBBGainTableLength; i++) {
-				if (TempCCk == cck[i].ccktxbb_valuearray[0]) {
-					priv->cck_present_attentuation_20Mdefault = (u8)i;
-					break;
-				}
-			}
-			priv->cck_present_attentuation_40Mdefault = 0;
-			priv->cck_present_attentuation_difference = 0;
-			priv->cck_present_attentuation =
-				priv->cck_present_attentuation_20Mdefault;
+	for (i = 0; i < CCKTxBBGainTableLength; i++) {
+		ccktxbbgain_struct cck = priv->cck_txbbgain_table[i];
 
+		if (TempCCk == cck.ccktxbb_valuearray[0]) {
+			priv->cck_present_attentuation_20Mdefault = (u8)i;
+			break;
 		}
 	}
-	write_nic_byte(dev, 0x87, 0x0);
+	priv->cck_present_attentuation_40Mdefault = 0;
+	priv->cck_present_attentuation_difference = 0;
+	priv->cck_present_attentuation =
+		priv->cck_present_attentuation_20Mdefault;
 
 
+end:
+	write_nic_byte(dev, 0x87, 0x0);
+
 	return init_status;
 }
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (20 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte
                   ` (9 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Refactor code to avoid multiple check of same boolean value, and to
make the code clearer. This patches also implements the necessary
changes for the code lines in this function to be under 80 chars.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 259 ++++++++++++++++++++-------------
 1 file changed, 155 insertions(+), 104 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index eb9c07e..7314e2f 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2447,129 +2447,180 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 	priv->rf_type = RTL819X_DEFAULT_RF_TYPE; /* default 1T2R */
 	priv->rf_chip = RF_8256;
 
-	if (priv->card_8192_version == (u8)VERSION_819xU_A) {
+	/* if version mismatch VERSION_819xU_A, go directly to the led section
+	 */
+	if (priv->card_8192_version != (u8)VERSION_819xU_A)
+		goto led;
+
+	if (bLoad_From_EEPOM) {
 		/* read Tx power gain offset of legacy OFDM to HT rate */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMTxPowerDiff = (eprom_read(dev, (EEPROM_TxPowerDiff >> 1)) & 0xff00) >> 8;
-		else
-			priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower;
-		RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff);
+		tmpValue = eprom_read(dev, (EEPROM_TxPowerDiff >> 1));
+		priv->EEPROMTxPowerDiff = (tmpValue & 0xff00) >> 8;
+
 		/* read ThermalMeter from EEPROM */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMThermalMeter = (u8)(eprom_read(dev, (EEPROM_ThermalMeter >> 1)) & 0x00ff);
-		else
-			priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
-		RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter);
-		/* for tx power track */
-		priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100;
+		tmpValue = eprom_read(dev, (EEPROM_ThermalMeter >> 1));
+		priv->EEPROMThermalMeter = (u8)(tmpValue & 0x00ff);
+
 		/* read antenna tx power offset of B/C/D to A from EEPROM */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMPwDiff = (eprom_read(dev, (EEPROM_PwDiff >> 1)) & 0x0f00) >> 8;
-		else
-			priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
-		RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff);
+		tmpValue = eprom_read(dev, (EEPROM_PwDiff >> 1));
+		priv->EEPROMPwDiff = (tmpValue & 0x0f00) >> 8;
+
 		/* Read CrystalCap from EEPROM */
-		if (bLoad_From_EEPOM)
-			priv->EEPROMCrystalCap = (eprom_read(dev, (EEPROM_CrystalCap >> 1)) & 0x0f);
-		else
-			priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
-		RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap);
+		tmpValue = eprom_read(dev, (EEPROM_CrystalCap >> 1));
+		priv->EEPROMCrystalCap = (tmpValue & 0x0f);
+
 		/* get per-channel Tx power level */
-		if (bLoad_From_EEPOM)
-			priv->EEPROM_Def_Ver = (eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1)) & 0xff00) >> 8;
-		else
-			priv->EEPROM_Def_Ver = 1;
-		RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver);
+		tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1));
+		priv->EEPROM_Def_Ver = (tmpValue & 0xff00) >> 8;
+	} else {
+		/* read Tx power gain offset of legacy OFDM to HT rate */
+		priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower;
+
+		/* read ThermalMeter from EEPROM */
+		priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
+
+		/* read antenna tx power offset of B/C/D to A from EEPROM */
+		priv->EEPROMPwDiff = EEPROM_Default_PwDiff;
+
+		/* Read CrystalCap from EEPROM */
+		priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
+
+		/* get per-channel Tx power level */
+		priv->EEPROM_Def_Ver = 1;
+	}
+
+	/* for tx power track */
+	priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100;
+
+	RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff);
+	RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter);
+	RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff);
+	RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap);
+	RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver);
+
+	if (bLoad_From_EEPOM) {
 		if (priv->EEPROM_Def_Ver == 0) { /* old eeprom definition */
 			int i;
 
-			if (bLoad_From_EEPOM)
-				priv->EEPROMTxPowerLevelCCK = (eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1)) & 0xff) >> 8;
-			else
-				priv->EEPROMTxPowerLevelCCK = 0x10;
-			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
+			tmpValue = (EEPROM_TxPwIndex_CCK >> 1) & 0xff;
+			tmpValue = eprom_read(dev, tmpValue);
+			priv->EEPROMTxPowerLevelCCK = tmpValue >> 8;
+
+			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n",
+				 priv->EEPROMTxPowerLevelCCK);
+
 			for (i = 0; i < 3; i++) {
-				if (bLoad_From_EEPOM) {
-					tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1);
-					if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0)
-						tmpValue = tmpValue & 0x00ff;
-					else
-						tmpValue = (tmpValue & 0xff00) >> 8;
-				} else {
-					tmpValue = 0x10;
-				}
-				priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)tmpValue;
-				RT_TRACE(COMP_EPROM, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK);
+				tmpValue = (EEPROM_TxPwIndex_OFDM_24G + i) >> 1;
+				tmpValue = eprom_read(dev, tmpValue);
+				if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0)
+					tmpValue = tmpValue & 0x00ff;
+				else
+					tmpValue = (tmpValue & 0xff00) >> 8;
+
+				priv->EEPROMTxPowerLevelOFDM24G[i] =
+					(u8)tmpValue;
+
+				RT_TRACE(COMP_EPROM,
+					 "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n",
+					 i, priv->EEPROMTxPowerLevelCCK);
 			}
 		} else if (priv->EEPROM_Def_Ver == 1) {
-			if (bLoad_From_EEPOM) {
-				tmpValue = eprom_read(dev,
-						EEPROM_TxPwIndex_CCK_V1 >> 1);
-				tmpValue = (tmpValue & 0xff00) >> 8;
-			} else {
-				tmpValue = 0x10;
-			}
+			tmpValue = EEPROM_TxPwIndex_CCK_V1 >> 1;
+			tmpValue = eprom_read(dev, tmpValue);
+			tmpValue = (tmpValue & 0xff00) >> 8;
 			priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)tmpValue;
 
-			if (bLoad_From_EEPOM)
-				tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1);
-			else
-				tmpValue = 0x1010;
-			*((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = tmpValue;
-			if (bLoad_From_EEPOM)
-				tmpValue = eprom_read(dev,
-					EEPROM_TxPwIndex_OFDM_24G_V1 >> 1);
-			else
-				tmpValue = 0x1010;
-			*((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) = tmpValue;
-			if (bLoad_From_EEPOM)
-				tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1 + 2) >> 1);
-			else
-				tmpValue = 0x10;
+			tmpValue = (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1;
+			*((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) =
+				eprom_read(dev, tmpValue);
+
+			tmpValue = EEPROM_TxPwIndex_OFDM_24G_V1 >> 1;
+			*((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) =
+				eprom_read(dev, tmpValue);
+
+			tmpValue = (EEPROM_TxPwIndex_OFDM_24G_V1 + 2) >> 1;
+			tmpValue = eprom_read(dev, tmpValue);
 			priv->EEPROMTxPowerLevelOFDM24G[2] = (u8)tmpValue;
 		} /* endif EEPROM_Def_Ver == 1 */
+	} else {
+		if (priv->EEPROM_Def_Ver == 0) { /* old eeprom definition */
+			int i;
 
-		/* update HAL variables */
-		for (i = 0; i < 14; i++) {
-			if (i <= 3)
-				priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[0];
-			else if (i >= 4 && i <= 9)
-				priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[1];
-			else
-				priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[2];
-		}
+			priv->EEPROMTxPowerLevelCCK = 0x10;
 
-		for (i = 0; i < 14; i++) {
-			if (priv->EEPROM_Def_Ver == 0) {
-				if (i <= 3)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelOFDM24G[0] + (priv->EEPROMTxPowerLevelCCK - priv->EEPROMTxPowerLevelOFDM24G[1]);
-				else if (i >= 4 && i <= 9)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK;
-				else
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelOFDM24G[2] + (priv->EEPROMTxPowerLevelCCK - priv->EEPROMTxPowerLevelOFDM24G[1]);
-			} else if (priv->EEPROM_Def_Ver == 1) {
-				if (i <= 3)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[0];
-				else if (i >= 4 && i <= 9)
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[1];
-				else
-					priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK_V1[2];
+			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n",
+				 priv->EEPROMTxPowerLevelCCK);
+
+			for (i = 0; i < 3; i++) {
+				priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)0x10;
+				RT_TRACE(COMP_EPROM,
+					 "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n",
+					 i, priv->EEPROMTxPowerLevelCCK);
 			}
-		}
-		priv->TxPowerDiff = priv->EEPROMPwDiff;
-		/* Antenna B gain offset to antenna A, bit0~3 */
-		priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
-		/* Antenna C gain offset to antenna A, bit4~7 */
-		priv->AntennaTxPwDiff[1] =
-			(priv->EEPROMTxPowerDiff & 0xf0) >> 4;
-		/* CrystalCap, bit12~15 */
-		priv->CrystalCap = priv->EEPROMCrystalCap;
-		/* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
-		 * 92U does not enable TX power tracking.
-		 */
-		priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
-	} /* end if VersionID == VERSION_819xU_A */
+		} else if (priv->EEPROM_Def_Ver == 1) {
+			priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)0x10;
+			*((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = 0x1010;
+			*((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) =
+				0x1010;
+			priv->EEPROMTxPowerLevelOFDM24G[2] = (u8)0x10;
+		} /* endif EEPROM_Def_Ver == 1 */
+	}
+
+	/* update HAL variables */
+	for (i = 0; i < 4; i++) {
+		priv->TxPowerLevelOFDM24G[i] =
+			priv->EEPROMTxPowerLevelOFDM24G[0];
+
+		if (priv->EEPROM_Def_Ver == 0)
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelOFDM24G[0] +
+				priv->EEPROMTxPowerLevelCCK -
+				priv->EEPROMTxPowerLevelOFDM24G[1];
+		else
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK_V1[0];
+	}
+
+	for (i = 4; i < 10; i++) {
+		priv->TxPowerLevelOFDM24G[i] =
+			priv->EEPROMTxPowerLevelOFDM24G[1];
+
+		if (priv->EEPROM_Def_Ver == 0)
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK;
+		else
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK_V1[1];
+	}
+
+	for (i = 10; i < 14; i++) {
+		priv->TxPowerLevelOFDM24G[i] =
+			priv->EEPROMTxPowerLevelOFDM24G[2];
+
+		if (priv->EEPROM_Def_Ver == 0)
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelOFDM24G[2] +
+				priv->EEPROMTxPowerLevelCCK -
+				priv->EEPROMTxPowerLevelOFDM24G[1];
+		else
+			priv->TxPowerLevelCCK[i] =
+				priv->EEPROMTxPowerLevelCCK_V1[2];
+	}
+
+	priv->TxPowerDiff = priv->EEPROMPwDiff;
+	/* Antenna B gain offset to antenna A, bit0~3 */
+	priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
+	/* Antenna C gain offset to antenna A, bit4~7 */
+	priv->AntennaTxPwDiff[1] =
+		(priv->EEPROMTxPowerDiff & 0xf0) >> 4;
+	/* CrystalCap, bit12~15 */
+	priv->CrystalCap = priv->EEPROMCrystalCap;
+	/* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
+	 * 92U does not enable TX power tracking.
+	 */
+	priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
 
+led:
 	/* for dlink led */
 	switch (priv->eeprom_CustomerID) {
 	case EEPROM_CID_RUNTOP:
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (21 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: " Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Rename variable to a shorter name to allow easier code refactoring
in following patch.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 84 +++++++++++++++++-----------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 7314e2f..1fd51ab 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3993,7 +3993,7 @@ static long rtl819x_translate_todbm(u8 signal_strength_index)
  * and it will be reinitialized when returned from S3/S4.
  */
 static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
-				    struct ieee80211_rx_stats *pprevious_stats,
+				    struct ieee80211_rx_stats *prev_stats,
 				    struct ieee80211_rx_stats *pcurrent_stats)
 {
 	bool bcheck = false;
@@ -4019,7 +4019,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	pcurrent_stats->Seq_Num = seq;
 
 	/* Check whether we should take the previous packet into accounting */
-	if (!pprevious_stats->bIsAMPDU) {
+	if (!prev_stats->bIsAMPDU) {
 		/* if previous packet is not aggregated packet */
 		bcheck = true;
 	}
@@ -4029,10 +4029,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		last_rssi = priv->stats.slide_signal_strength[slide_rssi_index];
 		priv->stats.slide_rssi_total -= last_rssi;
 	}
-	priv->stats.slide_rssi_total += pprevious_stats->SignalStrength;
+	priv->stats.slide_rssi_total += prev_stats->SignalStrength;
 
 	priv->stats.slide_signal_strength[slide_rssi_index++] =
-		pprevious_stats->SignalStrength;
+		prev_stats->SignalStrength;
 	if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
 		slide_rssi_index = 0;
 
@@ -4042,8 +4042,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	pcurrent_stats->rssi = priv->stats.signal_strength;
 
 	/* If the previous packet does not match the criteria, neglect it */
-	if (!pprevious_stats->bPacketMatchBSSID) {
-		if (!pprevious_stats->bToSelfBA)
+	if (!prev_stats->bPacketMatchBSSID) {
+		if (!prev_stats->bToSelfBA)
 			return;
 	}
 
@@ -4052,7 +4052,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 
 	/* only rtl8190 supported
-	 * rtl8190_process_cck_rxpathsel(priv,pprevious_stats);
+	 * rtl8190_process_cck_rxpathsel(priv,prev_stats);
 	 */
 
 	/* Check RSSI */
@@ -4064,8 +4064,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	/* <2> Showed on UI for engineering
 	 * hardware does not provide rssi information for each rf path in CCK
 	 */
-	if (!pprevious_stats->bIsCCK &&
-	    (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) {
+	if (!prev_stats->bIsCCK &&
+	    (prev_stats->bPacketToSelf || prev_stats->bToSelfBA)) {
 		for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) {
 			if (!rtl8192_phy_CheckIsLegalRFPath(
 					priv->ieee80211->dev, rfpath))
@@ -4073,16 +4073,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 			if (priv->stats.rx_rssi_percentage[rfpath] == 0)
 				priv->stats.rx_rssi_percentage[rfpath] =
-					pprevious_stats->RxMIMOSignalStrength[rfpath];
-			if (pprevious_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
+					prev_stats->RxMIMOSignalStrength[rfpath];
+			if (prev_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
 				priv->stats.rx_rssi_percentage[rfpath] =
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
+					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
 				priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath]  + 1;
 			} else {
 				priv->stats.rx_rssi_percentage[rfpath] =
 					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
+					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
 			}
 			RT_TRACE(COMP_DBG,
 				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
@@ -4093,57 +4093,57 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	/* Check PWDB. */
 	RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
-		 pprevious_stats->bIsCCK ? "CCK" : "OFDM",
-		 pprevious_stats->RxPWDBAll);
+		 prev_stats->bIsCCK ? "CCK" : "OFDM",
+		 prev_stats->RxPWDBAll);
 
-	if (pprevious_stats->bPacketBeacon) {
+	if (prev_stats->bPacketBeacon) {
 		/* record the beacon pwdb to the sliding window. */
 		if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
 			slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
 			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
 			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
-		priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll;
-		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll;
+		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
+		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = prev_stats->RxPWDBAll;
 		slide_beacon_adc_pwdb_index++;
 		if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			slide_beacon_adc_pwdb_index = 0;
-		pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
-		if (pprevious_stats->RxPWDBAll >= 3)
-			pprevious_stats->RxPWDBAll -= 3;
+		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
+		if (prev_stats->RxPWDBAll >= 3)
+			prev_stats->RxPWDBAll -= 3;
 	}
 
 	RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
-		 pprevious_stats->bIsCCK ? "CCK" : "OFDM",
-		 pprevious_stats->RxPWDBAll);
+		 prev_stats->bIsCCK ? "CCK" : "OFDM",
+		 prev_stats->RxPWDBAll);
 
 
-	if (pprevious_stats->bPacketToSelf ||
-	    pprevious_stats->bPacketBeacon ||
-	    pprevious_stats->bToSelfBA) {
+	if (prev_stats->bPacketToSelf ||
+	    prev_stats->bPacketBeacon ||
+	    prev_stats->bToSelfBA) {
 		if (priv->undecorated_smoothed_pwdb < 0)
 			/* initialize */
 			priv->undecorated_smoothed_pwdb =
-				pprevious_stats->RxPWDBAll;
-		if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
+				prev_stats->RxPWDBAll;
+		if (prev_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
 			priv->undecorated_smoothed_pwdb =
 				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (pprevious_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
+				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
 			priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1;
 		} else {
 			priv->undecorated_smoothed_pwdb =
 				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (pprevious_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
+				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
 		}
 
 	}
 
 	/* Check EVM */
 	/* record the general EVM to the sliding window. */
-	if (pprevious_stats->SignalQuality) {
-		if (pprevious_stats->bPacketToSelf ||
-		    pprevious_stats->bPacketBeacon ||
-		    pprevious_stats->bToSelfBA) {
+	if (prev_stats->SignalQuality) {
+		if (prev_stats->bPacketToSelf ||
+		    prev_stats->bPacketBeacon ||
+		    prev_stats->bToSelfBA) {
 			if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
 				slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
 				last_evm = priv->stats.slide_evm[slide_evm_index];
@@ -4151,10 +4151,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 			}
 
 			priv->stats.slide_evm_total +=
-				pprevious_stats->SignalQuality;
+				prev_stats->SignalQuality;
 
 			priv->stats.slide_evm[slide_evm_index++] =
-				pprevious_stats->SignalQuality;
+				prev_stats->SignalQuality;
 			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
 				slide_evm_index = 0;
 
@@ -4169,16 +4169,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		}
 
 		/* <2> Showed on UI for engineering */
-		if (pprevious_stats->bPacketToSelf ||
-		    pprevious_stats->bPacketBeacon ||
-		    pprevious_stats->bToSelfBA) {
+		if (prev_stats->bPacketToSelf ||
+		    prev_stats->bPacketBeacon ||
+		    prev_stats->bToSelfBA) {
 			for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */
-				if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
+				if (prev_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
 					if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */
-						priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream];
+						priv->stats.rx_evm_percentage[nspatial_stream] = prev_stats->RxMIMOSignalQuality[nspatial_stream];
 					priv->stats.rx_evm_percentage[nspatial_stream] =
 						((priv->stats.rx_evm_percentage[nspatial_stream] * (Rx_Smooth_Factor - 1)) +
-						 (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor);
+						 (prev_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor);
 				}
 			}
 		}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (22 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Rename variable to a shorter name to allow easier code
refactoring in following patch.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 1fd51ab..638bd5a 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4003,7 +4003,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	static u32 slide_evm_index, slide_evm_statistics;
 	static u32 last_rssi, last_evm;
 
-	static u32 slide_beacon_adc_pwdb_index;
+	static u32 sb_index;
 	static u32 slide_beacon_adc_pwdb_statistics;
 	static u32 last_beacon_adc_pwdb;
 
@@ -4100,14 +4100,14 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		/* record the beacon pwdb to the sliding window. */
 		if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
 			slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
-			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
+			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[sb_index];
 			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
 		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
-		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = prev_stats->RxPWDBAll;
-		slide_beacon_adc_pwdb_index++;
-		if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
-			slide_beacon_adc_pwdb_index = 0;
+		priv->stats.Slide_Beacon_pwdb[sb_index] = prev_stats->RxPWDBAll;
+		sb_index++;
+		if (sb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
+			sb_index = 0;
 		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
 		if (prev_stats->RxPWDBAll >= 3)
 			prev_stats->RxPWDBAll -= 3;
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (23 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte
                   ` (6 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Rename variable to a shorter name to allow easier code
refactoring in following patch.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 638bd5a..f56fb1b 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4004,7 +4004,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	static u32 last_rssi, last_evm;
 
 	static u32 sb_index;
-	static u32 slide_beacon_adc_pwdb_statistics;
+	static u32 sb_stats;
 	static u32 last_beacon_adc_pwdb;
 
 	struct rtl_80211_hdr_3addr *hdr;
@@ -4098,8 +4098,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	if (prev_stats->bPacketBeacon) {
 		/* record the beacon pwdb to the sliding window. */
-		if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
-			slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
+		if (sb_stats++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
+			sb_stats = PHY_Beacon_RSSI_SLID_WIN_MAX;
 			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[sb_index];
 			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
@@ -4108,7 +4108,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		sb_index++;
 		if (sb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			sb_index = 0;
-		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics;
+		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / sb_stats;
 		if (prev_stats->RxPWDBAll >= 3)
 			prev_stats->RxPWDBAll -= 3;
 	}
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (24 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte
                   ` (5 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Local variable last_beacon_adc_pwdb was used to store a value that wasn't
used after. This patch removes that variable.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index f56fb1b..510f08d 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4005,7 +4005,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	static u32 sb_index;
 	static u32 sb_stats;
-	static u32 last_beacon_adc_pwdb;
 
 	struct rtl_80211_hdr_3addr *hdr;
 	u16 sc;
@@ -4100,8 +4099,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		/* record the beacon pwdb to the sliding window. */
 		if (sb_stats++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) {
 			sb_stats = PHY_Beacon_RSSI_SLID_WIN_MAX;
-			last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[sb_index];
-			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
+			priv->stats.Slide_Beacon_Total -=
+				priv->stats.Slide_Beacon_pwdb[sb_index];
 		}
 		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
 		priv->stats.Slide_Beacon_pwdb[sb_index] = prev_stats->RxPWDBAll;
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (25 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte
                   ` (4 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Rename variable to a shorter name to allow easier code
refactoring in following patches.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 510f08d..b3dd18b 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3997,7 +3997,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 				    struct ieee80211_rx_stats *pcurrent_stats)
 {
 	bool bcheck = false;
-	u8	rfpath;
+	u8 rfp;
 	u32	nspatial_stream, tmp_val;
 	static u32 slide_rssi_index, slide_rssi_statistics;
 	static u32 slide_evm_index, slide_evm_statistics;
@@ -4065,27 +4065,28 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	 */
 	if (!prev_stats->bIsCCK &&
 	    (prev_stats->bPacketToSelf || prev_stats->bToSelfBA)) {
-		for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) {
+		for (rfp = RF90_PATH_A; rfp < priv->NumTotalRFPath; rfp++) {
 			if (!rtl8192_phy_CheckIsLegalRFPath(
-					priv->ieee80211->dev, rfpath))
+					priv->ieee80211->dev, rfp))
 				continue;
 
-			if (priv->stats.rx_rssi_percentage[rfpath] == 0)
-				priv->stats.rx_rssi_percentage[rfpath] =
-					prev_stats->RxMIMOSignalStrength[rfpath];
-			if (prev_stats->RxMIMOSignalStrength[rfpath]  > priv->stats.rx_rssi_percentage[rfpath]) {
-				priv->stats.rx_rssi_percentage[rfpath] =
-					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
-				priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath]  + 1;
+			if (priv->stats.rx_rssi_percentage[rfp] == 0)
+				priv->stats.rx_rssi_percentage[rfp] =
+					prev_stats->RxMIMOSignalStrength[rfp];
+
+			if (prev_stats->RxMIMOSignalStrength[rfp]  > priv->stats.rx_rssi_percentage[rfp]) {
+				priv->stats.rx_rssi_percentage[rfp] =
+					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
+					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
+				priv->stats.rx_rssi_percentage[rfp] = priv->stats.rx_rssi_percentage[rfp]  + 1;
 			} else {
-				priv->stats.rx_rssi_percentage[rfpath] =
-					((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor);
+				priv->stats.rx_rssi_percentage[rfp] =
+					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
+					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
 			}
 			RT_TRACE(COMP_DBG,
 				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
-				 priv->stats.rx_rssi_percentage[rfpath]);
+				 priv->stats.rx_rssi_percentage[rfp]);
 		}
 	}
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (26 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 12/15] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Reorganize function to make it cleaner, and respect the 80 characters
kernel code style rule.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 140 +++++++++++++++++++--------------
 1 file changed, 81 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index b3dd18b..b3cedec 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4066,6 +4066,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	if (!prev_stats->bIsCCK &&
 	    (prev_stats->bPacketToSelf || prev_stats->bToSelfBA)) {
 		for (rfp = RF90_PATH_A; rfp < priv->NumTotalRFPath; rfp++) {
+			u8 rx, add = 0;
+
 			if (!rtl8192_phy_CheckIsLegalRFPath(
 					priv->ieee80211->dev, rfp))
 				continue;
@@ -4074,16 +4076,16 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 				priv->stats.rx_rssi_percentage[rfp] =
 					prev_stats->RxMIMOSignalStrength[rfp];
 
-			if (prev_stats->RxMIMOSignalStrength[rfp]  > priv->stats.rx_rssi_percentage[rfp]) {
-				priv->stats.rx_rssi_percentage[rfp] =
-					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
-				priv->stats.rx_rssi_percentage[rfp] = priv->stats.rx_rssi_percentage[rfp]  + 1;
-			} else {
-				priv->stats.rx_rssi_percentage[rfp] =
-					((priv->stats.rx_rssi_percentage[rfp] * (Rx_Smooth_Factor - 1)) +
-					 (prev_stats->RxMIMOSignalStrength[rfp])) / (Rx_Smooth_Factor);
-			}
+			rx = priv->stats.rx_rssi_percentage[rfp];
+			if (prev_stats->RxMIMOSignalStrength[rfp] > rx)
+				add = 1;
+
+			rx *= Rx_Smooth_Factor - 1;
+			rx += prev_stats->RxMIMOSignalStrength[rfp];
+			rx /= Rx_Smooth_Factor;
+
+			priv->stats.rx_rssi_percentage[rfp] = rx + add;
+
 			RT_TRACE(COMP_DBG,
 				 "priv->stats.rx_rssi_percentage[rfPath]  = %d\n",
 				 priv->stats.rx_rssi_percentage[rfp]);
@@ -4103,12 +4105,17 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 			priv->stats.Slide_Beacon_Total -=
 				priv->stats.Slide_Beacon_pwdb[sb_index];
 		}
+
 		priv->stats.Slide_Beacon_Total += prev_stats->RxPWDBAll;
 		priv->stats.Slide_Beacon_pwdb[sb_index] = prev_stats->RxPWDBAll;
+
 		sb_index++;
 		if (sb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			sb_index = 0;
-		prev_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / sb_stats;
+
+		prev_stats->RxPWDBAll =
+			priv->stats.Slide_Beacon_Total / sb_stats;
+
 		if (prev_stats->RxPWDBAll >= 3)
 			prev_stats->RxPWDBAll -= 3;
 	}
@@ -4121,69 +4128,84 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	if (prev_stats->bPacketToSelf ||
 	    prev_stats->bPacketBeacon ||
 	    prev_stats->bToSelfBA) {
+		long pwdb, add = 0;
+
 		if (priv->undecorated_smoothed_pwdb < 0)
 			/* initialize */
 			priv->undecorated_smoothed_pwdb =
 				prev_stats->RxPWDBAll;
-		if (prev_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) {
-			priv->undecorated_smoothed_pwdb =
-				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
-			priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1;
-		} else {
-			priv->undecorated_smoothed_pwdb =
-				(((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) +
-				 (prev_stats->RxPWDBAll)) / (Rx_Smooth_Factor);
-		}
 
+		pwdb = priv->undecorated_smoothed_pwdb;
+
+		if (prev_stats->RxPWDBAll > (u32)pwdb)
+			add = 1;
+
+		pwdb *= Rx_Smooth_Factor - 1;
+		pwdb += prev_stats->RxPWDBAll;
+		pwdb /= Rx_Smooth_Factor;
+
+		priv->undecorated_smoothed_pwdb = pwdb + add;
 	}
 
+
 	/* Check EVM */
+	if (!prev_stats->SignalQuality)
+		return;
+
 	/* record the general EVM to the sliding window. */
-	if (prev_stats->SignalQuality) {
-		if (prev_stats->bPacketToSelf ||
-		    prev_stats->bPacketBeacon ||
-		    prev_stats->bToSelfBA) {
-			if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
-				slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
-				last_evm = priv->stats.slide_evm[slide_evm_index];
-				priv->stats.slide_evm_total -= last_evm;
-			}
+	if (prev_stats->bPacketToSelf ||
+	    prev_stats->bPacketBeacon ||
+	    prev_stats->bToSelfBA) {
+		if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
+			slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
+			last_evm = priv->stats.slide_evm[slide_evm_index];
+			priv->stats.slide_evm_total -= last_evm;
+		}
 
-			priv->stats.slide_evm_total +=
-				prev_stats->SignalQuality;
+		priv->stats.slide_evm_total += prev_stats->SignalQuality;
 
-			priv->stats.slide_evm[slide_evm_index++] =
-				prev_stats->SignalQuality;
-			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
-				slide_evm_index = 0;
+		priv->stats.slide_evm[slide_evm_index++] =
+			prev_stats->SignalQuality;
+		if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
+			slide_evm_index = 0;
 
-			/* <1> Showed on UI for user, in percentage. */
-			tmp_val = priv->stats.slide_evm_total /
-				  slide_evm_statistics;
-			priv->stats.signal_quality = tmp_val;
-			/* Showed on UI for user in Windows Vista,
-			 * for Link quality.
-			 */
-			priv->stats.last_signal_strength_inpercent = tmp_val;
-		}
+		/* <1> Showed on UI for user, in percentage. */
+		tmp_val = priv->stats.slide_evm_total / slide_evm_statistics;
+		priv->stats.signal_quality = tmp_val;
+		/* Showed on UI for user in Windows Vista,
+		 * for Link quality.
+		 */
+		priv->stats.last_signal_strength_inpercent = tmp_val;
+	}
 
-		/* <2> Showed on UI for engineering */
-		if (prev_stats->bPacketToSelf ||
-		    prev_stats->bPacketBeacon ||
-		    prev_stats->bToSelfBA) {
-			for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */
-				if (prev_stats->RxMIMOSignalQuality[nspatial_stream] != -1) {
-					if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */
-						priv->stats.rx_evm_percentage[nspatial_stream] = prev_stats->RxMIMOSignalQuality[nspatial_stream];
-					priv->stats.rx_evm_percentage[nspatial_stream] =
-						((priv->stats.rx_evm_percentage[nspatial_stream] * (Rx_Smooth_Factor - 1)) +
-						 (prev_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor);
-				}
-			}
+	/* <2> Showed on UI for engineering */
+	if (!prev_stats->bPacketToSelf &&
+	    !prev_stats->bPacketBeacon &&
+	    !prev_stats->bToSelfBA)
+		return;
+
+	/* 2 spatial stream */
+	for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) {
+		u8 utmp;
+		s8 stmp;
+
+		if (prev_stats->RxMIMOSignalQuality[nspatial_stream] == -1)
+			continue;
+
+		/* initialize */
+		if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) {
+			stmp = prev_stats->RxMIMOSignalQuality[nspatial_stream];
+			priv->stats.rx_evm_percentage[nspatial_stream] = stmp;
 		}
-	}
 
+		utmp = priv->stats.rx_evm_percentage[nspatial_stream];
+		utmp *= Rx_Smooth_Factor - 1;
+
+		stmp = prev_stats->RxMIMOSignalQuality[nspatial_stream];
+
+		priv->stats.rx_evm_percentage[nspatial_stream] =
+			(utmp + stmp) / Rx_Smooth_Factor;
+	}
 
 }
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 12/15] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (27 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte
                   ` (2 subsequent siblings)
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Replace some inline conditions by a full if-else statement to make
the source clearer and follow the 80 characters kernel code style
rule.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index b3cedec..7dc1b34 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1546,12 +1546,18 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	tx_fwinfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0;
 	tx_fwinfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0;
 	tx_fwinfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0;
-	tx_fwinfo->RtsHT = (tcb_desc->rts_rate & 0x80) ? 1 : 0;
 	tx_fwinfo->RtsRate =  MRateToHwRate8190Pci((u8)tcb_desc->rts_rate);
-	tx_fwinfo->RtsSubcarrier = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->RTSSC) : 0;
-	tx_fwinfo->RtsBandwidth = (tx_fwinfo->RtsHT == 1) ? ((tcb_desc->bRTSBW) ? 1 : 0) : 0;
-	tx_fwinfo->RtsShort = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) :
-			      (tcb_desc->bRTSUseShortGI ? 1 : 0);
+	if (tcb_desc->rts_rate & 0x80) {
+		tx_fwinfo->RtsHT = 1;
+		tx_fwinfo->RtsSubcarrier = 0;
+		tx_fwinfo->RtsBandwidth = (tcb_desc->bRTSBW) ? 1 : 0;
+		tx_fwinfo->RtsShort = (tcb_desc->bRTSUseShortGI ? 1 : 0);
+	} else {
+		tx_fwinfo->RtsHT = 0;
+		tx_fwinfo->RtsSubcarrier = tcb_desc->RTSSC;
+		tx_fwinfo->RtsBandwidth = 0;
+		tx_fwinfo->RtsShort = (tcb_desc->bRTSUseShortPreamble ? 1 : 0);
+	}
 
 	/* Set Bandwidth and sub-channel settings. */
 	if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) {
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (28 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 12/15] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

Reorganize function rtl8192_ioctl to replace a switch with only
one case besides the default by an if statement. This also allows
to follow the 80 characters kernel code style rule.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 141 ++++++++++++++++-----------------
 1 file changed, 68 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 7dc1b34..171a494 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3751,82 +3751,77 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 		goto out;
 	}
 
-	switch (cmd) {
-	case RTL_IOCTL_WPA_SUPPLICANT:
-		/* parse here for HW security */
-		if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) {
-			if (ipw->u.crypt.set_tx) {
-				if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
-					ieee->pairwise_key_type = KEY_TYPE_CCMP;
-				} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
-					ieee->pairwise_key_type = KEY_TYPE_TKIP;
-				} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
-					if (ipw->u.crypt.key_len == 13)
-						ieee->pairwise_key_type = KEY_TYPE_WEP104;
-					else if (ipw->u.crypt.key_len == 5)
-						ieee->pairwise_key_type = KEY_TYPE_WEP40;
-				} else {
-					ieee->pairwise_key_type = KEY_TYPE_NA;
-				}
-
-				if (ieee->pairwise_key_type) {
-					memcpy((u8 *)key, ipw->u.crypt.key, 16);
-					EnableHWSecurityConfig8192(dev);
-					/* We fill both index entry and 4th
-					 * entry for pairwise key as in IPW
-					 * interface, adhoc will only get here,
-					 * so we need index entry for its
-					 * default key serching!
-					 */
-					setKey(dev, 4, ipw->u.crypt.idx,
-					       ieee->pairwise_key_type,
-					       (u8 *)ieee->ap_mac_addr,
-					       0, key);
-					if (ieee->auth_mode != 2)
-						setKey(dev, ipw->u.crypt.idx,
-						       ipw->u.crypt.idx,
-						       ieee->pairwise_key_type,
-						       (u8 *)ieee->ap_mac_addr,
-						       0, key);
-				}
-			} else {
-				memcpy((u8 *)key, ipw->u.crypt.key, 16);
-				if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
-					ieee->group_key_type = KEY_TYPE_CCMP;
-				} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
-					ieee->group_key_type = KEY_TYPE_TKIP;
-				} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
-					if (ipw->u.crypt.key_len == 13)
-						ieee->group_key_type = KEY_TYPE_WEP104;
-					else if (ipw->u.crypt.key_len == 5)
-						ieee->group_key_type = KEY_TYPE_WEP40;
-				} else {
-					ieee->group_key_type = KEY_TYPE_NA;
-				}
-
-				if (ieee->group_key_type) {
-					setKey(dev, ipw->u.crypt.idx,
-					       /* KeyIndex */
-					       ipw->u.crypt.idx,
-					       /* KeyType */
-					       ieee->group_key_type,
-					       /* MacAddr */
-					       broadcast_addr,
-					       /* DefaultKey */
-					       0,
-					       /* KeyContent */
-					       key);
-				}
-			}
+	if (cmd != RTL_IOCTL_WPA_SUPPLICANT) {
+		ret = -EOPNOTSUPP;
+		goto kfree;
+	}
+
+	/* parse here for HW security */
+	if (ipw->cmd != IEEE_CMD_SET_ENCRYPTION)
+		goto ret;
+
+	if (ipw->u.crypt.set_tx) {
+		if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
+			ieee->pairwise_key_type = KEY_TYPE_CCMP;
+		} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
+			ieee->pairwise_key_type = KEY_TYPE_TKIP;
+		} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
+			if (ipw->u.crypt.key_len == 13)
+				ieee->pairwise_key_type = KEY_TYPE_WEP104;
+			else if (ipw->u.crypt.key_len == 5)
+				ieee->pairwise_key_type = KEY_TYPE_WEP40;
+		} else {
+			ieee->pairwise_key_type = KEY_TYPE_NA;
 		}
-		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
-						     &wrq->u.data);
-		break;
 
-	default:
-		ret = -EOPNOTSUPP;
-		break;
+		if (ieee->pairwise_key_type) {
+			memcpy((u8 *)key, ipw->u.crypt.key, 16);
+			EnableHWSecurityConfig8192(dev);
+			/* We fill both index entry and 4th
+			 * entry for pairwise key as in IPW
+			 * interface, adhoc will only get here,
+			 * so we need index entry for its
+			 * default key serching!
+			 */
+			setKey(dev, 4, ipw->u.crypt.idx,
+			       ieee->pairwise_key_type,
+			       (u8 *)ieee->ap_mac_addr, 0, key);
+			if (ieee->auth_mode != 2)
+				setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx,
+				       ieee->pairwise_key_type,
+				       (u8 *)ieee->ap_mac_addr, 0, key);
+		}
+	} else {
+		memcpy((u8 *)key, ipw->u.crypt.key, 16);
+		if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) {
+			ieee->group_key_type = KEY_TYPE_CCMP;
+		} else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) {
+			ieee->group_key_type = KEY_TYPE_TKIP;
+		} else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
+			if (ipw->u.crypt.key_len == 13)
+				ieee->group_key_type = KEY_TYPE_WEP104;
+			else if (ipw->u.crypt.key_len == 5)
+				ieee->group_key_type = KEY_TYPE_WEP40;
+		} else {
+			ieee->group_key_type = KEY_TYPE_NA;
+		}
+
+		if (ieee->group_key_type) {
+			setKey(dev, ipw->u.crypt.idx,
+			       ipw->u.crypt.idx, /* KeyIndex */
+			       ieee->group_key_type, /* KeyType */
+			       broadcast_addr, /* MacAddr */
+			       0, /* DefaultKey */
+			       key); /* KeyContent */
+
+		}
 	}
+
+ret:
+	ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211,
+					     &wrq->u.data);
+
+kfree:
 	kfree(ipw);
 	ipw = NULL;
 out:
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {}
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (29 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  2015-09-20 17:14 ` [PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Cristina Opriceana, devel, linux-kernel

An else block only contained an if statement. Replace that else
block by an else if block instead.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 171a494..7e04259 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4513,15 +4513,13 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 		pstats->SignalStrength =
 			precord_stats->SignalStrength =
 			(u8)(rtl819x_signal_scale_mapping((long)pwdb_all));
-	} else {
+	} else if (rf_rx_num != 0) {
 		/* We can judge RX path number now. */
-		if (rf_rx_num != 0) {
-			long currsig = (total_rssi /= rf_rx_num);
+		long currsig = (total_rssi /= rf_rx_num);
 
-			pstats->SignalStrength =
-				precord_stats->SignalStrength =
-				(u8)(rtl819x_signal_scale_mapping(currsig));
-		}
+		pstats->SignalStrength =
+			precord_stats->SignalStrength =
+			(u8)(rtl819x_signal_scale_mapping(currsig));
 	}
 }	/* QueryRxPhyStatus8190Pci */
 
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST
  2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
                   ` (30 preceding siblings ...)
  2015-09-20 17:14 ` [PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte
@ 2015-09-20 17:14 ` Raphaël Beamonte
  31 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-20 17:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Raphaël Beamonte, Paul Gortmaker, Cristina Opriceana,
	Andy Shevchenko, Andrew Morton, Joe Perches, Marti Bolivar,
	Shraddha Barke, Luis de Bethencourt, Arnd Bergmann,
	Ksenija Stanojevic, Navya Sri Nizamkari, Greg Donald,
	Haneen Mohammed, Aya Mahfouz, Rene Kolarik, Somya Anand,
	Vaishali Thakkar, Hatice ERTÜRK, Melike Yurtoglu, devel,
	linux-kernel

The symbol TO_DO_LIST was used in the code to frame sections
of code unused or unusable. This patch remove all code framed
by that symbol in this driver.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h     |   4 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |  23 -----
 .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c    |   4 -
 .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c    |   5 +-
 drivers/staging/rtl8192u/r8192U_core.c             | 102 ++-------------------
 drivers/staging/rtl8192u/r819xU_phy.c              |  57 ------------
 6 files changed, 9 insertions(+), 186 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index d481a26..28ba7d2 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -1654,10 +1654,10 @@ struct ieee80211_device {
 	struct list_head		Rx_TS_Pending_List;
 	struct list_head		Rx_TS_Unused_List;
 	RX_TS_RECORD		RxTsRecord[TOTAL_TS_NUM];
-//#ifdef TO_DO_LIST
+	
 	RX_REORDER_ENTRY	RxReorderEntry[128];
 	struct list_head		RxReorder_Unused_List;
-//#endif
+	
 	// Qos related. Added by Annie, 2005-11-01.
 //	PSTA_QOS			pStaQos;
 	u8				ForcedPriority;		// Force per-packet priority 1~7. (default: 0, not to force it.)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 1ab0aea..36a7acc 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -318,13 +318,6 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee,
 	if (is_multicast_ether_addr(hdr->addr1))
 		return;
 	//check packet and mode later
-#ifdef TO_DO_LIST
-	if(pTcb->PacketLength >= 4096)
-		return;
-	// For RTL819X, if pairwisekey = wep/tkip, we don't aggrregation.
-	if(!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter))
-		return;
-#endif
 	if(!ieee->GetNmodeSupportBySecCfg(ieee->dev))
 	{
 		return;
@@ -550,22 +543,6 @@ NO_PROTECTION:
 static void ieee80211_txrate_selectmode(struct ieee80211_device *ieee,
 					cb_desc *tcb_desc)
 {
-#ifdef TO_DO_LIST
-	if(!IsDataFrame(pFrame))
-	{
-		pTcb->bTxDisableRateFallBack = true;
-		pTcb->bTxUseDriverAssingedRate = true;
-		pTcb->RATRIndex = 7;
-		return;
-	}
-
-	if(pMgntInfo->ForcedDataRate!= 0)
-	{
-		pTcb->bTxDisableRateFallBack = true;
-		pTcb->bTxUseDriverAssingedRate = true;
-		return;
-	}
-#endif
 	if(ieee->bTxDisableRateFallBack)
 		tcb_desc->bTxDisableRateFallBack = true;
 
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
index c27397b..87b1bb9 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
@@ -88,10 +88,6 @@ void HTUpdateDefaultSetting(struct ieee80211_device *ieee)
 	ieee->bTxDisableRateFallBack = 0;
 	ieee->bTxUseDriverAssingedRate = 0;
 
-#ifdef	TO_DO_LIST
-	// 8190 only. Assign duration operation mode to firmware
-	pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
-#endif
 	// 8190 only, Realtek proprietary aggregation mode
 	// Set MPDUDensity=2,   1: Set MPDUDensity=2(32k)  for Realtek AP and set MPDUDensity=0(8k) for others
 	pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2,   1: Set MPDUDensity=2(32k)  for Realtek AP and set MPDUDensity=0(8k) for others
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index f33c743..fb493a2 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -193,7 +193,7 @@ void TSInitialize(struct ieee80211_device *ieee)
 	}
 	// Initialize unused Rx Reorder List.
 	INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
-//#ifdef TO_DO_LIST
+
 	for(count = 0; count < REORDER_ENTRY_NUM; count++)
 	{
 		list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
@@ -201,7 +201,6 @@ void TSInitialize(struct ieee80211_device *ieee)
 			break;
 		pRxReorderEntry = &ieee->RxReorderEntry[count+1];
 	}
-//#endif
 
 }
 
@@ -461,7 +460,6 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs,
 
 	if(TxRxSelect == RX_DIR)
 	{
-//#ifdef TO_DO_LIST
 		PRX_REORDER_ENTRY	pRxReorderEntry;
 		PRX_TS_RECORD		pRxTS = (PRX_TS_RECORD)pTs;
 		if(timer_pending(&pRxTS->RxPktPendingTimer))
@@ -493,7 +491,6 @@ static void RemoveTsEntry(struct ieee80211_device *ieee, PTS_COMMON_INFO pTs,
 			spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
 		}
 
-//#endif
 	}
 	else
 	{
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 7e04259..0ab371b 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2167,14 +2167,7 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 			wireless_mode = WIRELESS_MODE_B;
 		}
 	}
-#ifdef TO_DO_LIST
-	/* TODO: this function doesn't work well at this time,
-	 * we should wait for FPGA
-	 */
-	ActUpdateChannelAccessSetting(
-			pAdapter, pHalData->CurrentWirelessMode,
-			&pAdapter->MgntInfo.Info8185.ChannelAccessSetting);
-#endif
+
 	priv->ieee80211->mode = wireless_mode;
 
 	if (wireless_mode == WIRELESS_MODE_N_24G ||
@@ -2250,12 +2243,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 
 	priv->ieee80211->InitialGainHandler = InitialGain819xUsb;
 	priv->card_type = USB;
-#ifdef TO_DO_LIST
-	if (Adapter->bInHctTest) {
-		pHalData->ShortRetryLimit = 7;
-		pHalData->LongRetryLimit = 7;
-	}
-#endif
+
 	priv->ShortRetryLimit = 0x30;
 	priv->LongRetryLimit = 0x30;
 	priv->EarlyRxThreshold = 7;
@@ -2271,34 +2259,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 		 * TRUE: SW provides them
 		 */
 		(false ? TCR_SAT : 0);
-#ifdef TO_DO_LIST
-	if (Adapter->bInHctTest)
-		pHalData->ReceiveConfig =
-			pHalData->CSMethod |
-			/* accept management/data */
-			RCR_AMF | RCR_ADF |
-			/* accept control frame for SW
-			 * AP needs PS-poll
-			 */
-			RCR_ACF |
-			/* accept BC/MC/UC */
-			RCR_AB | RCR_AM | RCR_APM |
-			/* accept ICV/CRC error
-			 * packet
-			 */
-			RCR_AICV | RCR_ACRC32 |
-			/* Max DMA Burst Size per Tx
-			 * DMA Burst, 7: unlimited.
-			 */
-			((u32)7 << RCR_MXDMA_OFFSET) |
-			/* Rx FIFO Threshold,
-			 * 7: No Rx threshold.
-			 */
-			(pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) |
-			(pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0);
-	else
 
-#endif
 	priv->ReceiveConfig	=
 		/* accept management/data */
 		RCR_AMF | RCR_ADF |
@@ -2758,19 +2719,10 @@ static void rtl8192_hwconfig(struct net_device *dev)
 		regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		break;
 	case WIRELESS_MODE_AUTO:
-#ifdef TO_DO_LIST
-		if (Adapter->bInHctTest) {
-			regBwOpMode = BW_OPMODE_20MHZ;
-			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
-			regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
-		} else
-#endif
-		{
-			regBwOpMode = BW_OPMODE_20MHZ;
-			regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
-				  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
-			regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
-		}
+		regBwOpMode = BW_OPMODE_20MHZ;
+		regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
+			  RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
+		regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
 		break;
 	case WIRELESS_MODE_N_24G:
 		/* It support CCK rate by default. CCK rate will be filtered
@@ -2944,48 +2896,6 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 	}
 	RT_TRACE(COMP_INIT, "%s():after firmware download\n", __func__);
 
-#ifdef TO_DO_LIST
-	if (Adapter->ResetProgress == RESET_TYPE_NORESET) {
-		if (pMgntInfo->RegRfOff) { /* User disable RF via registry. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
-				 ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
-			MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
-			/* Those actions will be discard in MgntActSet_RF_State
-			 * because of the same state
-			 */
-			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter,
-					     (RF90_RADIO_PATH_E)eRFPath,
-					     0x4, 0xC00, 0x0);
-		} else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) {
-			/* H/W or S/W RF OFF before sleep. */
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
-				 ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n",
-				  pMgntInfo->RfOffReason));
-			MgntActSet_RF_State(Adapter,
-					    eRfOff,
-					    pMgntInfo->RfOffReason);
-		} else {
-			pHalData->eRFPowerState = eRfOn;
-			pMgntInfo->RfOffReason = 0;
-			RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD,
-				 ("InitializeAdapter819xUsb(): RF is on ----------\n"));
-		}
-	} else {
-		if (pHalData->eRFPowerState == eRfOff) {
-			MgntActSet_RF_State(Adapter,
-					    eRfOff,
-					    pMgntInfo->RfOffReason);
-			/* Those actions will be discard in MgntActSet_RF_State
-			 * because of the same state
-			 */
-			for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++)
-				PHY_SetRFReg(Adapter,
-					     (RF90_RADIO_PATH_E)eRFPath,
-					     0x4, 0xC00, 0x0);
-		}
-	}
-#endif
 	/* config RF. */
 	if (priv->ResetProgress == RESET_TYPE_NORESET) {
 		rtl8192_phy_RFConfig(dev);
diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c
index e5dbaca..55c3577 100644
--- a/drivers/staging/rtl8192u/r819xU_phy.c
+++ b/drivers/staging/rtl8192u/r819xU_phy.c
@@ -523,16 +523,6 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType)
 {
 	u32 i;
 
-#ifdef TO_DO_LIST
-	u32 *rtl8192PhyRegArrayTable = NULL, *rtl8192AgcTabArrayTable = NULL;
-
-	if (Adapter->bInHctTest) {
-		PHY_REGArrayLen = PHY_REGArrayLengthDTM;
-		AGCTAB_ArrayLen = AGCTAB_ArrayLengthDTM;
-		Rtl8190PHY_REGArray_Table = Rtl819XPHY_REGArrayDTM;
-		Rtl8190AGCTAB_Array_Table = Rtl819XAGCTAB_ArrayDTM;
-	}
-#endif
 	if (ConfigType == BaseBand_Config_PHY_REG) {
 		for (i = 0; i < PHY_REG_1T2RArrayLength; i += 2) {
 			rtl8192_setBBreg(dev, rtl819XPHY_REG_1T2RArray[i],
@@ -1063,10 +1053,6 @@ static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
 
 	switch (priv->rf_chip) {
 	case RF_8225:
-#ifdef TO_DO_LIST
-		PHY_SetRF8225CckTxPower(Adapter, powerlevel);
-		PHY_SetRF8225OfdmTxPower(Adapter, powerlevelOFDM24G);
-#endif
 		break;
 
 	case RF_8256:
@@ -1164,47 +1150,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev,
 		RT_TRACE(COMP_ERR, "Not support rf_chip(%x)\n", priv->rf_chip);
 		break;
 	}
-#ifdef TO_DO_LIST
-	if (bResult) {
-		/* Update current RF state variable. */
-		pHalData->eRFPowerState = eRFPowerState;
-		switch (pHalData->RFChipID) {
-		case RF_8256:
-			switch (pHalData->eRFPowerState) {
-			case eRfOff:
-				/* If Rf off reason is from IPS,
-				   LED should blink with no link */
-				if (pMgntInfo->RfOffReason == RF_CHANGE_BY_IPS)
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK);
-				else
-					/* Turn off LED if RF is not ON. */
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF);
-				break;
-
-			case eRfOn:
-				/* Turn on RF we are still linked, which might
-				   happen when we quickly turn off and on HW RF.
-				 */
-				if (pMgntInfo->bMediaConnect)
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK);
-				else
-					/* Turn off LED if RF is not ON. */
-					Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK);
-				break;
-
-			default:
-				break;
-			}
-			break;
-
-		default:
-			RT_TRACE(COMP_RF, DBG_LOUD, "%s(): Unknown RF type\n",
-				 __func__);
-			break;
-		}
 
-	}
-#endif
 	priv->SetRFPowerStateInProgress = false;
 
 	return bResult;
@@ -1629,9 +1575,6 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
 	/* <3> Set RF related register */
 	switch (priv->rf_chip) {
 	case RF_8225:
-#ifdef TO_DO_LIST
-		PHY_SetRF8225Bandwidth(Adapter, pHalData->CurrentChannelBW);
-#endif
 		break;
 
 	case RF_8256:
-- 
2.5.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-20 17:14 ` [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
@ 2015-09-21  2:16   ` Greg Kroah-Hartman
  2015-09-21 16:31     ` Raphaël Beamonte
  0 siblings, 1 reply; 40+ messages in thread
From: Greg Kroah-Hartman @ 2015-09-21  2:16 UTC (permalink / raw)
  To: Raphaël Beamonte; +Cc: Cristina Opriceana, devel, linux-kernel

On Sun, Sep 20, 2015 at 01:14:14PM -0400, Raphaël Beamonte wrote:
> Add some temporary variables to reduce line length under the maximum
> of 80 characters, as per the kernel code style.
> 
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
>  1 file changed, 94 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 28b54ba..2abc3e77 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -171,6 +171,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>  {
>  	int i, max_chan = -1, min_chan = -1;
>  	struct ieee80211_device *ieee = priv->ieee80211;
> +	struct CHANNEL_LIST cl;

A whole structure on the stack?  Are you sure you want to do that?

>  
>  	switch (channel_plan) {
>  	case COUNTRY_CODE_FCC:
> @@ -194,15 +195,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>  				 "unknown rf chip, can't set channel map in function:%s()\n",
>  				 __func__);
>  		}
> -		if (ChannelPlan[channel_plan].Len != 0) {
> +		cl = ChannelPlan[channel_plan];

You just did a memory copy of a whole structure, did you really want to
do that?  If so, why?  You just changed the logic of this function,
potentially slowing things down and setting yourself up for causing real
bugs (hint, anything you now change in that structure is not going to be
ever saved, it will go away after the function is exited.)

Please be more aware of how structures and pointers work in C before
doing changes like this, I can't take this change.

> +		if (cl.Len != 0) {
>  			/* Clear old channel map */
>  			memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
>  			       sizeof(GET_DOT11D_INFO(ieee)->channel_map));
>  			/* Set new channel map */
> -			for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
> -				if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
> +			for (i = 0; i < cl.Len; i++) {
> +				u8 chan = cl.Channel[i];
> +
> +				if (chan < min_chan || chan > max_chan)
>  					break;
> -				GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
> +				GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
>  			}
>  		}
>  		break;
> @@ -1649,9 +1653,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>  					  &zero, 0, tx_zero_isr, dev);
>  			status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
>  			if (status) {
> +				atomic_t tx =
> +					priv->tx_pending[tcb_desc->queue_index];

Oh that's funny, think about what you just did here.

Please get some more experience with C before doing kernel development.
C is tricky and will let you shoot yourself in the foot and any other
body part if you are not _VERY_ careful.  You just blew off a few limbs
without realizing it at all in just the first two changes you made.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters
  2015-09-21  2:16   ` Greg Kroah-Hartman
@ 2015-09-21 16:31     ` Raphaël Beamonte
  0 siblings, 0 replies; 40+ messages in thread
From: Raphaël Beamonte @ 2015-09-21 16:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Cristina Opriceana, devel, lkml

2015-09-20 22:16 GMT-04:00 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
> On Sun, Sep 20, 2015 at 01:14:14PM -0400, Raphaël Beamonte wrote:
>> Add some temporary variables to reduce line length under the maximum
>> of 80 characters, as per the kernel code style.
>>
>> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
>> ---
>>  drivers/staging/rtl8192u/r8192U_core.c | 139 ++++++++++++++++++++++-----------
>>  1 file changed, 94 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
>> index 28b54ba..2abc3e77 100644
>> --- a/drivers/staging/rtl8192u/r8192U_core.c
>> +++ b/drivers/staging/rtl8192u/r8192U_core.c
>> @@ -171,6 +171,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>>  {
>>       int i, max_chan = -1, min_chan = -1;
>>       struct ieee80211_device *ieee = priv->ieee80211;
>> +     struct CHANNEL_LIST cl;
>
> A whole structure on the stack?  Are you sure you want to do that?

Nope. I don't want to. I don't know what I was thinking, or if even I
was. Sorry for that, should have been a pointer.

>>
>>       switch (channel_plan) {
>>       case COUNTRY_CODE_FCC:
>> @@ -194,15 +195,18 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv)
>>                                "unknown rf chip, can't set channel map in function:%s()\n",
>>                                __func__);
>>               }
>> -             if (ChannelPlan[channel_plan].Len != 0) {
>> +             cl = ChannelPlan[channel_plan];
>
> You just did a memory copy of a whole structure, did you really want to
> do that?  If so, why?  You just changed the logic of this function,
> potentially slowing things down and setting yourself up for causing real
> bugs (hint, anything you now change in that structure is not going to be
> ever saved, it will go away after the function is exited.)

You're right. Should have been a pointer. Sorry again, that wasn't the
intention.

> Please be more aware of how structures and pointers work in C before
> doing changes like this, I can't take this change.
>
>> +             if (cl.Len != 0) {
>>                       /* Clear old channel map */
>>                       memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
>>                              sizeof(GET_DOT11D_INFO(ieee)->channel_map));
>>                       /* Set new channel map */
>> -                     for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
>> -                             if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
>> +                     for (i = 0; i < cl.Len; i++) {
>> +                             u8 chan = cl.Channel[i];
>> +
>> +                             if (chan < min_chan || chan > max_chan)
>>                                       break;
>> -                             GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
>> +                             GET_DOT11D_INFO(ieee)->channel_map[chan] = 1;
>>                       }
>>               }
>>               break;
>> @@ -1649,9 +1653,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
>>                                         &zero, 0, tx_zero_isr, dev);
>>                       status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
>>                       if (status) {
>> +                             atomic_t tx =
>> +                                     priv->tx_pending[tcb_desc->queue_index];
>
> Oh that's funny, think about what you just did here.

Also should have been a pointer. I'll do a more thorough recheck of
that patch before re-sending it. Thanks for your review and your time!

> Please get some more experience with C before doing kernel development.
> C is tricky and will let you shoot yourself in the foot and any other
> body part if you are not _VERY_ careful.  You just blew off a few limbs
> without realizing it at all in just the first two changes you made.
>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2015-09-21 16:31 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-11  7:29 [PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks to keep lines under " Raphaël Beamonte
2015-09-17  4:55   ` Greg Kroah-Hartman
2015-09-11  7:29 ` [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
2015-09-17  4:57   ` Greg Kroah-Hartman
2015-09-17  5:06     ` Raphaël Beamonte
2015-09-17  5:18       ` Greg Kroah-Hartman
2015-09-17 18:26         ` Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get " Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: " Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 09/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 14/16] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte
2015-09-11  7:29 ` [PATCHv2 16/16] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 00/15] staging: rtl8192u: code clean up Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 01/15] staging: rtl8192u: r8192U_core: add line breaks to keep lines under 80 characters Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables " Raphaël Beamonte
2015-09-21  2:16   ` Greg Kroah-Hartman
2015-09-21 16:31     ` Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get " Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: " Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 12/15] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte
2015-09-20 17:14 ` [PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).