Skip to content

Commit

Permalink
ath5k: use DECLARE_EWMA
Browse files Browse the repository at this point in the history
This reduces code size slightly (at least on x86/64) while also
removing memory consumption by two unsigned long values for each
ath5k device.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Johannes Berg authored and David S. Miller committed Aug 20, 2015
1 parent 5377d75 commit 46f26dd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion drivers/net/wireless/ath/ath5k/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ config ATH5K
select MAC80211_LEDS
select LEDS_CLASS
select NEW_LEDS
select AVERAGE
select ATH5K_AHB if ATH25
select ATH5K_PCI if !ATH25
---help---
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath5k/ani.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void
ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
bool ofdm_trigger)
{
int rssi = ewma_read(&ah->ah_beacon_rssi_avg);
int rssi = ewma_beacon_rssi_read(&ah->ah_beacon_rssi_avg);

ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "raise immunity (%s)",
ofdm_trigger ? "ODFM" : "CCK");
Expand Down Expand Up @@ -309,7 +309,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
static void
ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as)
{
int rssi = ewma_read(&ah->ah_beacon_rssi_avg);
int rssi = ewma_beacon_rssi_read(&ah->ah_beacon_rssi_avg);

ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "lower immunity");

Expand Down
4 changes: 3 additions & 1 deletion drivers/net/wireless/ath/ath5k/ath5k.h
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,8 @@ struct ath5k_statistics {
#define ATH5K_TXQ_LEN_MAX (ATH_TXBUF / 4) /* bufs per queue */
#define ATH5K_TXQ_LEN_LOW (ATH5K_TXQ_LEN_MAX / 2) /* low mark */

DECLARE_EWMA(beacon_rssi, 1024, 8)

/* Driver state associated with an instance of a device */
struct ath5k_hw {
struct ath_common common;
Expand Down Expand Up @@ -1432,7 +1434,7 @@ struct ath5k_hw {
struct ath5k_nfcal_hist ah_nfcal_hist;

/* average beacon RSSI in our BSS (used by ANI) */
struct ewma ah_beacon_rssi_avg;
struct ewma_beacon_rssi ah_beacon_rssi_avg;

/* noise floor from last periodic calibration */
s32 ah_noise_floor;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath5k/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ ath5k_receive_frame(struct ath5k_hw *ah, struct sk_buff *skb,
trace_ath5k_rx(ah, skb);

if (ath_is_mybeacon(common, (struct ieee80211_hdr *)skb->data)) {
ewma_add(&ah->ah_beacon_rssi_avg, rs->rs_rssi);
ewma_beacon_rssi_add(&ah->ah_beacon_rssi_avg, rs->rs_rssi);

/* check beacons in IBSS mode */
if (ah->opmode == NL80211_IFTYPE_ADHOC)
Expand Down Expand Up @@ -2936,7 +2936,7 @@ ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan,
ah->ah_cal_next_short = jiffies +
msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT);

ewma_init(&ah->ah_beacon_rssi_avg, 1024, 8);
ewma_beacon_rssi_init(&ah->ah_beacon_rssi_avg);

/* clear survey data and cycle counters */
memset(&ah->survey, 0, sizeof(ah->survey));
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ath/ath5k/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
st->mib_intr);
len += snprintf(buf + len, sizeof(buf) - len,
"beacon RSSI average:\t%d\n",
(int)ewma_read(&ah->ah_beacon_rssi_avg));
(int)ewma_beacon_rssi_read(&ah->ah_beacon_rssi_avg));

#define CC_PRINT(_struct, _field) \
_struct._field, \
Expand Down

0 comments on commit 46f26dd

Please sign in to comment.