diff options
author | Juuso Oikarinen <juuso.oikarinen@nokia.com> | 2010-02-22 01:38:39 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-03-09 15:03:04 -0500 |
commit | 5c9417f1656b0f415f4be5a7cd7195ecadd7dd1a (patch) | |
tree | c512af2adfa5994cc024ff537630b74adff99521 /drivers/net/wireless/wl12xx | |
parent | ac5e1e39c1eeaaff7e6f03bf7cf7a444b42fbc23 (diff) |
wl1271: Clean up firmware block allocation calculation
This patch simplifies the required block count calculation. Though it
introduces a division operator, it greatly simplifies the formula.
Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Reviewed-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_tx.c | 10 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_tx.h | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_tx.c b/drivers/net/wireless/wl12xx/wl1271_tx.c index a32d3014781d..d3ed63e92cf4 100644 --- a/drivers/net/wireless/wl12xx/wl1271_tx.c +++ b/drivers/net/wireless/wl12xx/wl1271_tx.c | |||
@@ -46,7 +46,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra) | |||
46 | { | 46 | { |
47 | struct wl1271_tx_hw_descr *desc; | 47 | struct wl1271_tx_hw_descr *desc; |
48 | u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; | 48 | u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; |
49 | u32 total_blocks, excluded; | 49 | u32 total_blocks; |
50 | int id, ret = -EBUSY; | 50 | int id, ret = -EBUSY; |
51 | 51 | ||
52 | /* allocate free identifier for the packet */ | 52 | /* allocate free identifier for the packet */ |
@@ -56,12 +56,8 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra) | |||
56 | 56 | ||
57 | /* approximate the number of blocks required for this packet | 57 | /* approximate the number of blocks required for this packet |
58 | in the firmware */ | 58 | in the firmware */ |
59 | /* FIXME: try to figure out what is done here and make it cleaner */ | 59 | total_blocks = total_len + TX_HW_BLOCK_SIZE - 1; |
60 | total_blocks = (total_len + 20) >> TX_HW_BLOCK_SHIFT_DIV; | 60 | total_blocks = total_blocks / TX_HW_BLOCK_SIZE + TX_HW_BLOCK_SPARE; |
61 | excluded = (total_blocks << 2) + ((total_len + 20) & 0xff) + 34; | ||
62 | total_blocks += (excluded > 252) ? 2 : 1; | ||
63 | total_blocks += TX_HW_BLOCK_SPARE; | ||
64 | |||
65 | if (total_blocks <= wl->tx_blocks_available) { | 61 | if (total_blocks <= wl->tx_blocks_available) { |
66 | desc = (struct wl1271_tx_hw_descr *)skb_push( | 62 | desc = (struct wl1271_tx_hw_descr *)skb_push( |
67 | skb, total_len - skb->len); | 63 | skb, total_len - skb->len); |
diff --git a/drivers/net/wireless/wl12xx/wl1271_tx.h b/drivers/net/wireless/wl12xx/wl1271_tx.h index ca92bd811292..8b9f6b4f5652 100644 --- a/drivers/net/wireless/wl12xx/wl1271_tx.h +++ b/drivers/net/wireless/wl12xx/wl1271_tx.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #define __WL1271_TX_H__ | 26 | #define __WL1271_TX_H__ |
27 | 27 | ||
28 | #define TX_HW_BLOCK_SPARE 2 | 28 | #define TX_HW_BLOCK_SPARE 2 |
29 | #define TX_HW_BLOCK_SHIFT_DIV 8 | 29 | #define TX_HW_BLOCK_SIZE 252 |
30 | 30 | ||
31 | #define TX_HW_MGMT_PKT_LIFETIME_TU 2000 | 31 | #define TX_HW_MGMT_PKT_LIFETIME_TU 2000 |
32 | /* The chipset reference driver states, that the "aid" value 1 | 32 | /* The chipset reference driver states, that the "aid" value 1 |