[PATCH v2 20/21] staging: rtl8192e: Fix LONG_LINE in simplify rtl8192_process_phyinfo()

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

 



Simplify function to make checkpatch.pl happy. Changes:
- Helper variables used
- Conditions were rephrased to return quickly (and decrease indent).

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx>
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 111 ++++++++++++-------------
 1 file changed, 53 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 2f21bdc..96938d7 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -1701,6 +1701,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 	struct rtllib_hdr_3addr *hdr;
 	u16 sc;
 	unsigned int frag, seq;
+	struct rt_stats *stats = &priv->stats;
 
 	hdr = (struct rtllib_hdr_3addr *)buffer;
 	sc = le16_to_cpu(hdr->seq_ctl);
@@ -1712,20 +1713,20 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
 		slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX;
-		last_rssi = priv->stats.slide_signal_strength[slide_rssi_index];
-		priv->stats.slide_rssi_total -= last_rssi;
+		last_rssi = stats->slide_signal_strength[slide_rssi_index];
+		stats->slide_rssi_total -= last_rssi;
 	}
-	priv->stats.slide_rssi_total += prev_st->SignalStrength;
+	stats->slide_rssi_total += prev_st->SignalStrength;
 
-	priv->stats.slide_signal_strength[slide_rssi_index++] =
-					 prev_st->SignalStrength;
+	stats->slide_signal_strength[slide_rssi_index++] =
+			prev_st->SignalStrength;
 	if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
 		slide_rssi_index = 0;
 
-	tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics;
-	priv->stats.signal_strength = rtl819x_translate_todbm(priv,
+	tmp_val = stats->slide_rssi_total/slide_rssi_statistics;
+	stats->signal_strength = rtl819x_translate_todbm(priv,
 				      (u8)tmp_val);
-	curr_st->rssi = priv->stats.signal_strength;
+	curr_st->rssi = stats->signal_strength;
 	if (!prev_st->bPacketMatchBSSID) {
 		if (!prev_st->bToSelfBA)
 			return;
@@ -1736,7 +1737,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 
 	rtl819x_process_cck_rxpathsel(priv, prev_st);
 
-	priv->stats.num_process_phyinfo++;
+	stats->num_process_phyinfo++;
 	if (!prev_st->bIsCCK && prev_st->bPacketToSelf) {
 		for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) {
 			if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev,
@@ -1745,30 +1746,30 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 			RT_TRACE(COMP_DBG,
 				 "Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath]  = %d\n",
 				 prev_st->RxMIMOSignalStrength[rfpath]);
-			if (priv->stats.rx_rssi_percentage[rfpath] == 0) {
-				priv->stats.rx_rssi_percentage[rfpath] =
+			if (stats->rx_rssi_percentage[rfpath] == 0) {
+				stats->rx_rssi_percentage[rfpath] =
 					 prev_st->RxMIMOSignalStrength[rfpath];
 			}
 			if (prev_st->RxMIMOSignalStrength[rfpath]  >
-			    priv->stats.rx_rssi_percentage[rfpath]) {
-				priv->stats.rx_rssi_percentage[rfpath] =
-					((priv->stats.rx_rssi_percentage[rfpath]
+			    stats->rx_rssi_percentage[rfpath]) {
+				stats->rx_rssi_percentage[rfpath] =
+					((stats->rx_rssi_percentage[rfpath]
 					* (RX_SMOOTH - 1)) +
 					(prev_st->RxMIMOSignalStrength
 					[rfpath])) / (RX_SMOOTH);
-				priv->stats.rx_rssi_percentage[rfpath] =
-					 priv->stats.rx_rssi_percentage[rfpath]
+				stats->rx_rssi_percentage[rfpath] =
+					 stats->rx_rssi_percentage[rfpath]
 					 + 1;
 			} else {
-				priv->stats.rx_rssi_percentage[rfpath] =
-				   ((priv->stats.rx_rssi_percentage[rfpath] *
+				stats->rx_rssi_percentage[rfpath] =
+				   ((stats->rx_rssi_percentage[rfpath] *
 				   (RX_SMOOTH-1)) +
 				   (prev_st->RxMIMOSignalStrength[rfpath])) /
 				   (RX_SMOOTH);
 			}
 			RT_TRACE(COMP_DBG,
 				 "Jacken -> priv->RxStats.RxRSSIPercentage[rfPath]  = %d\n",
-				 priv->stats.rx_rssi_percentage[rfpath]);
+				 stats->rx_rssi_percentage[rfpath]);
 		}
 	}
 
@@ -1778,17 +1779,17 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		    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
+			last_beacon_adc_pwdb = stats->Slide_Beacon_pwdb
 					       [slide_beacon_adc_pwdb_index];
-			priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
+			stats->Slide_Beacon_Total -= last_beacon_adc_pwdb;
 		}
-		priv->stats.Slide_Beacon_Total += prev_st->RxPWDBAll;
-		priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] =
+		stats->Slide_Beacon_Total += prev_st->RxPWDBAll;
+		stats->Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] =
 							 prev_st->RxPWDBAll;
 		slide_beacon_adc_pwdb_index++;
 		if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
 			slide_beacon_adc_pwdb_index = 0;
-		prev_st->RxPWDBAll = priv->stats.Slide_Beacon_Total /
+		prev_st->RxPWDBAll = stats->Slide_Beacon_Total /
 				     slide_beacon_adc_pwdb_statistics;
 		if (prev_st->RxPWDBAll >= 3)
 			prev_st->RxPWDBAll -= 3;
@@ -1818,46 +1819,40 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
 		rtl819x_update_rxsignalstatistics8190pci(priv, prev_st);
 	}
 
-	if (prev_st->SignalQuality != 0) {
-		if (prev_st->bPacketToSelf || prev_st->bPacketBeacon ||
-		    prev_st->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_st->SignalQuality == 0)
+		return;
 
-			priv->stats.slide_evm_total += prev_st->SignalQuality;
+	if (!(prev_st->bPacketToSelf || prev_st->bPacketBeacon ||
+	      prev_st->bToSelfBA))
+		return;
 
-			priv->stats.slide_evm[slide_evm_index++] =
-						 prev_st->SignalQuality;
-			if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
-				slide_evm_index = 0;
+	if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) {
+		slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
+		last_evm = stats->slide_evm[slide_evm_index];
+		stats->slide_evm_total -= last_evm;
+	}
 
-			tmp_val = priv->stats.slide_evm_total /
-				  slide_evm_statistics;
-			priv->stats.signal_quality = tmp_val;
-			priv->stats.last_signal_strength_inpercent = tmp_val;
-		}
+	stats->slide_evm_total += prev_st->SignalQuality;
 
