Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp749660imw; Fri, 8 Jul 2022 11:00:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tmv2Z1uPulmNEGsX9A7TLKAUh+NbQMpv3aOPDEsTRKMMCUSHqyUDdu89vaL22gNiBjkw2+ X-Received: by 2002:a05:6402:3454:b0:43a:86c8:637 with SMTP id l20-20020a056402345400b0043a86c80637mr6332291edc.393.1657303254552; Fri, 08 Jul 2022 11:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657303254; cv=none; d=google.com; s=arc-20160816; b=XGL0c3TMPs/DzMLHl9eglmy61p6Ow5xZAmN44qwQtCGJhIgA0stMsXpJ/RmUMHovIb suvEt2yyZgzik6cdK/hvbWQB6+5IPpQA4kDsZaUqOVn/wVlrHiyVWuCuQMvn1l6J5Mye ZVmatVQ4HIsvAk6UYTahUKe4kEq4RxyMQv50votgP/YvQ68m4fa1BmIUf+6hf0VoLNY2 rtMAPvDf6KT/ahe3npdUHBWX5lQ3WhXYXlsLCy+eibkSXupnnFRZm2yHgndayTyEr0vk dc6crJ0JC5B3Os7c6uQsAHoTSVJkUX66aPcZzkXsN7d06w8khagfEMCSD1B2pVopszSQ NyIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nzVxv9g1KIDwgrPYRASWlMEAOsfu9YJu7mu+GK3cui8=; b=gyJ2zoPslixfO+sv9dzz8RwwCDgOJu3SLdM+4V4LZXz+GvBV90qtlQMQkn+EyAdWzz 6DkgTwtTtd2P0IPkx8wMg4mgb9FcK6aYIjPwr/69FvAQTVxd2R8FMpyUyBQMlSSSFEYa t+wBexr4KBh61nQcjRkMWIQP803J+h4VOJnyNjM7+xrv/KTV7VKGrQcv/BDpL5F9wUNM WY9hpAqg55oGSaCYXS2LhVD851qPT6FGYIeMzJnuWeY7yK+i5/pFBXm1SpcoMcaG57MI DA/GyGAIYNplR4r9CkasqMvuxSJ3G9/OeG/VOK269+4hNtebTieBQm1a37OT+A9lM0KL ECSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp15-20020a170906c14f00b006feb4cd0e23si10560578ejc.368.2022.07.08.11.00.27; Fri, 08 Jul 2022 11:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238875AbiGHRhW (ORCPT + 99 others); Fri, 8 Jul 2022 13:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238535AbiGHRhT (ORCPT ); Fri, 8 Jul 2022 13:37:19 -0400 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0568675AF for ; Fri, 8 Jul 2022 10:37:17 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 9rukoBmwMvNzH9ruko3RGi; Fri, 08 Jul 2022 19:37:16 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 08 Jul 2022 19:37:16 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Cheng Xu , Kai Shen , Jason Gunthorpe , Leon Romanovsky Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-rdma@vger.kernel.org Subject: [PATCH 1/2] RDMA/erdma: Use the bitmap API to allocate bitmaps Date: Fri, 8 Jul 2022 19:37:12 +0200 Message-Id: <2764b6e204b32ef8c198a5efaf6c6bc4119f7665.1657301795.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use [devm_]bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET --- drivers/infiniband/hw/erdma/erdma_cmdq.c | 7 +++---- drivers/infiniband/hw/erdma/erdma_main.c | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/erdma/erdma_cmdq.c b/drivers/infiniband/hw/erdma/erdma_cmdq.c index 0cf5032d4b78..0489838d9717 100644 --- a/drivers/infiniband/hw/erdma/erdma_cmdq.c +++ b/drivers/infiniband/hw/erdma/erdma_cmdq.c @@ -78,10 +78,9 @@ static int erdma_cmdq_wait_res_init(struct erdma_dev *dev, return -ENOMEM; spin_lock_init(&cmdq->lock); - cmdq->comp_wait_bitmap = - devm_kcalloc(&dev->pdev->dev, - BITS_TO_LONGS(cmdq->max_outstandings), - sizeof(unsigned long), GFP_KERNEL); + cmdq->comp_wait_bitmap = devm_bitmap_zalloc(&dev->pdev->dev, + cmdq->max_outstandings, + GFP_KERNEL); if (!cmdq->comp_wait_bitmap) { devm_kfree(&dev->pdev->dev, cmdq->wait_pool); return -ENOMEM; diff --git a/drivers/infiniband/hw/erdma/erdma_main.c b/drivers/infiniband/hw/erdma/erdma_main.c index 27484bea51d9..7e1e27acb404 100644 --- a/drivers/infiniband/hw/erdma/erdma_main.c +++ b/drivers/infiniband/hw/erdma/erdma_main.c @@ -423,9 +423,8 @@ static int erdma_res_cb_init(struct erdma_dev *dev) for (i = 0; i < ERDMA_RES_CNT; i++) { dev->res_cb[i].next_alloc_idx = 1; spin_lock_init(&dev->res_cb[i].lock); - dev->res_cb[i].bitmap = - kcalloc(BITS_TO_LONGS(dev->res_cb[i].max_cap), - sizeof(unsigned long), GFP_KERNEL); + dev->res_cb[i].bitmap = bitmap_zalloc(dev->res_cb[i].max_cap, + GFP_KERNEL); /* We will free the memory in erdma_res_cb_free */ if (!dev->res_cb[i].bitmap) goto err; @@ -435,7 +434,7 @@ static int erdma_res_cb_init(struct erdma_dev *dev) err: for (j = 0; j < i; j++) - kfree(dev->res_cb[j].bitmap); + bitmap_free(dev->res_cb[j].bitmap); return -ENOMEM; } @@ -445,7 +444,7 @@ static void erdma_res_cb_free(struct erdma_dev *dev) int i; for (i = 0; i < ERDMA_RES_CNT; i++) - kfree(dev->res_cb[i].bitmap); + bitmap_free(dev->res_cb[i].bitmap); } static const struct ib_device_ops erdma_device_ops = { -- 2.34.1