lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <bc49972ede849bceee1dbade11278641393e2c9e.1442769012.git.raphael.beamonte@gmail.com>
Date:	Sun, 20 Sep 2015 13:14:23 -0400
From:	Raphaël Beamonte <raphael.beamonte@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	Raphaël Beamonte <raphael.beamonte@...il.com>,
	Cristina Opriceana <cristina.opriceana@...il.com>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCHv3 11/15] staging: rtl8192u: r8192U_core: rtl8192_process_phyinfo: reorganize function

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

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