Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp51051imk; Sat, 2 Jul 2022 11:30:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vIGCONDuf7U8Ge6gH25Hdx9Qu17o7ScD2nPG70XN2lX+UQ4WFYX1bm+swLfLBv23FO6wzf X-Received: by 2002:a63:2a4f:0:b0:40d:997:557f with SMTP id q76-20020a632a4f000000b0040d0997557fmr17811012pgq.42.1656786646470; Sat, 02 Jul 2022 11:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656786646; cv=none; d=google.com; s=arc-20160816; b=BvTbRLjSDNsX+iVFnrIxpiXZGdvFPsS4KOydW9/6CPWEkAIsnkn2c1XqDlWlltAC7L GNTKaEiC8Mem2sIOQNV+Fz2x9kN+CD7yVVpqwL/6uRwNmpoJOoOn7PZ42i9bM8pGfQNB uE0/5bc4jDxWE+xOtat0wUHflBBNut37dXp32cb5g3Mcz3lMQJe6dHWb0yAPPR7p2L6c 5jLiP8RsTfZxTUaW9CdO5QOWXgg7cpFEOzKupWkCR/f1dZgW3pqf4vClqh61mwEQRKj4 g6uLC3u1sP10QiUlLSOTpmLt0hr5HwHCyJAYu6T0S9zN0lTBh8MCJ+ZFKVSPxELwS8gT dUwg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WoSZOIA+kv0nyND41P7J4KGpp0pfO1T35PnPWVqqu0Y=; b=qbQJ908j6AOfCWJ4UMagC5FqwQmX1RWrMFZrH1kbMfN8AKdD4BiEttTHjWuGmsI1El S7E7MtKlixY38bNbAMUJY7Q7mf0LjXY98+OCj9obz07vXpW06j/ZOPzX3Uzs/67FPGOx RqAo2xUKzhdYQFZb8FSCm5XM+Y9Gg33WtTU+fzJo3xDqxy7jzu2X+MfcnIiTrvlXZw54 8Zpa9LDDb708pL93QU714q/QTrEUHa1EFD12Q30mzrbZh8JGOi574hMifwbIO1fxmnIs o5mMowzdbjnU7WzVgZPolycqHnrxSAW8QU34YXnpf95zwNWjqMak6DXG4E9OM5Ti9YM/ rqUg== 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 a11-20020a170902eccb00b00153b2d165c6si39177608plh.462.2022.07.02.11.30.34; Sat, 02 Jul 2022 11:30:46 -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 S232117AbiGBS3o (ORCPT + 99 others); Sat, 2 Jul 2022 14:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbiGBS3m (ORCPT ); Sat, 2 Jul 2022 14:29:42 -0400 Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69455DF1A for ; Sat, 2 Jul 2022 11:29:41 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 7hsAo7wOSYwJ77hsAo61iK; Sat, 02 Jul 2022 20:29:39 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 02 Jul 2022 20:29:39 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, almaz.alexandrovich@paragon-software.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Cc: linux-s390@vger.kernel.org, ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 3/4] bitmap: Introduce bitmap_size() Date: Sat, 2 Jul 2022 20:29:36 +0200 Message-Id: <98f5d3d855a9c687ccc035edf62016b02a6876b7.1656785856.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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 The new bitmap_size() function returns the size, in bytes, of a bitmap. Remove the already existing bitmap_size() functions and macro in some files. These files already use the bitmap API and will use the new function in bitmap.h automatically. Signed-off-by: Christophe JAILLET --- drivers/md/dm-clone-metadata.c | 5 ----- include/linux/bitmap.h | 6 ++++++ lib/math/prime_numbers.c | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-clone-metadata.c b/drivers/md/dm-clone-metadata.c index c43d55672bce..47c1fa7aad8b 100644 --- a/drivers/md/dm-clone-metadata.c +++ b/drivers/md/dm-clone-metadata.c @@ -465,11 +465,6 @@ static void __destroy_persistent_data_structures(struct dm_clone_metadata *cmd) /*---------------------------------------------------------------------------*/ -static size_t bitmap_size(unsigned long nr_bits) -{ - return BITS_TO_LONGS(nr_bits) * sizeof(long); -} - static int __dirty_map_init(struct dirty_map *dmap, unsigned long nr_words, unsigned long nr_regions) { diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index f091a1664bf1..f66fb98a4126 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -48,6 +48,7 @@ struct device; * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2? + * bitmap_size(nbits) Size, in bytes, of a bitmap * bitmap_empty(src, nbits) Are all bits zero in *src? * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_weight(src, nbits) Hamming Weight: number set bits @@ -124,6 +125,11 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node); unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node); void bitmap_free(const unsigned long *bitmap); +static __always_inline size_t bitmap_size(unsigned long nbits) +{ + return BITS_TO_LONGS(nbits) * sizeof(unsigned long); +} + /* Managed variants of the above. */ unsigned long *devm_bitmap_alloc(struct device *dev, unsigned int nbits, gfp_t flags); diff --git a/lib/math/prime_numbers.c b/lib/math/prime_numbers.c index d42cebf7407f..d3b64b10da1c 100644 --- a/lib/math/prime_numbers.c +++ b/lib/math/prime_numbers.c @@ -6,8 +6,6 @@ #include #include -#define bitmap_size(nbits) (BITS_TO_LONGS(nbits) * sizeof(unsigned long)) - struct primes { struct rcu_head rcu; unsigned long last, sz; -- 2.34.1