diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-10-12 10:08:01 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-10-15 15:48:44 -0400 |
commit | e49f913750bb8745085cc4c547912c330cd3eacb (patch) | |
tree | 989230a1b47ada33ad2c0e8407456e2ec354f667 /drivers/net/wireless/ath/ath9k | |
parent | 898c914a0871ea7e5557b77156d4358c0f15d98a (diff) |
ath9k_hw: fix division by zero in the ANI monitor code
The commit "ath9k_hw: remove code duplication in phy error counter handling"
split off some duplicate code into a separate function, but did not have a
return code for aborting ANI processing based on counter values.
This introduced a divide by zero issue.
This patch adds the missing return code check in ath9k_hw_ani_monitor
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ani.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c index 3aa8fb1ad77f..9297f574b71c 100644 --- a/drivers/net/wireless/ath/ath9k/ani.c +++ b/drivers/net/wireless/ath/ath9k/ani.c | |||
@@ -633,7 +633,7 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning) | |||
633 | REGWRITE_BUFFER_FLUSH(ah); | 633 | REGWRITE_BUFFER_FLUSH(ah); |
634 | } | 634 | } |
635 | 635 | ||
636 | static void ath9k_hw_ani_read_counters(struct ath_hw *ah) | 636 | static bool ath9k_hw_ani_read_counters(struct ath_hw *ah) |
637 | { | 637 | { |
638 | struct ath_common *common = ath9k_hw_common(ah); | 638 | struct ath_common *common = ath9k_hw_common(ah); |
639 | struct ar5416AniState *aniState = &ah->curchan->ani; | 639 | struct ar5416AniState *aniState = &ah->curchan->ani; |
@@ -646,10 +646,10 @@ static void ath9k_hw_ani_read_counters(struct ath_hw *ah) | |||
646 | ath_hw_cycle_counters_update(common); | 646 | ath_hw_cycle_counters_update(common); |
647 | listenTime = ath_hw_get_listen_time(common); | 647 | listenTime = ath_hw_get_listen_time(common); |
648 | 648 | ||
649 | if (listenTime < 0) { | 649 | if (listenTime <= 0) { |
650 | ah->stats.ast_ani_lneg++; | 650 | ah->stats.ast_ani_lneg++; |
651 | ath9k_ani_restart(ah); | 651 | ath9k_ani_restart(ah); |
652 | return; | 652 | return false; |
653 | } | 653 | } |
654 | 654 | ||
655 | if (!use_new_ani(ah)) { | 655 | if (!use_new_ani(ah)) { |
@@ -683,7 +683,7 @@ static void ath9k_hw_ani_read_counters(struct ath_hw *ah) | |||
683 | REG_WRITE(ah, AR_PHY_ERR_MASK_2, | 683 | REG_WRITE(ah, AR_PHY_ERR_MASK_2, |
684 | AR_PHY_ERR_CCK_TIMING); | 684 | AR_PHY_ERR_CCK_TIMING); |
685 | } | 685 | } |
686 | return; | 686 | return false; |
687 | } | 687 | } |
688 | 688 | ||
689 | ofdmPhyErrCnt = phyCnt1 - ofdm_base; | 689 | ofdmPhyErrCnt = phyCnt1 - ofdm_base; |
@@ -695,7 +695,7 @@ static void ath9k_hw_ani_read_counters(struct ath_hw *ah) | |||
695 | ah->stats.ast_ani_cckerrs += | 695 | ah->stats.ast_ani_cckerrs += |
696 | cckPhyErrCnt - aniState->cckPhyErrCount; | 696 | cckPhyErrCnt - aniState->cckPhyErrCount; |
697 | aniState->cckPhyErrCount = cckPhyErrCnt; | 697 | aniState->cckPhyErrCount = cckPhyErrCnt; |
698 | 698 | return true; | |
699 | } | 699 | } |
700 | 700 | ||
701 | void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan) | 701 | void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan) |
@@ -711,7 +711,8 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan) | |||
711 | if (WARN_ON(!aniState)) | 711 | if (WARN_ON(!aniState)) |
712 | return; | 712 | return; |
713 | 713 | ||
714 | ath9k_hw_ani_read_counters(ah); | 714 | if (!ath9k_hw_ani_read_counters(ah)) |
715 | return; | ||
715 | 716 | ||
716 | ofdmPhyErrRate = aniState->ofdmPhyErrCount * 1000 / | 717 | ofdmPhyErrRate = aniState->ofdmPhyErrCount * 1000 / |
717 | aniState->listenTime; | 718 | aniState->listenTime; |