2015-03-11 20:03:46

by Priit Laes

[permalink] [raw]
Subject: [PATCH 0/6] rtlwifi: Use common functions for driver stats

Hi all,

This is a small fixup to unify make the drivers use common helper
functions for driver statistics.

Priit Laes (6):
rtlwifi: Use common rtl_query_rxpwrpercentage function
rtlwifi: Clean rtl_evm_db_to_percentage a bit
rtlwifi: Use common rtl_evm_db_to_percentage
rtlwifi: No need to export rtl_evm_dbm_jaguar anymore
rtlwifi: Use common rtl_signal_scale_mapping
rtlwifi: Rename rtl_translate_todbm to rtl_signalpower_todbm

drivers/net/wireless/rtlwifi/rtl8188ee/trx.c | 8 ++--
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 70 ++--------------------------
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 67 +++-----------------------
drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 68 ++++-----------------------
drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 8 ++--
drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 8 ++--
drivers/net/wireless/rtlwifi/rtl8723ae/trx.c | 8 ++--
drivers/net/wireless/rtlwifi/rtl8723be/trx.c | 8 ++--
drivers/net/wireless/rtlwifi/rtl8821ae/trx.c | 24 ++++++++--
drivers/net/wireless/rtlwifi/stats.c | 48 ++++---------------
drivers/net/wireless/rtlwifi/stats.h | 3 +-
11 files changed, 69 insertions(+), 251 deletions(-)

--
2.3.1



2015-03-11 20:03:48

by Priit Laes

[permalink] [raw]
Subject: [PATCH 2/6] rtlwifi: Clean rtl_evm_db_to_percentage a bit

Signed-off-by: Priit Laes <[email protected]>
---
drivers/net/wireless/rtlwifi/stats.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
index 874e7d1..2021223 100644
--- a/drivers/net/wireless/rtlwifi/stats.c
+++ b/drivers/net/wireless/rtlwifi/stats.c
@@ -39,15 +39,8 @@ EXPORT_SYMBOL(rtl_query_rxpwrpercentage);

u8 rtl_evm_db_to_percentage(char value)
{
- char ret_val;
- ret_val = value;
-
- if (ret_val >= 0)
- ret_val = 0;
- if (ret_val <= -33)
- ret_val = -33;
- ret_val = 0 - ret_val;
- ret_val *= 3;
+ char ret_val = clamp(-value, 0, 33) * 3;
+
if (ret_val == 99)
ret_val = 100;

--
2.3.1


2015-03-11 20:03:49

by Priit Laes

[permalink] [raw]
Subject: [PATCH 3/6] rtlwifi: Use common rtl_evm_db_to_percentage

Signed-off-by: Priit Laes <[email protected]>
---
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 22 +---------------------
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 18 +-----------------
drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 17 +----------------
3 files changed, 3 insertions(+), 54 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 4eedf39..4c7e804 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -49,26 +49,6 @@ static u8 _rtl92ce_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
return skb->priority;
}

-static u8 _rtl92c_evm_db_to_percentage(char value)
-{
- char ret_val;
- ret_val = value;
-
- if (ret_val >= 0)
- ret_val = 0;
-
- if (ret_val <= -33)
- ret_val = -33;
-
- ret_val = 0 - ret_val;
- ret_val *= 3;
-
- if (ret_val == 99)
- ret_val = 100;
-
- return ret_val;
-}
-
static long _rtl92ce_signal_scale_mapping(struct ieee80211_hw *hw,
long currsig)
{
@@ -254,7 +234,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
max_spatial_stream = 1;

for (i = 0; i < max_spatial_stream; i++) {
- evm = _rtl92c_evm_db_to_percentage(p_drvinfo->rxevm[i]);
+ evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]);

