aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/main.c
diff options
context:
space:
mode:
authorArik Nemtsov <arik@wizery.com>2011-08-14 06:17:34 -0400
committerLuciano Coelho <coelho@ti.com>2011-08-22 05:35:30 -0400
commitbdf91cfae66dd76a093c75cac8f6ada12fd21b83 (patch)
tree58f07c4eda2091cc51666093a9318de141e6b361 /drivers/net/wireless/wl12xx/main.c
parent742246f8bc16c3a1a556c68ca2fabca162d14c24 (diff)
wl12xx: handle wrap-around overflow in released Tx blocks FW counter
When the FW Tx released blocks counter wraps around, we should correct our calculation of released blocks. Otherwise we add a large negative figure to our driver freed blocks counter Signed-off-by: Arik Nemtsov <arik@wizery.com> Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/main.c')
-rw-r--r--drivers/net/wireless/wl12xx/main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 027b6742a15..0fa3a2281dd 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -834,8 +834,15 @@ static void wl12xx_fw_status(struct wl1271 *wl,
834 wl->tx_pkts_freed[i] = status->tx_released_pkts[i]; 834 wl->tx_pkts_freed[i] = status->tx_released_pkts[i];
835 } 835 }
836 836
837 freed_blocks = le32_to_cpu(status->total_released_blks) - 837 /* prevent wrap-around in total blocks counter */
838 wl->tx_blocks_freed; 838 if (likely(wl->tx_blocks_freed <=
839 le32_to_cpu(status->total_released_blks)))
840 freed_blocks = le32_to_cpu(status->total_released_blks) -
841 wl->tx_blocks_freed;
842 else
843 freed_blocks = 0x100000000LL - wl->tx_blocks_freed +
844 le32_to_cpu(status->total_released_blks);
845
839 wl->tx_blocks_freed = le32_to_cpu(status->total_released_blks); 846 wl->tx_blocks_freed = le32_to_cpu(status->total_released_blks);
840 847
841 wl->tx_allocated_blocks -= freed_blocks; 848 wl->tx_allocated_blocks -= freed_blocks;