From patchwork Sat Mar 14 01:12:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 6010461 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C36E9F318 for ; Sat, 14 Mar 2015 01:14:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47441202BE for ; Sat, 14 Mar 2015 01:14:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A0E7202B4 for ; Sat, 14 Mar 2015 01:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750781AbbCNBNT (ORCPT ); Fri, 13 Mar 2015 21:13:19 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36608 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753840AbbCNBNS (ORCPT ); Fri, 13 Mar 2015 21:13:18 -0400 Received: by pdbcz9 with SMTP id cz9so1289566pdb.3; Fri, 13 Mar 2015 18:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=AK/RUOUazSkPnO84sl6wGvjCoHhcQ7/k8+LWfWhM5aI=; b=U+c1Kfw1iRI/pzCxfeCY6uCMnCUfQVRtcuw2ULFMCQD4l3yMmK4x2UgKRnHpvn7gNC 0S2OQcq/ud7BxlsoGJ8dZxoQlPpytXHYM0PHAYdoiSMYdiHFu3vtpjiaayrbtKhh6MLe gz6Q8TqhixHa4WaKNqNbCoyKmwlTFBj/K7BfVOU2wIiGd1eX2qFvqgalkSwRPPbvsIR4 Fiq5lxQguwvlV3arkEvCkxLh5w7RxECzCIWw+dxBwX7aRrIn8wqUI6IxItjQPD2n/Y57 NCh10F3dwVXw+ZxjeSL8Ohg2nPvzo0yp0g9Fs0P008HQsMl4X2i1dvCUUColFaBpnVWA bBpA== X-Received: by 10.66.221.8 with SMTP id qa8mr87217573pac.62.1426295598250; Fri, 13 Mar 2015 18:13:18 -0700 (PDT) Received: from localhost.localdomain (KD106168100169.ppp-bb.dion.ne.jp. [106.168.100.169]) by mx.google.com with ESMTPSA id kd9sm5460429pab.0.2015.03.13.18.13.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Mar 2015 18:13:16 -0700 (PDT) From: Akinobu Mita To: linux-kernel@vger.kernel.org Cc: Akinobu Mita , Don Brace , iss_storagedev@hp.com, storagedev@pmcs.com, "James E.J. Bottomley" , linux-scsi@vger.kernel.org Subject: [PATCH] hpsa: cleanup bitops usage Date: Sat, 14 Mar 2015 10:12:53 +0900 Message-Id: <1426295577-10836-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Don Brace Cc: iss_storagedev@hp.com Cc: storagedev@pmcs.com Cc: "James E.J. Bottomley" 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),