if (packet_match_bssid) {
/* Fill value in RFD, Get the first
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index f55b35c..60f2001 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -714,22 +714,6 @@ void rtl92c_set_data_filter(struct ieee80211_hw *hw, u16 filter)
}
/*==============================================================*/

-static u8 _rtl92c_evm_db_to_percentage(char value)
-{
- char ret_val;
-
- ret_val = value;
- if (ret_val >= 0)
- ret_val = 0;
- if (ret_val <= -33)
- ret_val = -33;
- ret_val = 0 - ret_val;
- ret_val *= 3;
- if (ret_val == 99)
- ret_val = 100;
- return ret_val;
-}
-
static long _rtl92c_signal_scale_mapping(struct ieee80211_hw *hw,
long currsig)
{
@@ -876,7 +860,7 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
else
max_spatial_stream = 1;
for (i = 0; i < max_spatial_stream; i++) {
- evm = _rtl92c_evm_db_to_percentage(p_drvinfo->rxevm[i]);
+ evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]);
if (packet_match_bssid) {
if (i == 0)
pstats->signalquality =
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index 54736dd..369edd4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -48,21 +48,6 @@ static u8 _rtl92de_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
return skb->priority;
}

-static u8 _rtl92d_evm_db_to_percentage(char value)
-{
- char ret_val = value;
-
- if (ret_val >= 0)
- ret_val = 0;
- if (ret_val <= -33)
- ret_val = -33;
- ret_val = 0 - ret_val;
- ret_val *= 3;
- if (ret_val == 99)
- ret_val = 100;
- return ret_val;
-}
-
static long _rtl92de_translate_todbm(struct ieee80211_hw *hw,
u8 signal_strength_index)
{
@@ -231,7 +216,7 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
else
max_spatial_stream = 1;
for (i = 0; i < max_spatial_stream; i++) {
- evm = _rtl92d_evm_db_to_percentage(p_drvinfo->rxevm[i]);
+ evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]);
if (packet_match_bssid) {
if (i == 0)
pstats->signalquality =
--
2.3.1


2015-03-11 20:03:49

by Priit Laes

[permalink] [raw]
Subject: [PATCH 4/6] rtlwifi: No need to export rtl_evm_dbm_jaguar anymore

This function is used only by rtl8821ae so move it there

Signed-off-by: Priit Laes <[email protected]>
---
drivers/net/wireless/rtlwifi/rtl8821ae/trx.c | 16 +++++++++++++++-
drivers/net/wireless/rtlwifi/stats.c | 15 ---------------
drivers/net/wireless/rtlwifi/stats.h | 1 -
3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
index 72af4b9..174743a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
@@ -64,6 +64,20 @@ static u16 odm_cfo(char value)
return ret_val;
}

+static u8 _rtl8821ae_evm_dbm_jaguar(char value)
+{
+ char ret_val = value;
+
+ /* -33dB~0dB to 33dB ~ 0dB*/
+ if (ret_val == -128)
+ ret_val = 127;
+ else if (ret_val < 0)
+ ret_val = 0 - ret_val;
+
+ ret_val = ret_val >> 1;
+ return ret_val;
+}
+
static void query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstatus, u8 *pdesc,
struct rx_fwinfo_8821ae *p_drvinfo,
@@ -246,7 +260,7 @@ static void query_rxphystatus(struct ieee80211_hw *hw,

for (i = 0; i < max_spatial_stream; i++) {
evm = rtl_evm_db_to_percentage(p_phystrpt->rxevm[i]);
- evmdbm = rtl_evm_dbm_jaguar(p_phystrpt->rxevm[i]);
+ evmdbm = _rtl8821ae_evm_dbm_jaguar(p_phystrpt->rxevm[i]);

if (bpacket_match_bssid) {
/* Fill value in RFD, Get the first
diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
index 2021223..7042b6e 100644
--- a/drivers/net/wireless/rtlwifi/stats.c
+++ b/drivers/net/wireless/rtlwifi/stats.c
@@ -48,21 +48,6 @@ u8 rtl_evm_db_to_percentage(char value)
}
EXPORT_SYMBOL(rtl_evm_db_to_percentage);

-u8 rtl_evm_dbm_jaguar(char value)
-{
- char ret_val = value;
-
- /* -33dB~0dB to 33dB ~ 0dB*/
- if (ret_val == -128)
- ret_val = 127;
- else if (ret_val < 0)
- ret_val = 0 - ret_val;
-
- ret_val = ret_val >> 1;
- return ret_val;
-}
-EXPORT_SYMBOL(rtl_evm_dbm_jaguar);
-
static long rtl_translate_todbm(struct ieee80211_hw *hw,
u8 signal_strength_index)
{
diff --git a/drivers/net/wireless/rtlwifi/stats.h b/drivers/net/wireless/rtlwifi/stats.h
index aa4eec8..2b57dff 100644
--- a/drivers/net/wireless/rtlwifi/stats.h
+++ b/drivers/net/wireless/rtlwifi/stats.h
@@ -35,7 +35,6 @@

u8 rtl_query_rxpwrpercentage(char antpower);
u8 rtl_evm_db_to_percentage(char value);
-u8 rtl_evm_dbm_jaguar(char value);
long rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig);
void rtl_process_phyinfo(struct ieee80211_hw *hw, u8 *buffer,
struct rtl_stats *pstatus);
--
2.3.1


2015-03-11 20:03:50

by Priit Laes

[permalink] [raw]
Subject: [PATCH 5/6] rtlwifi: Use common rtl_signal_scale_mapping

Signed-off-by: Priit Laes <[email protected]>
---
drivers/net/wireless/rtlwifi/rtl8188ee/trx.c | 8 +++----
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 34 ++-------------------------
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 33 ++------------------------
drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 35 ++++------------------------
drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 8 +++----
drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 8 +++----
drivers/net/wireless/rtlwifi/rtl8723ae/trx.c | 8 +++----
drivers/net/wireless/rtlwifi/rtl8723be/trx.c | 8 +++----
drivers/net/wireless/rtlwifi/rtl8821ae/trx.c | 8 +++----
drivers/net/wireless/rtlwifi/stats.c | 2 +-
drivers/net/wireless/rtlwifi/stats.h | 2 +-
11 files changed, 34 insertions(+), 120 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
index 791efbe..d1ca048 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
@@ -247,11 +247,11 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw,
* make it good looking, from 0~100.
*/
if (is_cck)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- pwdb_all));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
/*HW antenna diversity*/
rtldm->fat_table.antsel_rx_keep_0 = phystrpt->ant_sel;
rtldm->fat_table.antsel_rx_keep_1 = phystrpt->ant_sel_b;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 4c7e804..6884af4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -49,35 +49,6 @@ static u8 _rtl92ce_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
return skb->priority;
}

