All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps
@ 2022-07-20 18:13 Christophe JAILLET
  2022-07-20 18:14 ` [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters Christophe JAILLET
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christophe JAILLET @ 2022-07-20 18:13 UTC (permalink / raw)
  To: Don Brace, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, storagedev,
	linux-scsi

Use 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/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


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

* [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters
  2022-07-20 18:13 [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Christophe JAILLET
@ 2022-07-20 18:14 ` Christophe JAILLET
  2022-08-02 20:56   ` Don.Brace
  2022-08-02 20:55 ` [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Don.Brace
  2022-09-01  4:45 ` Martin K. Petersen
  2 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2022-07-20 18:14 UTC (permalink / raw)
  To: Don Brace, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, storagedev,
	linux-scsi

{clear|set}_bit() can take an almost arbitrarily large bit number, so there
is no need to manually compute addresses. This is just redundant.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 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 0612ca681200..f8e832b1bc46 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -6233,8 +6233,7 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
 			offset = (i + 1) % HPSA_NRESERVED_CMDS;
 			continue;
 		}
-		set_bit(i & (BITS_PER_LONG - 1),
-			h->cmd_pool_bits + (i / BITS_PER_LONG));
+		set_bit(i, h->cmd_pool_bits);
 		break; /* it's ours now. */
 	}
 	hpsa_cmd_partial_init(h, i, c);
@@ -6261,8 +6260,7 @@ static void cmd_free(struct ctlr_info *h, struct CommandList *c)
 		int i;
 
 		i = c - h->cmd_pool;
-		clear_bit(i & (BITS_PER_LONG - 1),
-			  h->cmd_pool_bits + (i / BITS_PER_LONG));
+		clear_bit(i, h->cmd_pool_bits);
 	}
 }
 
-- 
2.34.1


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

* Re: [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps
  2022-07-20 18:13 [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Christophe JAILLET
  2022-07-20 18:14 ` [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters Christophe JAILLET
@ 2022-08-02 20:55 ` Don.Brace
  2022-09-01  4:45 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Don.Brace @ 2022-08-02 20:55 UTC (permalink / raw)
  To: christophe.jaillet, jejb, martin.petersen
  Cc: linux-kernel, kernel-janitors, storagedev, linux-scsi


From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Wednesday, July 20, 2022 1:13 PM
To: Don Brace - C33706 <Don.Brace@microchip.com>; James E.J. Bottomley <jejb@linux.ibm.com>; Martin K. Petersen <martin.petersen@oracle.com>
Cc: linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org <kernel-janitors@vger.kernel.org>; Christophe JAILLET <christophe.jaillet@wanadoo.fr>; storagedev <storagedev@microchip.com>; linux-scsi@vger.kernel.org <linux-scsi@vger.kernel.org>
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 <christophe.jaillet@wanadoo.fr>

Acked-by: Don Brace <don.brace@microchip.com>
Tested-by: Don Brace <don.brace@microchip.com>

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

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

* Re: [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters
  2022-07-20 18:14 ` [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters Christophe JAILLET
@ 2022-08-02 20:56   ` Don.Brace
  0 siblings, 0 replies; 5+ messages in thread
From: Don.Brace @ 2022-08-02 20:56 UTC (permalink / raw)
  To: christophe.jaillet, jejb, martin.petersen
  Cc: linux-kernel, kernel-janitors, storagedev, linux-scsi


From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Wednesday, July 20, 2022 1:14 PM
To: Don Brace - C33706 <Don.Brace@microchip.com>; James E.J. Bottomley <jejb@linux.ibm.com>; Martin K. Petersen <martin.petersen@oracle.com>
Cc: linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org <kernel-janitors@vger.kernel.org>; Christophe JAILLET <christophe.jaillet@wanadoo.fr>; storagedev <storagedev@microchip.com>; linux-scsi@vger.kernel.org <linux-scsi@vger.kernel.org>
Subject: [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters 
 
[Some people who received this message don't often get email from christophe.jaillet@wanadoo.fr. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

{clear|set}_bit() can take an almost arbitrarily large bit number, so there
is no need to manually compute addresses. This is just redundant.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Don Brace <don.brace@microchip.com>
Tested-by: Don Brace <don.brace@microchip.com>

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 0612ca681200..f8e832b1bc46 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -6233,8 +6233,7 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
                        offset = (i + 1) % HPSA_NRESERVED_CMDS;
                        continue;
                }
-               set_bit(i & (BITS_PER_LONG - 1),
-                       h->cmd_pool_bits + (i / BITS_PER_LONG));
+               set_bit(i, h->cmd_pool_bits);
                break; /* it's ours now. */
        }
        hpsa_cmd_partial_init(h, i, c);
@@ -6261,8 +6260,7 @@ static void cmd_free(struct ctlr_info *h, struct CommandList *c)
                int i;

                i = c - h->cmd_pool;
-               clear_bit(i & (BITS_PER_LONG - 1),
-                         h->cmd_pool_bits + (i / BITS_PER_LONG));
+               clear_bit(i, h->cmd_pool_bits);
        }
 }

--
2.34.1

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

* Re: [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps
  2022-07-20 18:13 [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Christophe JAILLET
  2022-07-20 18:14 ` [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters Christophe JAILLET
  2022-08-02 20:55 ` [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Don.Brace
@ 2022-09-01  4:45 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2022-09-01  4:45 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Don Brace, James E.J. Bottomley, Martin K. Petersen,
	linux-kernel, kernel-janitors, storagedev, linux-scsi


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

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

end of thread, other threads:[~2022-09-01  4:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 18:13 [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-20 18:14 ` [PATCH 2/2] scsi: hpsa: Simplify {clear|set}_bit() parameters Christophe JAILLET
2022-08-02 20:56   ` Don.Brace
2022-08-02 20:55 ` [PATCH 1/2] scsi: hpsa: Use the bitmap API to allocate bitmaps Don.Brace
2022-09-01  4:45 ` Martin K. Petersen

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.