From: =?ISO-8859-1?Q?Bj=F6rn_Smedman?= Date: Wed, 13 Jan 2010 16:17:27 +0100 Subject: [ath9k-devel] [RFC] Avoid loading single/bad NF sample into CCA registers Message-ID: <133e8d7e1001130717t48e3856ay14e7e6579bfe221c@mail.gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org Normally new noise floor values loaded into CCA registers in calib.c is the median of a number of reasonable calibration samples taken over time. However, looking at the code in ath9k_hw_update_nfcal_hist_buffer() it seems possible to also load a new noise floor based on a single calibration sample, an old median value, a median of unreasonable values or the initial default value under certain circumstances. The patch below attempt to avoid this by checking that the noise floor estimate is the median of a number of samples (which may or may not be reasonable). An alternative perhaps better approach would be to store only reasonable values in nfCalBuffer and always compute the median in ath9k_hw_update_nfcal_hist_buffer(). Any thoughts? /Bj?rn --- diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c index 238a574..970314d 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c @@ -640,7 +640,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan) h = ah->nfCalHist; for (i = 0; i < NUM_NF_READINGS; i++) { - if (chainmask & (1 << i)) { + if (!h[i].invalidNFcount && chainmask & (1 << i)) { val = REG_READ(ah, ar5416_cca_regs[i]); val &= 0xFFFFFE00; val |= (((u32) (h[i].privNF) << 1) & 0x1ff);