From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755530AbbCNBNY (ORCPT ); Fri, 13 Mar 2015 21:13:24 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36650 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755372AbbCNBNV (ORCPT ); Fri, 13 Mar 2015 21:13:21 -0400 From: Akinobu Mita To: linux-kernel@vger.kernel.org Cc: Akinobu Mita , Don Brace , iss_storagedev@hp.com Subject: [PATCH] cpqarray: simplify bitops usages Date: Sat, 14 Mar 2015 10:12:54 +0900 Message-Id: <1426295577-10836-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426295577-10836-1-git-send-email-akinobu.mita@gmail.com> References: <1426295577-10836-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove unnecessary adjustment for bit number and address of bitmask. This change just simplifies the code a bit. Signed-off-by: Akinobu Mita Cc: Don Brace 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