2015-03-22 13:36:05

by Priit Laes

[permalink] [raw]
Subject: [PATCH v2 0/4] 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.

There are no functional changes since the first posting, except dropping
patches already applied and addressing the comments by Joe Perches.

Priit Laes (4):
rtlwifi: Use common rtl_evm_db_to_percentage
rtlwifi: Use common rtl_signal_scale_mapping
rtlwifi: Rename rtl_translate_todbm to rtl_signalpower_todbm
rtlwifi: Use common rtl_query_rxpwrpercentage function

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 | 8 ++--
drivers/net/wireless/rtlwifi/stats.c | 27 +++++------
drivers/net/wireless/rtlwifi/stats.h | 2 +-
11 files changed, 55 insertions(+), 227 deletions(-)

--
2.3.3



2015-03-22 16:27:54

by Larry Finger

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

On 03/22/2015 08:35 AM, Priit Laes wrote:
> Hi all,
>
> This is a small fixup to unify make the drivers use common helper
> functions for driver statistics.
>
> There are no functional changes since the first posting, except dropping
> patches already applied and addressing the comments by Joe Perches.

Are there patches that are required before these work? Applying these four
results in the following build errors:

drivers/net/wireless/rtlwifi/rtl8192de/trx.c: In function
?_rtl92de_query_rxphystatus?:
drivers/net/wireless/rtlwifi/rtl8192de/trx.c:132:3: error: implicit declaration
of function ?rtl_query_rxpwrpercentage? [-Werror=implicit-function-declaration]
pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
^
drivers/net/wireless/rtlwifi/rtl8192de/trx.c:192:4: error: implicit declaration
of function ?rtl_evm_db_to_percentage? [-Werror=implicit-function-declaration]
evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]);
^
drivers/net/wireless/rtlwifi/rtl8192de/trx.c:204:4: error: implicit declaration
of function ?rtl_signal_scale_mapping? [-Werror=implicit-function-declaration]
(u8)(rtl_signal_scale_mapping(pwdb_all));
^
cc1: some warnings being treated as errors
scripts/Makefile.build:258: recipe for target
'drivers/net/wireless/rtlwifi/rtl8192de/trx.o' failed

I cannot find any patches that created common routines in rtlwifi.

Larry


2015-03-22 13:36:07

by Priit Laes

[permalink] [raw]
Subject: [PATCH v2 2/4] 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 f6cf05e..e2474bd 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -59,35 +59,6 @@ static u8 _rtl92c_query_rxpwrpercentage(char antpower)
return 100 + antpower;
}

-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,
@@ -263,11 +234,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 40e5a84..18edd8e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -724,34 +724,6 @@ static u8 _rtl92c_query_rxpwrpercentage(char antpower)
return 100 + antpower;
}

-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,
@@ -882,11 +854,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 7a621f9..64ad847 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -68,33 +68,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,
@@ -237,11 +210,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 d8b3069..9ebeb6e 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.3


2015-03-22 13:36:08

by Priit Laes

[permalink] [raw]
Subject: [PATCH v2 4/4] 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 | 7 ++++---
4 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index e2474bd..6884af4 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 void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstats,
struct rx_desc_92c *pdesc,
@@ -187,7 +177,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] =
@@ -202,7 +192,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 18edd8e..728e4ff 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 void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstats,
struct rx_desc_92c *p_desc,
@@ -794,7 +784,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) {
@@ -822,7 +812,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);
@@ -831,7 +821,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 64ad847..44fcf79 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 long _rtl92de_translate_todbm(struct ieee80211_hw *hw,
u8 signal_strength_index)
{
@@ -139,7 +129,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;
@@ -181,7 +171,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);
@@ -189,7 +179,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 4cce472..1fa19d5 100644
--- a/drivers/net/wireless/rtlwifi/stats.c
+++ b/drivers/net/wireless/rtlwifi/stats.c
@@ -26,14 +26,15 @@
#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
+ else if (antpower < 0)
return 100 + antpower;
+ else
+ return 100;
}
EXPORT_SYMBOL(rtl_query_rxpwrpercentage);

--
2.3.3


2015-03-22 17:05:33

by Priit Laes

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

On Sun, 2015-03-22 at 11:27 -0500, Larry Finger wrote:
> On 03/22/2015 08:35 AM, Priit Laes wrote:
> > Hi all,
> >
> > This is a small fixup to unify make the drivers use common helper
> > functions for driver statistics.
> >
> > There are no functional changes since the first posting, except
> > dropping
> > patches already applied and addressing the comments by Joe Perches.
>
> Are there patches that are required before these work? Applying
> these four
> results in the following build errors:

Oops. I'll figure out what went wrong.
>
> drivers/net/wireless/rtlwifi/rtl8192de/trx.c: In function
> ‘_rtl92de_query_rxphystatus’:
> drivers/net/wireless/rtlwifi/rtl8192de/trx.c:132:3: error: implicit
> declaration
> of function ‘rtl_query_rxpwrpercentage’ [-Werror=implicit-function-
> declaration]
> pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
> ^
> drivers/net/wireless/rtlwifi/rtl8192de/trx.c:192:4: error: implicit
> declaration
> of function ‘rtl_evm_db_to_percentage’ [-Werror=implicit-function-
> declaration]
> evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]);
> ^
> drivers/net/wireless/rtlwifi/rtl8192de/trx.c:204:4: error: implicit
> declaration
> of function ‘rtl_signal_scale_mapping’ [-Werror=implicit-function-
> declaration]
> (u8)(rtl_signal_scale_mapping(pwdb_all));
> ^
> cc1: some warnings being treated as errors
> scripts/Makefile.build:258: recipe for target
> 'drivers/net/wireless/rtlwifi/rtl8192de/trx.o' failed
>
> I cannot find any patches that created common routines in rtlwifi.
>
> Larry
>

2015-03-22 13:36:05

by Priit Laes

[permalink] [raw]
Subject: [PATCH v2 1/4] 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 84ddd4d..f6cf05e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -59,26 +59,6 @@ static u8 _rtl92c_query_rxpwrpercentage(char antpower)
return 100 + antpower;
}

-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)
{
@@ -264,7 +244,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 133e395..40e5a84 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -724,22 +724,6 @@ static u8 _rtl92c_query_rxpwrpercentage(char antpower)
return 100 + antpower;
}

-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)
{
@@ -886,7 +870,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 1feaa62..7a621f9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -58,21 +58,6 @@ static u8 _rtl92d_query_rxpwrpercentage(char antpower)
return 100 + antpower;
}

-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)
{
@@ -241,7 +226,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.3


2015-03-22 13:36:08

by Priit Laes

[permalink] [raw]
Subject: [PATCH v2 3/4] 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 9ebeb6e..4cce472 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.3