Commit f86dbc9f authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Jason Gunthorpe

IB/hfi1: Use bitmap_zalloc() when applicable

Use 'bitmap_zalloc()' to simplify code, improve the semantic and avoid
some open-coded arithmetic in allocator arguments.

Also change the corresponding 'kfree()' into 'bitmap_free()' to keep
consistency.

Link: https://lore.kernel.org/r/d46c6bc1869b8869244fa71943d2cad4104b3668.1637869925.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 0c83da72
...@@ -161,9 +161,7 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, ...@@ -161,9 +161,7 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
if (!pq->reqs) if (!pq->reqs)
goto pq_reqs_nomem; goto pq_reqs_nomem;
pq->req_in_use = kcalloc(BITS_TO_LONGS(hfi1_sdma_comp_ring_size), pq->req_in_use = bitmap_zalloc(hfi1_sdma_comp_ring_size, GFP_KERNEL);
sizeof(*pq->req_in_use),
GFP_KERNEL);
if (!pq->req_in_use) if (!pq->req_in_use)
goto pq_reqs_no_in_use; goto pq_reqs_no_in_use;
...@@ -210,7 +208,7 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt, ...@@ -210,7 +208,7 @@ int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *uctxt,
cq_nomem: cq_nomem:
kmem_cache_destroy(pq->txreq_cache); kmem_cache_destroy(pq->txreq_cache);
pq_txreq_nomem: pq_txreq_nomem:
kfree(pq->req_in_use); bitmap_free(pq->req_in_use);
pq_reqs_no_in_use: pq_reqs_no_in_use:
kfree(pq->reqs); kfree(pq->reqs);
pq_reqs_nomem: pq_reqs_nomem:
...@@ -257,7 +255,7 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd, ...@@ -257,7 +255,7 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd,
pq->wait, pq->wait,
!atomic_read(&pq->n_reqs)); !atomic_read(&pq->n_reqs));
kfree(pq->reqs); kfree(pq->reqs);
kfree(pq->req_in_use); bitmap_free(pq->req_in_use);
kmem_cache_destroy(pq->txreq_cache); kmem_cache_destroy(pq->txreq_cache);
flush_pq_iowait(pq); flush_pq_iowait(pq);
kfree(pq); kfree(pq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment