Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3175871pxb; Mon, 24 Jan 2022 04:15:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+KazBt4FAujEhgcP7t5jMZ5xvMTxho17F+kN+bYAZstzljgHL4CbfN2C7IfvGwWYV2/7S X-Received: by 2002:a17:90b:33ca:: with SMTP id lk10mr1636546pjb.45.1643026523343; Mon, 24 Jan 2022 04:15:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643026523; cv=none; d=google.com; s=arc-20160816; b=0vNlB1rQEaDvXPL5S7H08whUIZHuTIpkk9fuzbxapiO7Z1mewE9xIroMZNcwIU5vvH Nq+ArVH5XEczKKJaYihUZZltVwYqNrY7PP2PknPJ4sLZwdkSLFUQMQC1XJ9b+/1RNswd jX0RusxxZXi3ihWmgYqzggHCX6y2E7v/Xi4tK79pFttlVIxL8LgOJWt/VJTS+NL9/m41 Z5Pi3xBbNyNsMm9mtDLTFdi/MaFwGgTDlUsT8mOtiaokcMjBXHG0qUG4K3vYnq9eaz9T yu4sHq5abztCIkSSjJT3N3k4vtW6VU+A4XEuN7i3VNBaP7C/n44a2YY9r2IN9oqLhIYn GnBA== 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=IkNrFbXH9gY1KIOKy+h9o3LQcC7Su75w6LGwm4LKjaA=; b=asgADNkyWU1NpOkCIufAhLfzaaBxVhJVMwmOMqzZQRDntwiXXpk0xHUsyrt6ylTMc3 dhS+/u8zB/7JPz9tKPcp+XXXNaUhxBzRK6bfN3AShzH9MdP1+uk86l7TA1MlkRaahGOB fVQmjGxKxTvNKUdgviA5XW4/eX61x67uEvgzvZVfEZDlkUehqr/F0UyhuBowKnOhHbVe nWhfLN+4sDkEQAnaSCMw2pqMSRRFDI8eOFIQar0CdjsghhjwIROvx6+Tr5f65T91cnlx /wC0MugvHOeFlzCtb9ik7YB62KkLbCTQximQZrwBkaBaqDsB/ubT/whqT83LA1gFe8Fg 0nIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="EaNO/dAS"; 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 s5si11463668pgp.178.2022.01.24.04.15.11; Mon, 24 Jan 2022 04:15:23 -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="EaNO/dAS"; 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 S240078AbiAWSmj (ORCPT + 99 others); Sun, 23 Jan 2022 13:42:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240074AbiAWSlo (ORCPT ); Sun, 23 Jan 2022 13:41:44 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A4EEC0613DE; Sun, 23 Jan 2022 10:41:38 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id c3so13490602pls.5; Sun, 23 Jan 2022 10:41:38 -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=IkNrFbXH9gY1KIOKy+h9o3LQcC7Su75w6LGwm4LKjaA=; b=EaNO/dASy+lPZWlcOtxF1hC9GdUeB2iS8umkWOWTX4v3h315YhPaRibVAi7vXbbHWe dZQi44B8tyxUoVsiF1ho0iJZOHCw92Invp1s1Jngv0T8L+0c7uqMPEEfpdlpf7wsR2hX def6pyngVUbofEtQ0onarODYce0lr6EcewlHKAkg7wW7/E/IkNjJ29EwgZ9JC95dqfwt HyYjjJh6C7hZd1XozPUerv73BbBwkDAQaBq4LR4A9muS5E19XN+FHJn+gDMMIIQ3OCVG BFULBqru13piNITxvIlEYH3XteGH1vToU8U0ADIfL8v4GWj0g5Y1FVAMkzSf8zEQusxa sUQg== 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=IkNrFbXH9gY1KIOKy+h9o3LQcC7Su75w6LGwm4LKjaA=; b=RY59NwHFm1GkcqcSz+WxYiTzOYYpKs+o8EVUByY0h5MJM5wYx/6NXMO0C3l/O7iM47 zy7TIyf6BD90C/Gx3RYoGJN0FF+ttqgIpLAEcTglK5xMG6p/r3Wld1zHt1UQTMdg9/B5 ZcdJQU7NqMYXzUInH6Hb0Okv6Ga2ZXrmewlIePNR+W8s7zKaeOe3Ac1pY8RtrjkHhzLW Wff7QzpHnVxJt2ZZnPsiAUh8Lllkj6mX9zoYQBY/u0yXlToUZKrY0KfgyceF6XowEoJB 0ZCZtc7Fl/encwiEBiwxmdzweEEETg5f72uKev0mWl8EvuiwKNNbeaZa8H9ICoRw4U7w TWHA== X-Gm-Message-State: AOAM533iw7yIgHU+dKabTx8o/cKkFQjbqjvwHdZ1mdw6MG7nYzRnwfOb tkutO2Rvl22V5fOZIfPOo2Y= X-Received: by 2002:a17:902:c40d:b0:14a:96a4:1044 with SMTP id k13-20020a170902c40d00b0014a96a41044mr11869369plk.50.1642963297601; Sun, 23 Jan 2022 10:41:37 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id ms14sm11163509pjb.15.2022.01.23.10.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:37 -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, Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 35/54] drivers/staging: replace bitmap_weight with bitmap_weight_le for tegra-video Date: Sun, 23 Jan 2022 10:39:06 -0800 Message-Id: <20220123183925.1052919-36-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 tegra_channel_enum_format() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_le() because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/staging/media/tegra-video/vi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index d1f43f465c22..4e79a80e9307 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -436,7 +436,7 @@ static int tegra_channel_enum_format(struct file *file, void *fh, if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) fmts_bitmap = chan->fmts_bitmap; - if (f->index >= bitmap_weight(fmts_bitmap, MAX_FORMAT_NUM)) + if (bitmap_weight_le(fmts_bitmap, MAX_FORMAT_NUM, f->index)) return -EINVAL; for (i = 0; i < f->index + 1; i++, index++) -- 2.30.2