linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] RDMA/erdma: Use the bitmap API to allocate bitmaps
@ 2022-07-08 17:37 Christophe JAILLET
  2022-07-08 17:37 ` [PATCH 2/2] RDMA/erdma: Use the non-atomic bitmap API when applicable Christophe JAILLET
  2022-07-11  7:34 ` [PATCH 1/2] RDMA/erdma: Use the bitmap API to allocate bitmaps Cheng Xu
  0 siblings, 2 replies; 13+ messages in thread
From: Christophe JAILLET @ 2022-07-08 17:37 UTC (permalink / raw)
  To: Cheng Xu, Kai Shen, Jason Gunthorpe, Leon Romanovsky
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-rdma

Use [devm_]bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/infiniband/hw/erdma/erdma_cmdq.c | 7 +++----
 drivers/infiniband/hw/erdma/erdma_main.c | 9 ++++-----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/erdma/erdma_cmdq.c b/drivers/infiniband/hw/erdma/erdma_cmdq.c
index 0cf5032d4b78..0489838d9717 100644
--- a/drivers/infiniband/hw/erdma/erdma_cmdq.c
+++ b/drivers/infiniband/hw/erdma/erdma_cmdq.c
@@ -78,10 +78,9 @@ static int erdma_cmdq_wait_res_init(struct erdma_dev *dev,
 		return -ENOMEM;
 
 	spin_lock_init(&cmdq->lock);
-	cmdq->comp_wait_bitmap =
-		devm_kcalloc(&dev->pdev->dev,
-			     BITS_TO_LONGS(cmdq->max_outstandings),
-			     sizeof(unsigned long), GFP_KERNEL);
+	cmdq->comp_wait_bitmap = devm_bitmap_zalloc(&dev->pdev->dev,
+						    cmdq->max_outstandings,
+						    GFP_KERNEL);
 	if (!cmdq->comp_wait_bitmap) {
 		devm_kfree(&dev->pdev->dev, cmdq->wait_pool);
 		return -ENOMEM;
diff --git a/drivers/infiniband/hw/erdma/erdma_main.c b/drivers/infiniband/hw/erdma/erdma_main.c
index 27484bea51d9..7e1e27acb404 100644
--- a/drivers/infiniband/hw/erdma/erdma_main.c
+++ b/drivers/infiniband/hw/erdma/erdma_main.c
@@ -423,9 +423,8 @@ static int erdma_res_cb_init(struct erdma_dev *dev)
 	for (i = 0; i < ERDMA_RES_CNT; i++) {
 		dev->res_cb[i].next_alloc_idx = 1;
 		spin_lock_init(&dev->res_cb[i].lock);
-		dev->res_cb[i].bitmap =
-			kcalloc(BITS_TO_LONGS(dev->res_cb[i].max_cap),
-				sizeof(unsigned long), GFP_KERNEL);
+		dev->res_cb[i].bitmap = bitmap_zalloc(dev->res_cb[i].max_cap,
+						      GFP_KERNEL);
 		/* We will free the memory in erdma_res_cb_free */
 		if (!dev->res_cb[i].bitmap)
 			goto err;
@@ -435,7 +434,7 @@ static int erdma_res_cb_init(struct erdma_dev *dev)
 
 err:
 	for (j = 0; j < i; j++)
-		kfree(dev->res_cb[j].bitmap);
+		bitmap_free(dev->res_cb[j].bitmap);
 
 	return -ENOMEM;
 }
@@ -445,7 +444,7 @@ static void erdma_res_cb_free(struct erdma_dev *dev)
 	int i;
 
 	for (i = 0; i < ERDMA_RES_CNT; i++)
-		kfree(dev->res_cb[i].bitmap);
+		bitmap_free(dev->res_cb[i].bitmap);
 }
 
 static const struct ib_device_ops erdma_device_ops = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-07-21  9:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 17:37 [PATCH 1/2] RDMA/erdma: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-08 17:37 ` [PATCH 2/2] RDMA/erdma: Use the non-atomic bitmap API when applicable Christophe JAILLET
2022-07-11  7:34 ` [PATCH 1/2] RDMA/erdma: Use the bitmap API to allocate bitmaps Cheng Xu
2022-07-12  9:01   ` Dan Carpenter
2022-07-12  9:56     ` Cheng Xu
2022-07-19 12:54     ` Jason Gunthorpe
2022-07-19 13:01       ` Dan Carpenter
2022-07-19 15:36         ` Christophe JAILLET
2022-07-19 15:39           ` Jason Gunthorpe
2022-07-20  1:58           ` Cheng Xu
2022-07-21  7:31             ` Leon Romanovsky
2022-07-21  9:14               ` Cheng Xu
2022-07-21  7:27           ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).