[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <d86d642d29959bae2e07770a9b31b14700fbbd67.1441955761.git.raphael.beamonte@gmail.com>
Date: Fri, 11 Sep 2015 03:29:20 -0400
From: Raphaël Beamonte <raphael.beamonte@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Dan Carpenter <dan.carpenter@...cle.com>,
Raphaël Beamonte <raphael.beamonte@...il.com>,
Cristina Opriceana <cristina.opriceana@...il.com>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCHv2 12/16] 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 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
--
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