ath9k_hw: simplify ar9003_hw_per_calibration
authorFelix Fietkau <nbd@nbd.name>
Mon, 11 Jul 2016 10:02:46 +0000 (12:02 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Tue, 19 Jul 2016 17:59:08 +0000 (20:59 +0300)
Reduce indentation, use a variable to save a few pointer dereferences

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath9k/ar9003_calib.c

index 518e649ecff383898288f3f154f9fe7af32897f5..b9ef3d371030bce1d81f1b9ce2ee3f2bf0cf787a 100644 (file)
@@ -75,50 +75,49 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,
                                      struct ath9k_cal_list *currCal)
 {
        struct ath9k_hw_cal_data *caldata = ah->caldata;
-       /* Cal is assumed not done until explicitly set below */
-       bool iscaldone = false;
+       const struct ath9k_percal_data *cur_caldata = currCal->calData;
 
        /* Calibration in progress. */
        if (currCal->calState == CAL_RUNNING) {
                /* Check to see if it has finished. */
-               if (!(REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)) {
+               if (REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)
+                       return false;
+
+               /*
+               * Accumulate cal measures for active chains
+               */
+               cur_caldata->calCollect(ah);
+               ah->cal_samples++;
+
+               if (ah->cal_samples >= cur_caldata->calNumSamples) {
+                       unsigned int i, numChains = 0;
+                       for (i = 0; i < AR9300_MAX_CHAINS; i++) {
+                               if (rxchainmask & (1 << i))
+                                       numChains++;
+                       }
+
                        /*
-                       * Accumulate cal measures for active chains
+                       * Process accumulated data
                        */
-                       currCal->calData->calCollect(ah);
-                       ah->cal_samples++;
-
-                       if (ah->cal_samples >=
-                           currCal->calData->calNumSamples) {
-                               unsigned int i, numChains = 0;
-                               for (i = 0; i < AR9300_MAX_CHAINS; i++) {
-                                       if (rxchainmask & (1 << i))
-                                               numChains++;
-                               }
+                       cur_caldata->calPostProc(ah, numChains);
 
-                               /*
-                               * Process accumulated data
-                               */
-                               currCal->calData->calPostProc(ah, numChains);
-
-                               /* Calibration has finished. */
-                               caldata->CalValid |= currCal->calData->calType;
-                               currCal->calState = CAL_DONE;
-                               iscaldone = true;
-                       } else {
+                       /* Calibration has finished. */
+                       caldata->CalValid |= cur_caldata->calType;
+                       currCal->calState = CAL_DONE;
+                       return true;
+               } else {
                        /*
                         * Set-up collection of another sub-sample until we
                         * get desired number
                         */
                        ar9003_hw_setup_calibration(ah, currCal);
-                       }
                }
-       } else if (!(caldata->CalValid & currCal->calData->calType)) {
+       } else if (!(caldata->CalValid & cur_caldata->calType)) {
                /* If current cal is marked invalid in channel, kick it off */
                ath9k_hw_reset_calibration(ah, currCal);
        }
 
-       return iscaldone;
+       return false;
 }
 
 static int ar9003_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,