Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1228914

[PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function

From Raphaël Beamonte <raphael.beamonte@gmail.com>
Newsgroups linux.kernel
Subject [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function
Date 2015-09-20 19:20 +0200
Message-ID <qaQro-6fo-25@gated-at.bofh.it> (permalink)
References <qaQrn-6fo-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv2 00/16] staging: rtl8192u: code clean up Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 01/16] staging: rtl8192u: r8192U_core: fix comments lines over 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 10/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 11/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 15/16] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 07/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 06/16] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 13/16] staging: rtl8192u: r8192U_core: rtl8192_tx: replace some inline conditions Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
    Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:00 +0200
      Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-17 07:10 +0200
        Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:20 +0200
          Re: [PATCHv2 03/16] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-17 20:30 +0200
  [PATCHv2 12/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 08/16] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 05/16] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  [PATCHv2 04/16] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-11 09:40 +0200
  Re: [PATCHv2 02/16] staging: rtl8192u: r8192U_core: add line breaks  to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-17 07:00 +0200
  [PATCHv3 00/15] staging: rtl8192u: code clean up Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 06/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable pprevious_stats to prev_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 04/15] staging: rtl8192u: r8192U_core: rtl8192_adapter_start: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 13/15] staging: rtl8192u: r8192U_core: rtl8192_ioctl: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 05/15] staging: rtl8192u: r8192U_core: rtl8192_read_eeprom_info: reorganize function Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 10/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable rfpath to rfp Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 07/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_index to sb_index Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 14/15] staging: rtl8192u: r8192U_core: replace else { if() {} } by else if () {} Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 15/15] staging: rtl8192u: remove all code framed by symbol TO_DO_LIST Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:20 +0200
    [PATCHv3 09/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: remove unneeded variable Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
    [PATCHv3 08/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: rename variable slide_beacon_adc_pwdb_statistics to sb_stats Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
    [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200
      Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-09-21 06:40 +0200
        Re: [PATCHv3 02/15] staging: rtl8192u: r8192U_core: add temporary  variables to keep lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-21 18:40 +0200
    [PATCHv3 03/15] staging: rtl8192u: r8192U_core: reverse conditions to get lines under 80 characters Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-20 19:30 +0200

csiph-web