Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp705399imw; Fri, 8 Jul 2022 10:10:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vYGJoyDfGCIGFXN6VAI/dCWYXHzg9Zb4NLAKVrpSN5mTlpDW8B/2Ph+miT8kfsfrrfF5am X-Received: by 2002:a17:90a:e391:b0:1ef:83c2:2527 with SMTP id b17-20020a17090ae39100b001ef83c22527mr951299pjz.94.1657300234499; Fri, 08 Jul 2022 10:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657300234; cv=none; d=google.com; s=arc-20160816; b=pFGIr4me1jUJrNpHCoeFqRr2dzB7jFIVWxWCSdr/vAHqCTsPitQi8jv+UXLn2Vp5IY 0g5ZML6iM2V3VxtQ6Ceb6bnzvTHmZ282HmhinPm6LBCDJrR0FgOefrvLwKVlbOIw7oFt suwieIoDwD7OTx4ZKGq5eUxvcPXgzqap4CiPL16S0aK2hWOts3jEQUs0/mwJk2dtMwP8 V1pRjjROu0avrS77iqmxyPlcQrJBQ1d3y5OZSoS0PsUO8WP3+Tc7agerTUkpUjmGu1/5 MAOtbXcllcnJZFpdhp3dQgZSQqGBJsnuhO/mYm3+tWSS/Yq0bSM1h7jfoR2KgJnYp0wo 1TYw== 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=evGvFoYllwICu7t7rdNBDYVsXhgvf+ktlLZm8U1vMEI=; b=SGgibex4+YRPWx2VPgqzd+8MxtHsZepuvsYjJJ2iyLFaH4xH1teAtelbnci25peHCg yt/S4cnrB+IJ2klnM3I3+DWUPegu03YwMetuTRPD3x5rRS1e5zQWwkaGVPnnVDE4vJaW k63qmteeu1ZaERLSeVebbPjyZSeEldoAvp97chQrE/u8nwCJ83+7G5MYuKkFb93vgiBT B4nwvoptoBdkV1w+m3KQT3jfKVsL3FzHgk9pO2DHcPuBJQOIOxZVsVrxtOcnuIZ/f3ku dtDY6z3F0uemtww2Z30YQKZDa775k1hhJ78FaA9lJa2kvWhu1/w/qAAPqFcNSk+zzVfV /Ziw== 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 z64-20020a636543000000b004126d5fa836si6053675pgb.182.2022.07.08.10.10.20; Fri, 08 Jul 2022 10:10:34 -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 S238598AbiGHQrj (ORCPT + 99 others); Fri, 8 Jul 2022 12:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238798AbiGHQrc (ORCPT ); Fri, 8 Jul 2022 12:47:32 -0400 Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A9E171BEE for ; Fri, 8 Jul 2022 09:47:31 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 9r8aoCK06ZDzU9r8aojqo6; Fri, 08 Jul 2022 18:47:28 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 08 Jul 2022 18:47:28 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: "Md. Haris Iqbal" , Jack Wang , 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/rtrs-clt: Use the bitmap API to allocate bitmaps Date: Fri, 8 Jul 2022 18:47:27 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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/ulp/rtrs/rtrs-clt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 9809c3883979..06c27a3d83f5 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1403,8 +1403,7 @@ static int alloc_permits(struct rtrs_clt_sess *clt) unsigned int chunk_bits; int err, i; - clt->permits_map = kcalloc(BITS_TO_LONGS(clt->queue_depth), - sizeof(long), GFP_KERNEL); + clt->permits_map = bitmap_zalloc(clt->queue_depth, GFP_KERNEL); if (!clt->permits_map) { err = -ENOMEM; goto out_err; @@ -1426,7 +1425,7 @@ static int alloc_permits(struct rtrs_clt_sess *clt) return 0; err_map: - kfree(clt->permits_map); + bitmap_free(clt->permits_map); clt->permits_map = NULL; out_err: return err; @@ -1440,7 +1439,7 @@ static void free_permits(struct rtrs_clt_sess *clt) wait_event(clt->permits_wait, find_first_bit(clt->permits_map, sz) >= sz); } - kfree(clt->permits_map); + bitmap_free(clt->permits_map); clt->permits_map = NULL; kfree(clt->permits); clt->permits = NULL; -- 2.34.1