-static long _rtl92ce_signal_scale_mapping(struct ieee80211_hw *hw,
- long currsig)
-{
- long retsig;
-
- if (currsig >= 61 && currsig <= 100)
- retsig = 90 + ((currsig - 60) / 4);
- else if (currsig >= 41 && currsig <= 60)
- retsig = 78 + ((currsig - 40) / 2);
- else if (currsig >= 31 && currsig <= 40)
- retsig = 66 + (currsig - 30);
- else if (currsig >= 21 && currsig <= 30)
- retsig = 54 + (currsig - 20);
- else if (currsig >= 5 && currsig <= 20)
- retsig = 42 + (((currsig - 5) * 2) / 3);
- else if (currsig == 4)
- retsig = 36;
- else if (currsig == 3)
- retsig = 27;
- else if (currsig == 2)
- retsig = 18;
- else if (currsig == 1)
- retsig = 9;
- else
- retsig = currsig;
-
- return retsig;
-}
-
static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstats,
struct rx_desc_92c *pdesc,
@@ -253,11 +224,10 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
*/
if (is_cck_rate)
pstats->signalstrength =
- (u8) (_rtl92ce_signal_scale_mapping(hw, pwdb_all));
+ (u8) (rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
pstats->signalstrength =
- (u8) (_rtl92ce_signal_scale_mapping
- (hw, total_rssi /= rf_rx_num));
+ (u8) (rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

static void _rtl92ce_translate_rx_signal_stuff(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index 60f2001..728e4ff 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -714,34 +714,6 @@ void rtl92c_set_data_filter(struct ieee80211_hw *hw, u16 filter)
}
/*==============================================================*/

-static long _rtl92c_signal_scale_mapping(struct ieee80211_hw *hw,
- long currsig)
-{
- long retsig;
-
- if (currsig >= 61 && currsig <= 100)
- retsig = 90 + ((currsig - 60) / 4);
- else if (currsig >= 41 && currsig <= 60)
- retsig = 78 + ((currsig - 40) / 2);
- else if (currsig >= 31 && currsig <= 40)
- retsig = 66 + (currsig - 30);
- else if (currsig >= 21 && currsig <= 30)
- retsig = 54 + (currsig - 20);
- else if (currsig >= 5 && currsig <= 20)
- retsig = 42 + (((currsig - 5) * 2) / 3);
- else if (currsig == 4)
- retsig = 36;
- else if (currsig == 3)
- retsig = 27;
- else if (currsig == 2)
- retsig = 18;
- else if (currsig == 1)
- retsig = 9;
- else
- retsig = currsig;
- return retsig;
-}
-
static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstats,
struct rx_desc_92c *p_desc,
@@ -872,11 +844,10 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
}
if (is_cck_rate)
pstats->signalstrength =
- (u8) (_rtl92c_signal_scale_mapping(hw, pwdb_all));
+ (u8) (rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
pstats->signalstrength =
- (u8) (_rtl92c_signal_scale_mapping
- (hw, total_rssi /= rf_rx_num));
+ (u8) (rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

void rtl92c_translate_rx_signal_stuff(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index 369edd4..44fcf79 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -58,33 +58,6 @@ static long _rtl92de_translate_todbm(struct ieee80211_hw *hw,
return signal_power;
}

-static long _rtl92de_signal_scale_mapping(struct ieee80211_hw *hw, long currsig)
-{
- long retsig;
-
- if (currsig >= 61 && currsig <= 100)
- retsig = 90 + ((currsig - 60) / 4);
- else if (currsig >= 41 && currsig <= 60)
- retsig = 78 + ((currsig - 40) / 2);
- else if (currsig >= 31 && currsig <= 40)
- retsig = 66 + (currsig - 30);
- else if (currsig >= 21 && currsig <= 30)
- retsig = 54 + (currsig - 20);
- else if (currsig >= 5 && currsig <= 20)
- retsig = 42 + (((currsig - 5) * 2) / 3);
- else if (currsig == 4)
- retsig = 36;
- else if (currsig == 3)
- retsig = 27;
- else if (currsig == 2)
- retsig = 18;
- else if (currsig == 1)
- retsig = 9;
- else
- retsig = currsig;
- return retsig;
-}
-
static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstats,
struct rx_desc_92d *pdesc,
@@ -227,11 +200,11 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
}
}
if (is_cck_rate)
- pstats->signalstrength = (u8)(_rtl92de_signal_scale_mapping(hw,
- pwdb_all));
+ pstats->signalstrength =
+ (u8)(rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
- pstats->signalstrength = (u8)(_rtl92de_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstats->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

static void rtl92d_loop_over_paths(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
index d39ee67..de8c9f8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
@@ -225,11 +225,11 @@ static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw,
* make it good looking, from 0~100.
*/
if (is_cck)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- pwdb_all));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

static void _rtl92ee_translate_rx_signal_stuff(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index 125b29b..f88d125 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -210,11 +210,11 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
}

if (is_cck)
- pstats->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- pwdb_all));
+ pstats->signalstrength =
+ (u8)(rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
- pstats->signalstrength = (u8) (rtl_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstats->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

static void _rtl92se_translate_rx_signal_stuff(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
index 2f7c144..2003f11 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
@@ -229,11 +229,11 @@ static void _rtl8723e_query_rxphystatus(struct ieee80211_hw *hw,
* make it good looking, from 0~100.
*/
if (is_cck)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- pwdb_all));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

static void translate_rx_signal_stuff(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
index 338ec9a..d7c2edc 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
@@ -201,11 +201,11 @@ static void _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw,
* make it good looking, from 0~100.
*/
if (is_cck)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- pwdb_all));
+ pstatus->signalstrength =
+ (u8)rtl_signal_scale_mapping(pwdb_all);
else if (rf_rx_num != 0)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
}

static void _rtl8723be_translate_rx_signal_stuff(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
index 174743a..659bac9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
@@ -285,11 +285,11 @@ static void query_rxphystatus(struct ieee80211_hw *hw,
* make it good looking, from 0~100.
*/
if (is_cck)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- pwdb_all));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(pwdb_all));
else if (rf_rx_num != 0)
- pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
- total_rssi /= rf_rx_num));
+ pstatus->signalstrength =
+ (u8)(rtl_signal_scale_mapping(total_rssi /= rf_rx_num));
/*HW antenna diversity*/
rtldm->fat_table.antsel_rx_keep_0 = p_phystrpt->antidx_anta;
rtldm->fat_table.antsel_rx_keep_1 = p_phystrpt->antidx_antb;
diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
index 7042b6e..c702d01 100644
--- a/drivers/net/wireless/rtlwifi/stats.c
+++ b/drivers/net/wireless/rtlwifi/stats.c
@@ -58,7 +58,7 @@ static long rtl_translate_todbm(struct ieee80211_hw *hw,
return signal_power;
}

-long rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig)
+long rtl_signal_scale_mapping(long currsig)
{
long retsig;

diff --git a/drivers/net/wireless/rtlwifi/stats.h b/drivers/net/wireless/rtlwifi/stats.h
index 2b57dff..689006b 100644
--- a/drivers/net/wireless/rtlwifi/stats.h
+++ b/drivers/net/wireless/rtlwifi/stats.h
@@ -35,7 +35,7 @@

u8 rtl_query_rxpwrpercentage(char antpower);
u8 rtl_evm_db_to_percentage(char value);
-long rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig);
+long rtl_signal_scale_mapping(long currsig);
void rtl_process_phyinfo(struct ieee80211_hw *hw, u8 *buffer,
struct rtl_stats *pstatus);

--
2.3.1


2015-03-16 15:58:13

by Kalle Valo

[permalink] [raw]
Subject: Re: [2/6] rtlwifi: Clean rtl_evm_db_to_percentage a bit


> Signed-off-by: Priit Laes <[email protected]>

Thanks, 2 patches applied to wireless-drivers-next.git:

54fb66d6fe98 rtlwifi: Clean rtl_evm_db_to_percentage a bit
52f119ddea41 rtlwifi: No need to export rtl_evm_dbm_jaguar anymore

3 patches skipped because of conflicts:

