ath9k: implement temperature compensation support for AR93xx and newer
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 326-ath9k_hw-simplify-ar9003_hw_per_calibration.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 11 Jul 2016 11:34:47 +0200
3 Subject: [PATCH] ath9k_hw: simplify ar9003_hw_per_calibration
4
5 Reduce indentation, use a variable to save a few pointer dereferences
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
11 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
12 @@ -75,50 +75,49 @@ static bool ar9003_hw_per_calibration(st
13                                       struct ath9k_cal_list *currCal)
14  {
15         struct ath9k_hw_cal_data *caldata = ah->caldata;
16 -       /* Cal is assumed not done until explicitly set below */
17 -       bool iscaldone = false;
18 +       const struct ath9k_percal_data *cur_caldata = currCal->calData;
19  
20         /* Calibration in progress. */
21         if (currCal->calState == CAL_RUNNING) {
22                 /* Check to see if it has finished. */
23 -               if (!(REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)) {
24 -                       /*
25 -                       * Accumulate cal measures for active chains
26 -                       */
27 -                       currCal->calData->calCollect(ah);
28 -                       ah->cal_samples++;
29 +               if (REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)
30 +                       return false;
31  
32 -                       if (ah->cal_samples >=
33 -                           currCal->calData->calNumSamples) {
34 -                               unsigned int i, numChains = 0;
35 -                               for (i = 0; i < AR9300_MAX_CHAINS; i++) {
36 -                                       if (rxchainmask & (1 << i))
37 -                                               numChains++;
38 -                               }
39 +               /*
40 +               * Accumulate cal measures for active chains
41 +               */
42 +               cur_caldata->calCollect(ah);
43 +               ah->cal_samples++;
44  
45 -                               /*
46 -                               * Process accumulated data
47 -                               */
48 -                               currCal->calData->calPostProc(ah, numChains);
49 +               if (ah->cal_samples >= cur_caldata->calNumSamples) {
50 +                       unsigned int i, numChains = 0;
51 +                       for (i = 0; i < AR9300_MAX_CHAINS; i++) {
52 +                               if (rxchainmask & (1 << i))
53 +                                       numChains++;
54 +                       }
55  
56 -                               /* Calibration has finished. */
57 -                               caldata->CalValid |= currCal->calData->calType;
58 -                               currCal->calState = CAL_DONE;
59 -                               iscaldone = true;
60 -                       } else {
61 +                       /*
62 +                       * Process accumulated data
63 +                       */
64 +                       cur_caldata->calPostProc(ah, numChains);
65 +
66 +                       /* Calibration has finished. */
67 +                       caldata->CalValid |= cur_caldata->calType;
68 +                       currCal->calState = CAL_DONE;
69 +                       return true;
70 +               } else {
71                         /*
72                          * Set-up collection of another sub-sample until we
73                          * get desired number
74                          */
75                         ar9003_hw_setup_calibration(ah, currCal);
76 -                       }
77                 }
78 -       } else if (!(caldata->CalValid & currCal->calData->calType)) {
79 +       } else if (!(caldata->CalValid & cur_caldata->calType)) {
80                 /* If current cal is marked invalid in channel, kick it off */
81                 ath9k_hw_reset_calibration(ah, currCal);
82         }
83  
84 -       return iscaldone;
85 +       return false;
86  }
87  
88  static int ar9003_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,