Skip to content

Commit 6273c97

Browse files
tititiou36kvalo
authored andcommitted
carl9170: Use the bitmap API when applicable
Use 'bitmap_zalloc()' to simplify code, improve the semantic and avoid some open-coded arithmetic in allocator arguments. Note, that this 'bitmap_zalloc()' divides by BITS_PER_LONG the amount of memory allocated. The 'roundup()' used to computed the number of needed long should have been a DIV_ROUND_UP. Also change the corresponding 'kfree()' into 'bitmap_free()' to keep consistency. Use 'bitmap_zero()' to avoid hand writing it. Signed-off-by: Christophe JAILLET <[email protected]> Acked-by: Christian Lamparter <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/1fe18fb73f71d855043c40c83865ad539f326478.1638396221.git.christophe.jaillet@wanadoo.fr
1 parent 09cab43 commit 6273c97

File tree

1 file changed

+3
-6
lines changed
  • drivers/net/wireless/ath/carl9170

1 file changed

+3
-6
lines changed

drivers/net/wireless/ath/carl9170/main.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ static void carl9170_zap_queues(struct ar9170 *ar)
307307
for (i = 0; i < ar->hw->queues; i++)
308308
ar->tx_stats[i].limit = CARL9170_NUM_TX_LIMIT_HARD;
309309

310-
for (i = 0; i < DIV_ROUND_UP(ar->fw.mem_blocks, BITS_PER_LONG); i++)
311-
ar->mem_bitmap[i] = 0;
310+
bitmap_zero(ar->mem_bitmap, ar->fw.mem_blocks);
312311

313312
rcu_read_lock();
314313
list_for_each_entry_rcu(cvif, &ar->vif_list, list) {
@@ -1968,9 +1967,7 @@ int carl9170_register(struct ar9170 *ar)
19681967
if (WARN_ON(ar->mem_bitmap))
19691968
return -EINVAL;
19701969

1971-
ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG),
1972-
sizeof(unsigned long),
1973-
GFP_KERNEL);
1970+
ar->mem_bitmap = bitmap_zalloc(ar->fw.mem_blocks, GFP_KERNEL);
19741971

19751972
if (!ar->mem_bitmap)
19761973
return -ENOMEM;
@@ -2085,7 +2082,7 @@ void carl9170_free(struct ar9170 *ar)
20852082
kfree_skb(ar->rx_failover);
20862083
ar->rx_failover = NULL;
20872084

2088-
kfree(ar->mem_bitmap);
2085+
bitmap_free(ar->mem_bitmap);
20892086
ar->mem_bitmap = NULL;
20902087

20912088
kfree(ar->survey);

0 commit comments

Comments
 (0)