[3/6] rtlwifi: Use common rtl_evm_db_to_percentage
[5/6] rtlwifi: Use common rtl_signal_scale_mapping
[6/6] rtlwifi: Rename rtl_translate_todbm to rtl_signalpower_todbm

And patch 1 dropped due to comments.

Kalle Valo

2015-03-11 20:03:47

by Priit Laes

[permalink] [raw]
Subject: [PATCH 1/6] rtlwifi: Use common rtl_query_rxpwrpercentage function

Signed-off-by: Priit Laes <[email protected]>
---
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 14 ++------------
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 16 +++-------------
drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 16 +++-------------
drivers/net/wireless/rtlwifi/stats.c | 4 ++--
4 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 84ddd4d..4eedf39 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -49,16 +49,6 @@ static u8 _rtl92ce_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
return skb->priority;
}

-static u8 _rtl92c_query_rxpwrpercentage(char antpower)
-{
- if ((antpower <= -100) || (antpower >= 20))
- return 0;
- else if (antpower >= 0)
- return 100;
- else
- return 100 + antpower;
-}
-
static u8 _rtl92c_evm_db_to_percentage(char value)
{
char ret_val;
@@ -236,7 +226,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
rx_pwr[i] =
((p_drvinfo->gain_trsw[i] & 0x3f) * 2) - 110;
/* Translate DBM to percentage. */
- rssi = _rtl92c_query_rxpwrpercentage(rx_pwr[i]);
+ rssi = rtl_query_rxpwrpercentage(rx_pwr[i]);
total_rssi += rssi;
/* Get Rx snr value in DB */
rtlpriv->stats.rx_snr_db[i] =
@@ -251,7 +241,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
* hardware (for rate adaptive)
*/
rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 110;
- pwdb_all = _rtl92c_query_rxpwrpercentage(rx_pwr_all);
+ pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
pstats->rx_pwdb_all = pwdb_all;
pstats->rxpower = rx_pwr_all;
pstats->recvsignalpower = rx_pwr_all;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index 133e395..f55b35c 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -714,16 +714,6 @@ void rtl92c_set_data_filter(struct ieee80211_hw *hw, u16 filter)
}
/*==============================================================*/

