Commit 11ab35ed authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

rt2x00: use DECLARE_EWMA

Instead of using the out-of-line EWMA calculation, use DECLARE_EWMA()
to create static inlines. On x86/64 this results in code that's one
byte larger (for me), but reduces struct link_ant and struct link
size by the two unsigned long values that store the parameters each.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46f26ddf
...@@ -240,7 +240,6 @@ config RT2X00_LIB_USB ...@@ -240,7 +240,6 @@ config RT2X00_LIB_USB
config RT2X00_LIB config RT2X00_LIB
tristate tristate
select AVERAGE
config RT2X00_LIB_FIRMWARE config RT2X00_LIB_FIRMWARE
bool bool
......
...@@ -254,6 +254,8 @@ struct link_qual { ...@@ -254,6 +254,8 @@ struct link_qual {
int tx_failed; int tx_failed;
}; };
DECLARE_EWMA(rssi, 1024, 8)
/* /*
* Antenna settings about the currently active link. * Antenna settings about the currently active link.
*/ */
...@@ -285,7 +287,7 @@ struct link_ant { ...@@ -285,7 +287,7 @@ struct link_ant {
* Similar to the avg_rssi in the link_qual structure * Similar to the avg_rssi in the link_qual structure
* this value is updated by using the walking average. * this value is updated by using the walking average.
*/ */
struct ewma rssi_ant; struct ewma_rssi rssi_ant;
}; };
/* /*
...@@ -314,7 +316,7 @@ struct link { ...@@ -314,7 +316,7 @@ struct link {
/* /*
* Currently active average RSSI value * Currently active average RSSI value
*/ */
struct ewma avg_rssi; struct ewma_rssi avg_rssi;
/* /*
* Work structure for scheduling periodic link tuning. * Work structure for scheduling periodic link tuning.
......
...@@ -33,15 +33,11 @@ ...@@ -33,15 +33,11 @@
*/ */
#define DEFAULT_RSSI -128 #define DEFAULT_RSSI -128
/* Constants for EWMA calculations. */ static inline int rt2x00link_get_avg_rssi(struct ewma_rssi *ewma)
#define RT2X00_EWMA_FACTOR 1024
#define RT2X00_EWMA_WEIGHT 8
static inline int rt2x00link_get_avg_rssi(struct ewma *ewma)
{ {
unsigned long avg; unsigned long avg;
avg = ewma_read(ewma); avg = ewma_rssi_read(ewma);
if (avg) if (avg)
return -avg; return -avg;
...@@ -76,8 +72,7 @@ static void rt2x00link_antenna_update_rssi_history(struct rt2x00_dev *rt2x00dev, ...@@ -76,8 +72,7 @@ static void rt2x00link_antenna_update_rssi_history(struct rt2x00_dev *rt2x00dev,
static void rt2x00link_antenna_reset(struct rt2x00_dev *rt2x00dev) static void rt2x00link_antenna_reset(struct rt2x00_dev *rt2x00dev)
{ {
ewma_init(&rt2x00dev->link.ant.rssi_ant, RT2X00_EWMA_FACTOR, ewma_rssi_init(&rt2x00dev->link.ant.rssi_ant);
RT2X00_EWMA_WEIGHT);
} }
static void rt2x00lib_antenna_diversity_sample(struct rt2x00_dev *rt2x00dev) static void rt2x00lib_antenna_diversity_sample(struct rt2x00_dev *rt2x00dev)
...@@ -225,12 +220,12 @@ void rt2x00link_update_stats(struct rt2x00_dev *rt2x00dev, ...@@ -225,12 +220,12 @@ void rt2x00link_update_stats(struct rt2x00_dev *rt2x00dev,
/* /*
* Update global RSSI * Update global RSSI
*/ */
ewma_add(&link->avg_rssi, -rxdesc->rssi); ewma_rssi_add(&link->avg_rssi, -rxdesc->rssi);
/* /*
* Update antenna RSSI * Update antenna RSSI
*/ */
ewma_add(&ant->rssi_ant, -rxdesc->rssi); ewma_rssi_add(&ant->rssi_ant, -rxdesc->rssi);
} }
void rt2x00link_start_tuner(struct rt2x00_dev *rt2x00dev) void rt2x00link_start_tuner(struct rt2x00_dev *rt2x00dev)
...@@ -285,8 +280,7 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna) ...@@ -285,8 +280,7 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)
*/ */
rt2x00dev->link.count = 0; rt2x00dev->link.count = 0;
memset(qual, 0, sizeof(*qual)); memset(qual, 0, sizeof(*qual));
ewma_init(&rt2x00dev->link.avg_rssi, RT2X00_EWMA_FACTOR, ewma_rssi_init(&rt2x00dev->link.avg_rssi);
RT2X00_EWMA_WEIGHT);
/* /*
* Restore the VGC level as stored in the registers, * Restore the VGC level as stored in the registers,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment