aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/ar9003_calib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/ar9003_calib.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index fa35a0235f44..3319a676c0fb 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -615,11 +615,10 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
615{ 615{
616 int mp_max = -64, max_idx = 0; 616 int mp_max = -64, max_idx = 0;
617 int mp_min = 63, min_idx = 0; 617 int mp_min = 63, min_idx = 0;
618 int mp_avg = 0, i, outlier_idx = 0; 618 int mp_avg = 0, i, outlier_idx = 0, mp_count = 0;
619 619
620 /* find min/max mismatch across all calibrated gains */ 620 /* find min/max mismatch across all calibrated gains */
621 for (i = 0; i < nmeasurement; i++) { 621 for (i = 0; i < nmeasurement; i++) {
622 mp_avg += mp_coeff[i];
623 if (mp_coeff[i] > mp_max) { 622 if (mp_coeff[i] > mp_max) {
624 mp_max = mp_coeff[i]; 623 mp_max = mp_coeff[i];
625 max_idx = i; 624 max_idx = i;
@@ -632,10 +631,20 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
632 /* find average (exclude max abs value) */ 631 /* find average (exclude max abs value) */
633 for (i = 0; i < nmeasurement; i++) { 632 for (i = 0; i < nmeasurement; i++) {
634 if ((abs(mp_coeff[i]) < abs(mp_max)) || 633 if ((abs(mp_coeff[i]) < abs(mp_max)) ||
635 (abs(mp_coeff[i]) < abs(mp_min))) 634 (abs(mp_coeff[i]) < abs(mp_min))) {
636 mp_avg += mp_coeff[i]; 635 mp_avg += mp_coeff[i];
636 mp_count++;
637 }
637 } 638 }
638 mp_avg /= (nmeasurement - 1); 639
640 /*
641 * finding mean magnitude/phase if possible, otherwise
642 * just use the last value as the mean
643 */
644 if (mp_count)
645 mp_avg /= mp_count;
646 else
647 mp_avg = mp_coeff[nmeasurement - 1];
639 648
640 /* detect outlier */ 649 /* detect outlier */
641 if (abs(mp_max - mp_min) > max_delta) { 650 if (abs(mp_max - mp_min) > max_delta) {