-static u8 _rtl92c_query_rxpwrpercentage(char antpower)
-{
- if ((antpower <= -100) || (antpower >= 20))
- return 0;
- else if (antpower >= 0)
- return 100;
- else
- return 100 + antpower;
-}
-
static u8 _rtl92c_evm_db_to_percentage(char value)
{
char ret_val;
@@ -838,7 +828,7 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
break;
}
}
- pwdb_all = _rtl92c_query_rxpwrpercentage(rx_pwr_all);
+ pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
pstats->rx_pwdb_all = pwdb_all;
pstats->recvsignalpower = rx_pwr_all;
if (packet_match_bssid) {
@@ -866,7 +856,7 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
rf_rx_num++;
rx_pwr[i] =
((p_drvinfo->gain_trsw[i] & 0x3f) * 2) - 110;
- rssi = _rtl92c_query_rxpwrpercentage(rx_pwr[i]);
+ rssi = rtl_query_rxpwrpercentage(rx_pwr[i]);
total_rssi += rssi;
rtlpriv->stats.rx_snr_db[i] =
(long)(p_drvinfo->rxsnr[i] / 2);
@@ -875,7 +865,7 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
pstats->rx_mimo_signalstrength[i] = (u8) rssi;
}
rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 110;
- pwdb_all = _rtl92c_query_rxpwrpercentage(rx_pwr_all);
+ pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
pstats->rx_pwdb_all = pwdb_all;
pstats->rxpower = rx_pwr_all;
pstats->recvsignalpower = rx_pwr_all;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index 1feaa62..54736dd 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -48,16 +48,6 @@ static u8 _rtl92de_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
return skb->priority;
}

-static u8 _rtl92d_query_rxpwrpercentage(char antpower)
-{
- if ((antpower <= -100) || (antpower >= 20))
- return 0;
- else if (antpower >= 0)
- return 100;
- else
- return 100 + antpower;
-}
-
static u8 _rtl92d_evm_db_to_percentage(char value)
{
char ret_val = value;
@@ -181,7 +171,7 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
break;
}
}
- pwdb_all = _rtl92d_query_rxpwrpercentage(rx_pwr_all);
+ pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
/* CCK gain is smaller than OFDM/MCS gain, */
/* so we add gain diff by experiences, the val is 6 */
pwdb_all += 6;
@@ -223,7 +213,7 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
rf_rx_num++;
rx_pwr[i] = ((p_drvinfo->gain_trsw[i] & 0x3f) * 2)
- 110;
- rssi = _rtl92d_query_rxpwrpercentage(rx_pwr[i]);
+ rssi = rtl_query_rxpwrpercentage(rx_pwr[i]);
total_rssi += rssi;
rtlpriv->stats.rx_snr_db[i] =
(long)(p_drvinfo->rxsnr[i] / 2);
@@ -231,7 +221,7 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
pstats->rx_mimo_signalstrength[i] = (u8) rssi;
}
rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 106;
- pwdb_all = _rtl92d_query_rxpwrpercentage(rx_pwr_all);
+ pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
pstats->rx_pwdb_all = pwdb_all;
pstats->rxpower = rx_pwr_all;
pstats->recvsignalpower = rx_pwr_all;
diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
index 2d0736a..874e7d1 100644
--- a/drivers/net/wireless/rtlwifi/stats.c
+++ b/drivers/net/wireless/rtlwifi/stats.c
@@ -26,14 +26,14 @@
#include "stats.h"
#include <linux/export.h>

