Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a54be5d4 authored by Forrest Zhang's avatar Forrest Zhang Committed by John W. Linville
Browse files

ath5k: fix exp off-by-one when computing OFDM delta slope



Commit e8f055f0 ("ath5k: Update reset code") subtly changed the
code that computes floating point values for the PHY3_TIMING register
such that the exponent is off by a decimal point, which can cause
problems with OFDM channel operation.

get_bitmask_order() actually returns the highest bit set plus one,
whereas the previous code wanted the highest bit set.  Instead, use
ilog2 which is what this code is really calculating.  Also check
coef_scaled to handle the (invalid) case where we need log2(0).

Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 88f16db7
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@
\*****************************/
\*****************************/


#include <linux/pci.h> 		/* To determine if a card is pci-e */
#include <linux/pci.h> 		/* To determine if a card is pci-e */
#include <linux/bitops.h>	/* For get_bitmask_order */
#include <linux/log2.h>
#include "ath5k.h"
#include "ath5k.h"
#include "reg.h"
#include "reg.h"
#include "base.h"
#include "base.h"
@@ -69,10 +69,10 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,


	/* Get exponent
	/* Get exponent
	 * ALGO: coef_exp = 14 - highest set bit position */
	 * ALGO: coef_exp = 14 - highest set bit position */
	coef_exp = get_bitmask_order(coef_scaled);
	coef_exp = ilog2(coef_scaled);


	/* Doesn't make sense if it's zero*/
	/* Doesn't make sense if it's zero*/
	if (!coef_exp)
	if (!coef_scaled || !coef_exp)
		return -EINVAL;
		return -EINVAL;


	/* Note: we've shifted coef_scaled by 24 */
	/* Note: we've shifted coef_scaled by 24 */