Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3175719pxb; Mon, 24 Jan 2022 04:15:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2APgWdjN79c3kchnanLNSvpFoWSM7dAaC11kMy0v9yZUqNEt4D1daqSBiaIN+IvNoiuOn X-Received: by 2002:a17:90b:fc6:: with SMTP id gd6mr1593736pjb.225.1643026511956; Mon, 24 Jan 2022 04:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643026511; cv=none; d=google.com; s=arc-20160816; b=O6tXaTgENDvbIhknL9OpkOvLwkbAe6CYHI/65IZDGcB3wYTXOysh5m8HqJIOWIi+dS XTlIyh9KshEMLAKzAYjk+Yr3u/79XAFDb+si/aXU4c3Hv1h3KoTjbYp4STbYSklmaa9I jQBaDrHmD1YPlkMXS02Xt5ByWOQnvn+6lKpOJtlnFyYfloeeRNSsioGAVvblFl0UfNK1 9SkQnN3pMnxZpyjmurUs8Qbmd9Rt2E1zQsaLA8K/lBTog4DtZCUADVWxdNmI6e4yEAfs smFAgRwvehcVcZpDAOWerqz2y7jy0MrWTF/RnYvCMk5+3Ige4fP21gsCwx8K5kGXscYF Nzlg== 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:to:from :dkim-signature; bh=6Ui4qYj030cyXXLNoJCYbzVgN3GtE9ORNZ/WmrY4RZ0=; b=tBNPWy5qvrDjRo7ssjT2LZnjLHGAol6oCGdlc9pYRL0nRcTzKmP6g0/OFNhxwvBgh3 vExNradagv5iobgfS4CardNKOAse/+7DO5omj3//1KaMGpcPNVISMNZQ5QRF0IocSMaH DC984p1yvkpnXqqGeAS1qzvurb3QGF2KYpuSAVMjRuCN4L1ZEoJMRMldRgxkUokluZ2p nYat3D22GC/UPth/nd3M85D7QUgu0CKKgGdc6bTXeqyATotp0Q/YNy7z/2LcQfPpEQyn o/gBbzJQ0cL64zwkS2VgPTq/HAvXE2NTH8vuURN9FVxBHa5MSbYboMgCzAHPYupfX6lL 323g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="bvjD/rU6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o20si13169841pgv.148.2022.01.24.04.14.59; Mon, 24 Jan 2022 04:15:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="bvjD/rU6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239966AbiAWSmP (ORCPT + 99 others); Sun, 23 Jan 2022 13:42:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239984AbiAWSlX (ORCPT ); Sun, 23 Jan 2022 13:41:23 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA93CC06177E; Sun, 23 Jan 2022 10:41:22 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id h23so13123433pgk.11; Sun, 23 Jan 2022 10:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6Ui4qYj030cyXXLNoJCYbzVgN3GtE9ORNZ/WmrY4RZ0=; b=bvjD/rU6iqsebFa6UrcK3iewqd10jG4LVBWUGqLPKS6DQHmKsM0GlWrRcDkwm32wez K2Tav2t5udTw/hhvd4t8Ul9uRQspEUYlHM2i05GSTepFyaem1ef2UrxlUOykmr/yIVwQ /LBLWZgnweBxdfSFAOGfeJDVTH8CBqw5Z6Tjd4R8ePwhjhCFathcOrwavkUjnB6NU7re rNo7Wqa3tUpSJLsAu4J/S0oXA9AhDk6aKHUwEoolQiPPOZJnjRuSzrwbX89WRuubEGpG JV3SpEZBVcZaT1MRC3c+z3VssVlfm7kpONiwsTOcm5S+lWEWrx6Ow2eBzVXGhCJbZ0Kz 8Mtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Ui4qYj030cyXXLNoJCYbzVgN3GtE9ORNZ/WmrY4RZ0=; b=gTmwqm+gEreKHs475whqEdd50qE1hR3TMs5xD1b8Qljvdnes5nZ2RBmXeI6wXnLG4h 9BDvkxMZZkQ/TNPXCsrI8q5l2emy+b5Z39IKRHuf0INfKo7lAuuVLbKGNAlcNW1iNlXa 6Z0jFklUqwAtfE87SwaGemWrH9cGymdVbKGdfQIQSPIK5LFdYZkHDlDBpbZXvFfd71Yy CctB6e+Vs9Cg0rCyWvANKt73CuiNHV7HZtyKl0ykgo3GuDd5YhDMIfCnDB/5qv5k76ai Pjgh0LFvPCKwelGA0cNl81GVvCvr8PY9QggEcAgGZqUXn0KE26QEnyWA9T6vo34EzzHX IATg== X-Gm-Message-State: AOAM532RjT3/yEf65t1DOGCNth+EBP/hVHcuVpRa1MCCBS7Cyrzx7s5A ORdYcZLmvxPygjNwgjocwlE= X-Received: by 2002:a63:1f07:: with SMTP id f7mr9444383pgf.219.1642963282332; Sun, 23 Jan 2022 10:41:22 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id y42sm5576483pfw.157.2022.01.23.10.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:22 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Maxim Levitsky , Alex Dubov , Ulf Hansson , Jens Axboe , Luis Chamberlain , Colin Ian King , Arnd Bergmann , Shubhankar Kuranagatti , linux-mmc@vger.kernel.org Subject: [PATCH 30/54] drivers/memstick: replace bitmap_weight with bitmap_weight_eq where appropriate Date: Sun, 23 Jan 2022 10:39:01 -0800 Message-Id: <20220123183925.1052919-31-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org msb_validate_used_block_bitmap() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/memstick/core/ms_block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c index 0cda6c6baefc..5cdd987e78f7 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c @@ -155,8 +155,8 @@ static int msb_validate_used_block_bitmap(struct msb_data *msb) for (i = 0; i < msb->zone_count; i++) total_free_blocks += msb->free_block_count[i]; - if (msb->block_count - bitmap_weight(msb->used_blocks_bitmap, - msb->block_count) == total_free_blocks) + if (bitmap_weight_eq(msb->used_blocks_bitmap, msb->block_count, + msb->block_count - total_free_blocks)) return 0; pr_err("BUG: free block counts don't match the bitmap"); -- 2.30.2