-- for (ip = 0; ip < MPASS; ip++) {
-- for (i = 0; i < num_chains; i++) {
-- nmeasurement = REG_READ_FIELD(ah,
-- AR_PHY_TX_IQCAL_STATUS_B0_9485,
-- AR_PHY_CALIBRATED_GAINS_0);
-- if (nmeasurement > MAX_MEASUREMENT)
-- nmeasurement = MAX_MEASUREMENT;
-+ for (i = 0; i < num_chains; i++) {
-+ nmeasurement = REG_READ_FIELD(ah,
-+ AR_PHY_TX_IQCAL_STATUS_B0,
-+ AR_PHY_CALIBRATED_GAINS_0);
-+ if (nmeasurement > MAX_MEASUREMENT)
-+ nmeasurement = MAX_MEASUREMENT;
-+
-+ for (im = 0; im < nmeasurement; im++) {
-+ ath_dbg(common, ATH_DBG_CALIBRATE,
-+ "Doing Tx IQ Cal for chain %d.\n", i);
-
-- for (im = 0; im < nmeasurement; im++) {
-+ if (REG_READ(ah, txiqcal_status[i]) &
-+ AR_PHY_TX_IQCAL_STATUS_FAILED) {
- ath_dbg(common, ATH_DBG_CALIBRATE,
-- "Doing Tx IQ Cal for chain %d.\n", i);
--
-- if (REG_READ(ah, txiqcal_status[i]) &
-- AR_PHY_TX_IQCAL_STATUS_FAILED) {
-- ath_dbg(common, ATH_DBG_CALIBRATE,
- "Tx IQ Cal failed for chain %d.\n", i);
-- goto tx_iqcal_fail;
-- }
-+ goto tx_iqcal_fail;
-+ }
-
-- for (j = 0; j < 3; j++) {
-- u32 idx = 2 * j, offset = 4 * (3 * im + j);
-+ for (j = 0; j < 3; j++) {
-+ u32 idx = 2 * j, offset = 4 * (3 * im + j);
-
-- REG_RMW_FIELD(ah,
-+ REG_RMW_FIELD(ah,
- AR_PHY_CHAN_INFO_MEMORY,
- AR_PHY_CHAN_INFO_TAB_S2_READ,
- 0);
-
-- /* 32 bits */
-- iq_res[idx] = REG_READ(ah,
-- chan_info_tab[i] +
-- offset);
-+ /* 32 bits */
-+ iq_res[idx] = REG_READ(ah,
-+ chan_info_tab[i] +
-+ offset);
-
-- REG_RMW_FIELD(ah,
-+ REG_RMW_FIELD(ah,
- AR_PHY_CHAN_INFO_MEMORY,
- AR_PHY_CHAN_INFO_TAB_S2_READ,
- 1);
-
-- /* 16 bits */
-- iq_res[idx + 1] = 0xffff & REG_READ(ah,
-- chan_info_tab[i] + offset);
--
-- ath_dbg(common, ATH_DBG_CALIBRATE,
-- "IQ RES[%d]=0x%x"
-- "IQ_RES[%d]=0x%x\n",
-- idx, iq_res[idx], idx + 1,
-- iq_res[idx + 1]);
-- }
-+ /* 16 bits */
-+ iq_res[idx + 1] = 0xffff & REG_READ(ah,
-+ chan_info_tab[i] + offset);
-
-- if (!ar9003_hw_calc_iq_corr(ah, i, iq_res,
-- coeff.iqc_coeff)) {
-- ath_dbg(common, ATH_DBG_CALIBRATE,
-- "Failed in calculation of IQ correction.\n");
-- goto tx_iqcal_fail;
-- }
-+ ath_dbg(common, ATH_DBG_CALIBRATE,
-+ "IQ RES[%d]=0x%x"
-+ "IQ_RES[%d]=0x%x\n",
-+ idx, iq_res[idx], idx + 1,
-+ iq_res[idx + 1]);
-+ }
-
-- coeff.mag_coeff[i][im][ip] =
-- coeff.iqc_coeff[0] & 0x7f;
-- coeff.phs_coeff[i][im][ip] =
-- (coeff.iqc_coeff[0] >> 7) & 0x7f;
--
-- if (coeff.mag_coeff[i][im][ip] > 63)
-- coeff.mag_coeff[i][im][ip] -= 128;
-- if (coeff.phs_coeff[i][im][ip] > 63)
-- coeff.phs_coeff[i][im][ip] -= 128;
-+ if (!ar9003_hw_calc_iq_corr(ah, i, iq_res,
-+ coeff.iqc_coeff)) {
-+ ath_dbg(common, ATH_DBG_CALIBRATE,
-+ "Failed in calculation of \
-+ IQ correction.\n");
-+ goto tx_iqcal_fail;
- }
-+
-+ coeff.mag_coeff[i][im] = coeff.iqc_coeff[0] & 0x7f;
-+ coeff.phs_coeff[i][im] =
-+ (coeff.iqc_coeff[0] >> 7) & 0x7f;
-+
-+ if (coeff.mag_coeff[i][im] > 63)
-+ coeff.mag_coeff[i][im] -= 128;
-+ if (coeff.phs_coeff[i][im] > 63)
-+ coeff.phs_coeff[i][im] -= 128;
- }
- }
- ar9003_hw_tx_iqcal_load_avg_2_passes(ah, num_chains, &coeff);
-@@ -941,6 +838,7 @@ static bool ar9003_hw_init_cal(struct at
+ ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
+--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+@@ -236,7 +236,7 @@ static void ar9003_paprd_get_gain_table(
+ memset(entry, 0, sizeof(ah->paprd_gain_table_entries));
+ memset(index, 0, sizeof(ah->paprd_gain_table_index));
+
+- for (i = 0; i < 32; i++) {
++ for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
+ entry[i] = REG_READ(ah, reg);
+ index[i] = (entry[i] >> 24) & 0xff;
+ reg += 4;
+@@ -246,13 +246,13 @@ static void ar9003_paprd_get_gain_table(
+ static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
+ int target_power)