[PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function

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

 



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

Signed-off-by: Raphaël Beamonte <raphael.beamonte@xxxxxxxxx>
---
 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

_______________________________________________
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