2022-07-20 18:20:36

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps

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

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/scsi/hpsa.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a47bcce3c9c7..0612ca681200 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8030,7 +8030,7 @@ static int hpsa_init_reset_devices(struct pci_dev *pdev, u32 board_id)

static void hpsa_free_cmd_pool(struct ctlr_info *h)
{
- kfree(h->cmd_pool_bits);
+ bitmap_free(h->cmd_pool_bits);
h->cmd_pool_bits = NULL;
if (h->cmd_pool) {
dma_free_coherent(&h->pdev->dev,
@@ -8052,9 +8052,7 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h)

static int hpsa_alloc_cmd_pool(struct ctlr_info *h)
{
- h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG),
- sizeof(unsigned long),
- GFP_KERNEL);
+ h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL);
h->cmd_pool = dma_alloc_coherent(&h->pdev->dev,
h->nr_cmds * sizeof(*h->cmd_pool),
&h->cmd_pool_dhandle, GFP_KERNEL);
--
2.34.1


2022-08-02 21:02:04

by Don Brace

[permalink] [raw]
Subject: Re: [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps


From: Christophe JAILLET <[email protected]>
Sent: Wednesday, July 20, 2022 1:13 PM
To: Don Brace - C33706 <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Christophe JAILLET <[email protected]>; storagedev <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps
?

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

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <[email protected]>

Acked-by: Don Brace <[email protected]>
Tested-by: Don Brace <[email protected]>

We normally do not make changes to this driver anymore. But the change looks good.
Thanks for your patch. No cover letter to Ack both at the same time.

Don
---
?drivers/scsi/hpsa.c | 6 ++----
?1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a47bcce3c9c7..0612ca681200 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8030,7 +8030,7 @@ static int hpsa_init_reset_devices(struct pci_dev *pdev, u32 board_id)

?static void hpsa_free_cmd_pool(struct ctlr_info *h)
?{
-?????? kfree(h->cmd_pool_bits);
+?????? bitmap_free(h->cmd_pool_bits);
??????? h->cmd_pool_bits = NULL;
??????? if (h->cmd_pool) {
??????????????? dma_free_coherent(&h->pdev->dev,
@@ -8052,9 +8052,7 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h)

?static int hpsa_alloc_cmd_pool(struct ctlr_info *h)
?{
-?????? h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG),
-????????????????????????????????? sizeof(unsigned long),
-????????????????????????????????? GFP_KERNEL);
+?????? h->cmd_pool_bits = bitmap_zalloc(h->nr_cmds, GFP_KERNEL);
??????? h->cmd_pool = dma_alloc_coherent(&h->pdev->dev,
??????????????????? h->nr_cmds * sizeof(*h->cmd_pool),
??????????????????? &h->cmd_pool_dhandle, GFP_KERNEL);
--
2.34.1

2022-09-01 05:40:50

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps


Christophe,

> Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

Applied 1+2 to 6.1/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering