1 --- a/drivers/net/wireless/ath/ath9k/calib.c
2 +++ b/drivers/net/wireless/ath/ath9k/calib.c
5 /* Common calibration code */
7 -/* We can tune this as we go by monitoring really low values */
8 -#define ATH9K_NF_TOO_LOW -60
9 +#define ATH9K_NF_TOO_HIGH -60
11 static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
13 @@ -45,11 +44,35 @@ static int16_t ath9k_hw_get_nf_hist_mid(
17 -static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h,
18 +static struct ath_nf_limits *ath9k_hw_get_nf_limits(struct ath_hw *ah,
19 + struct ath9k_channel *chan)
21 + struct ath_nf_limits *limit;
23 + if (!chan || IS_CHAN_2GHZ(chan))
31 +static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
32 + struct ath9k_channel *chan)
34 + return ath9k_hw_get_nf_limits(ah, chan)->nominal;
38 +static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah,
39 + struct ath9k_nfcal_hist *h,
42 + struct ath_nf_limits *limit;
45 + limit = ath9k_hw_get_nf_limits(ah, ah->curchan);
47 for (i = 0; i < NUM_NF_READINGS; i++) {
48 h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
50 @@ -63,6 +86,9 @@ static void ath9k_hw_update_nfcal_hist_b
52 ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer);
55 + if (h[i].privNF > limit->max)
56 + h[i].privNF = limit->max;
60 @@ -104,19 +130,6 @@ void ath9k_hw_reset_calibration(struct a
64 -static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
65 - struct ath9k_channel *chan)
67 - struct ath_nf_limits *limit;
69 - if (!chan || IS_CHAN_2GHZ(chan))
74 - return limit->nominal;
77 /* This is done for the currently configured channel */
78 bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
80 @@ -277,10 +290,10 @@ static void ath9k_hw_nf_sanitize(struct
81 "NF calibrated [%s] [chain %d] is %d\n",
82 (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]);
84 - if (nf[i] > limit->max) {
85 + if (nf[i] > ATH9K_NF_TOO_HIGH) {
86 ath_print(common, ATH_DBG_CALIBRATE,
87 "NF[%d] (%d) > MAX (%d), correcting to MAX",
88 - i, nf[i], limit->max);
89 + i, nf[i], ATH9K_NF_TOO_HIGH);
91 } else if (nf[i] < limit->min) {
92 ath_print(common, ATH_DBG_CALIBRATE,
93 @@ -326,7 +339,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, s
95 h = caldata->nfCalHist;
96 caldata->nfcal_pending = false;
97 - ath9k_hw_update_nfcal_hist_buffer(h, nfarray);
98 + ath9k_hw_update_nfcal_hist_buffer(ah, h, nfarray);
99 caldata->rawNoiseFloor = h[0].privNF;