-		if (prev_st->bPacketToSelf ||
-		    prev_st->bPacketBeacon ||
-		    prev_st->bToSelfBA) {
-			for (ij = 0; ij < 2; ij++) {
-				if (prev_st->RxMIMOSignalQuality[ij] != -1) {
-					if (priv->stats.rx_evm_percentage[ij] == 0)
-						priv->stats.rx_evm_percentage[ij] =
-						   prev_st->RxMIMOSignalQuality[ij];
-					priv->stats.rx_evm_percentage[ij] =
-					  ((priv->stats.rx_evm_percentage[ij] *
-					  (RX_SMOOTH - 1)) +
-					  (prev_st->RxMIMOSignalQuality[ij])) /
-					  (RX_SMOOTH);
-				}
-			}
+	stats->slide_evm[slide_evm_index++] = prev_st->SignalQuality;
+	if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
+		slide_evm_index = 0;
+
+	tmp_val = stats->slide_evm_total / slide_evm_statistics;
+	stats->signal_quality = tmp_val;
+	stats->last_signal_strength_inpercent = tmp_val;
+	for (ij = 0; ij < 2; ij++) {
+		u8 *evm = stats->rx_evm_percentage;
+
+		if (prev_st->RxMIMOSignalQuality[ij] != -1) {
+			if (evm[ij] == 0)
+				evm[ij] = prev_st->RxMIMOSignalQuality[ij];
+			evm[ij] = ((evm[ij] * (RX_SMOOTH - 1)) +
+				   (prev_st->RxMIMOSignalQuality[ij])) /
+				  (RX_SMOOTH);
 		}
 	}
+
 }
 
 static void rtl8192_TranslateRxSignalStuff(struct net_device *dev,
-- 
1.8.4.1

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




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