linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
	Don Brace <don.brace@pmcs.com>,
	iss_storagedev@hp.com
Subject: [PATCH] cpqarray: simplify bitops usages
Date: Sat, 14 Mar 2015 10:12:54 +0900	[thread overview]
Message-ID: <1426295577-10836-2-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1426295577-10836-1-git-send-email-akinobu.mita@gmail.com>

Remove unnecessary adjustment for bit number and address of bitmask.
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
---
 drivers/block/cpqarray.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 2b94403..34dde22 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -422,8 +422,8 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
 	hba[i]->cmd_pool = pci_alloc_consistent(
 		hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
 		&(hba[i]->cmd_pool_dhandle));
-	hba[i]->cmd_pool_bits = kcalloc(
-		DIV_ROUND_UP(NR_CMDS, BITS_PER_LONG), sizeof(unsigned long),
+	hba[i]->cmd_pool_bits = kcalloc(BITS_TO_LONGS(NR_CMDS),
+		sizeof(unsigned long),
 		GFP_KERNEL);
 
 	if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool)
@@ -1373,7 +1373,7 @@ static cmdlist_t * cmd_alloc(ctlr_info_t *h, int get_from_pool)
 			i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS);
 			if (i == NR_CMDS)
 				return NULL;
-		} while(test_and_set_bit(i&(BITS_PER_LONG-1), h->cmd_pool_bits+(i/BITS_PER_LONG)) != 0);
+		} while (test_and_set_bit(i, h->cmd_pool_bits) != 0);
 		c = h->cmd_pool + i;
 		cmd_dhandle = h->cmd_pool_dhandle + i*sizeof(cmdlist_t);
 		h->nr_allocs++;
@@ -1393,7 +1393,7 @@ static void cmd_free(ctlr_info_t *h, cmdlist_t *c, int got_from_pool)
 			c->busaddr);
 	} else {
 		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);
 		h->nr_frees++;
 	}
 }
-- 
1.9.1


  reply	other threads:[~2015-03-14  1:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-14  1:12 [PATCH] hpsa: cleanup bitops usage Akinobu Mita
2015-03-14  1:12 ` Akinobu Mita [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426295577-10836-2-git-send-email-akinobu.mita@gmail.com \
    --to=akinobu.mita@gmail.com \
    --cc=don.brace@pmcs.com \
    --cc=iss_storagedev@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).