* [PATCH] carl9170: Use the bitmap API when applicable
@ 2021-12-01 22:05 Christophe JAILLET
2021-12-03 7:57 ` Christian Lamparter
2021-12-08 8:36 ` Kalle Valo
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-12-01 22:05 UTC (permalink / raw)
To: chunkeey, kvalo, davem, kuba
Cc: linux-wireless, netdev, linux-kernel, kernel-janitors,
Christophe JAILLET
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 <christophe.jaillet@wanadoo.fr>
---
All uses of 'mem_bitmap' in 'carl9170/debug.c', 'carl9170/main.c' and
'carl9170/tx.c' are consistent with a 'ar->fw.mem_blocks' bits long bitmap.
So the smaller memory allocation of this patch looks correct to me.
... but review with care :)
---
drivers/net/wireless/ath/carl9170/main.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index cca3b086aa70..49f7ee1c912b 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -307,8 +307,7 @@ static void carl9170_zap_queues(struct ar9170 *ar)
for (i = 0; i < ar->hw->queues; i++)
ar->tx_stats[i].limit = CARL9170_NUM_TX_LIMIT_HARD;
- for (i = 0; i < DIV_ROUND_UP(ar->fw.mem_blocks, BITS_PER_LONG); i++)
- ar->mem_bitmap[i] = 0;
+ bitmap_zero(ar->mem_bitmap, ar->fw.mem_blocks);
rcu_read_lock();
list_for_each_entry_rcu(cvif, &ar->vif_list, list) {
@@ -1968,9 +1967,7 @@ int carl9170_register(struct ar9170 *ar)
if (WARN_ON(ar->mem_bitmap))
return -EINVAL;
- ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG),
- sizeof(unsigned long),
- GFP_KERNEL);
+ ar->mem_bitmap = bitmap_zalloc(ar->fw.mem_blocks, GFP_KERNEL);
if (!ar->mem_bitmap)
return -ENOMEM;
@@ -2085,7 +2082,7 @@ void carl9170_free(struct ar9170 *ar)
kfree_skb(ar->rx_failover);
ar->rx_failover = NULL;
- kfree(ar->mem_bitmap);
+ bitmap_free(ar->mem_bitmap);
ar->mem_bitmap = NULL;
kfree(ar->survey);
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] carl9170: Use the bitmap API when applicable
2021-12-01 22:05 [PATCH] carl9170: Use the bitmap API when applicable Christophe JAILLET
@ 2021-12-03 7:57 ` Christian Lamparter
2021-12-08 8:36 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Christian Lamparter @ 2021-12-03 7:57 UTC (permalink / raw)
To: Christophe JAILLET, chunkeey, kvalo, davem, kuba
Cc: linux-wireless, netdev, linux-kernel, kernel-janitors
On 01/12/2021 23:05, Christophe JAILLET wrote:
> 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 <christophe.jaillet@wanadoo.fr>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] carl9170: Use the bitmap API when applicable
2021-12-01 22:05 [PATCH] carl9170: Use the bitmap API when applicable Christophe JAILLET
2021-12-03 7:57 ` Christian Lamparter
@ 2021-12-08 8:36 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2021-12-08 8:36 UTC (permalink / raw)
To: Christophe JAILLET
Cc: chunkeey, kvalo, davem, kuba, linux-wireless, netdev,
linux-kernel, kernel-janitors, Christophe JAILLET
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> 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 <christophe.jaillet@wanadoo.fr>
> Acked-by: Christian Lamparter <chunkeey@gmail.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Patch applied to ath-next branch of ath.git, thanks.
6273c97296a8 carl9170: Use the bitmap API when applicable
--
https://patchwork.kernel.org/project/linux-wireless/patch/1fe18fb73f71d855043c40c83865ad539f326478.1638396221.git.christophe.jaillet@wanadoo.fr/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-08 8:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 22:05 [PATCH] carl9170: Use the bitmap API when applicable Christophe JAILLET
2021-12-03 7:57 ` Christian Lamparter
2021-12-08 8:36 ` Kalle Valo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.