+/* TODO: Figure out a better name */
u8 rtl_query_rxpwrpercentage(char antpower)
{
if ((antpower <= -100) || (antpower >= 20))
return 0;
else if (antpower >= 0)
return 100;
- else
- return 100 + antpower;
+ return 100 + antpower;
}
EXPORT_SYMBOL(rtl_query_rxpwrpercentage);

--
2.3.1


2015-03-11 20:19:47

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/6] rtlwifi: Use common rtl_query_rxpwrpercentage function

On Wed, 2015-03-11 at 22:03 +0200, Priit Laes wrote:
> diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
[]
> @@ -26,14 +26,14 @@
> #include "stats.h"
> #include <linux/export.h>
>
> +/* TODO: Figure out a better name */
> u8 rtl_query_rxpwrpercentage(char antpower)
> {
> if ((antpower <= -100) || (antpower >= 20))
> return 0;
> else if (antpower >= 0)
> return 100;
> - else
> - return 100 + antpower;
> + return 100 + antpower;
> }

This is a superfluous change.

If it was changed because checkpatch emitted a warning,
there's a newer version of checkpatch that doesn't emit
a warning for this line.

If any change was to be made, I suggest reordering so
that the return values are written low to high like:

u8 rtl_query_rxpwrpercentage(char antpower)
{
if ((antpower <= -100) || (antpower >= 20))
return 0;
else if (antpower < 0)
return antpower + 100;
else
return 100;
}



2015-03-11 20:03:51

by Priit Laes

[permalink] [raw]
Subject: [PATCH 6/6] rtlwifi: Rename rtl_translate_todbm to rtl_signalpower_todbm

Signed-off-by: Priit Laes <[email protected]>
---
drivers/net/wireless/rtlwifi/stats.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/stats.c b/drivers/net/wireless/rtlwifi/stats.c
index c702d01..4739324 100644
--- a/drivers/net/wireless/rtlwifi/stats.c
+++ b/drivers/net/wireless/rtlwifi/stats.c
@@ -48,14 +48,9 @@ u8 rtl_evm_db_to_percentage(char value)
}
EXPORT_SYMBOL(rtl_evm_db_to_percentage);

-static long rtl_translate_todbm(struct ieee80211_hw *hw,
- u8 signal_strength_index)
+static long rtl_signalpower_todbm(u8 signal_strength_index)
{
- long signal_power;
-
- signal_power = (long)((signal_strength_index + 1) >> 1);
- signal_power -= 95;
- return signal_power;
+ return (long)((signal_strength_index + 1) >> 1) - 95;
}

long rtl_signal_scale_mapping(long currsig)
@@ -93,7 +88,7 @@ static void rtl_process_ui_rssi(struct ieee80211_hw *hw,
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &(rtlpriv->phy);
u8 rfpath;
- u32 last_rssi, tmpval;
+ u32 last_rssi;

if (!pstatus->packet_toself && !pstatus->packet_beacon)
return;
@@ -112,10 +107,9 @@ static void rtl_process_ui_rssi(struct ieee80211_hw *hw,
pstatus->signalstrength;
if (rtlpriv->stats.ui_rssi.index >= PHY_RSSI_SLID_WIN_MAX)
rtlpriv->stats.ui_rssi.index = 0;
- tmpval = rtlpriv->stats.ui_rssi.total_val /
- rtlpriv->stats.ui_rssi.total_num;
- rtlpriv->stats.signal_strength = rtl_translate_todbm(hw,
- (u8) tmpval);
+ rtlpriv->stats.signal_strength = rtl_signalpower_todbm(
+ (u8)rtlpriv->stats.ui_rssi.total_val /
+ rtlpriv->stats.ui_rssi.total_num);
pstatus->rssi = rtlpriv->stats.signal_strength;

if (pstatus->is_cck)
--
2.3.1