All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hpsa: cleanup bitops usage
@ 2015-03-14  1:12 Akinobu Mita
  2015-03-14  1:12 ` [PATCH] cpqarray: simplify bitops usages Akinobu Mita
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Akinobu Mita @ 2015-03-14  1:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Akinobu Mita, Don Brace, iss_storagedev, storagedev,
	James E.J. Bottomley, linux-scsi

Remove unnecessary adjustment for bit number and address of bitmask,
and use BITS_TO_LONGS macro to calculate bitmap size.  This change
just simplifies the code a bit.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Don Brace <don.brace@pmcs.com>
Cc: iss_storagedev@hp.com
Cc: storagedev@pmcs.com
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/hpsa.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a1cfbd3..73a282b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4697,8 +4697,7 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
 			offset = (i + 1) % h->nr_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. */
 	}
 	h->last_allocation = i; /* benignly racy */
@@ -4729,8 +4728,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);
 	}
 }
 
@@ -6410,8 +6408,7 @@ out_disable:
 
 static int hpsa_allocate_cmd_pool(struct ctlr_info *h)
 {
-	h->cmd_pool_bits = kzalloc(
-		DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) *
+	h->cmd_pool_bits = kcalloc(BITS_TO_LONGS(h->nr_cmds),
 		sizeof(unsigned long), GFP_KERNEL);
 	h->cmd_pool = pci_alloc_consistent(h->pdev,
 		    h->nr_cmds * sizeof(*h->cmd_pool),
-- 
1.9.1


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

end of thread, other threads:[~2015-03-22  2:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-14  1:12 [PATCH] hpsa: cleanup bitops usage Akinobu Mita
2015-03-14  1:12 ` [PATCH] cpqarray: simplify bitops usages Akinobu Mita
2015-03-14  1:12 ` [PATCH] pktcdvd: convert char array to bitmap Akinobu Mita
2015-03-14  1:12 ` [PATCH] drbd: use bitmap_weight() Akinobu Mita
2015-03-20 15:14   ` [Drbd-dev] " Lars Ellenberg
2015-03-22  2:11     ` Akinobu Mita
2015-03-14  1:12 ` [PATCH] ia64: Use bitmap_weight Akinobu Mita
2015-03-14  1:12   ` Akinobu Mita

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.