This patch fix calibration procedure bug, where sign of value
i_coff/q_coff is lost when its value and'ed with 0x3f/0x1f.

In phy.c/ath5k_hw_rf511x_calibrate()
i_coff = ((-iq_corr) / i_coffd) & 0x3f;
but, i_coff is signed 32bit value, but when masking it with 0x3f it
becomes signed positive value 0..63,
but later, at boundary check it compared with (s32)-32 or (s32)31, and
all correct negative values of i_coff always be
greater than 31, and in card will be written not correct value (31
instead of -5, for example).

Proposed patch fix this bug, and some small differences between ath5k
and Sam's HAL.
I have tested ath5k with this patch for 3-4 months in different
environments (indoor/outdoor, hot/cold, mips32/intel) - it works fine.

Signed-off-by: Nikiforov Pavel <bitbucket...@gmail.com>
---

diff -ruN a/drivers/net/wireless/ath/ath5k/phy.c
b/drivers/net/wireless/ath/ath5k/phy.c
--- a/drivers/net/wireless/ath/ath5k/phy.c      2009-09-04
08:33:07.000000000 +0400
+++ b/drivers/net/wireless/ath/ath5k/phy.c      2009-09-04
12:09:24.000000000 +0400
@@ -1325,10 +1325,10 @@
        q_coffd = q_pwr >> 7;

        /* No correction */
-       if (i_coffd == 0 || q_coffd == 0)
+       if (i_coffd == 0 || q_coffd < 2)
                goto done;

-       i_coff = ((-iq_corr) / i_coffd) & 0x3f;
+       i_coff = (-iq_corr) / i_coffd;

        /* Boundary check */
        if (i_coff > 31)
@@ -1336,7 +1336,7 @@
        if (i_coff < -32)
                i_coff = -32;

-       q_coff = (((s32)i_pwr / q_coffd) - 128) & 0x1f;
+       q_coff = (((s32)i_pwr / q_coffd) - 128);

        /* Boundary check */
        if (q_coff > 15)
@@ -1346,7 +1346,7 @@

        /* Commit new I/Q value */
        AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE |
-               ((u32)q_coff) | ((u32)i_coff << AR5K_PHY_IQ_CORR_Q_I_COFF_S));
+               (((u32)q_coff)&0x1f) | ((((u32)i_coff)&0x3f) <<
AR5K_PHY_IQ_CORR_Q_I_COFF_S));

        /* Re-enable calibration -if we don't we'll commit
         * the same values again and again */
_______________________________________________
ath5k-devel mailing list
ath5k-devel@lists.ath5k.org
https://lists.ath5k.org/mailman/listinfo/ath5k-devel

Reply via email to