From: Yury Norov <ynorov@nvidia.com>
To: Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Sowjanya Komatineni <skomatineni@nvidia.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-media@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Yury Norov <ynorov@nvidia.com>, Yury Norov <yury.norov@gmail.com>
Subject: [PATCH] staging: media: tegra-video: simplify formats enumeration
Date: Fri, 25 Sep 2026 14:55:52 -0400 [thread overview]
Message-ID: <20260925185553.242102-1-ynorov@nvidia.com> (raw)
Get rid of bitmap_weight(), and use find_nth_bit() in the function,
instead of the for-loop.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
drivers/staging/media/tegra-video/vi.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 01622013c109..302a1bd29a68 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -6,6 +6,7 @@
#include <linux/bitmap.h>
#include <linux/clk.h>
#include <linux/delay.h>
+#include <linux/find.h>
#include <linux/host1x.h>
#include <linux/lcm.h>
#include <linux/list.h>
@@ -393,19 +394,17 @@ static int tegra_channel_enum_format(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
{
struct tegra_vi_channel *chan = video_drvdata(file);
- unsigned int index = 0, i;
+ unsigned int index;
unsigned long *fmts_bitmap = chan->tpg_fmts_bitmap;
if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG))
fmts_bitmap = chan->fmts_bitmap;
- if (f->index >= bitmap_weight(fmts_bitmap, MAX_FORMAT_NUM))
+ index = find_nth_bit(fmts_bitmap, MAX_FORMAT_NUM, f->index);
+ if (index >= MAX_FORMAT_NUM)
return -EINVAL;
- for (i = 0; i < f->index + 1; i++, index++)
- index = find_next_bit(fmts_bitmap, MAX_FORMAT_NUM, index);
-
- f->pixelformat = tegra_get_format_fourcc_by_idx(chan->vi, index - 1);
+ f->pixelformat = tegra_get_format_fourcc_by_idx(chan->vi, index);
return 0;
}
--
2.53.0
reply other threads:[~2026-09-25 18:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260925185553.242102-1-ynorov@nvidia.com \
--to=ynorov@nvidia.com \
--cc=gregkh@linuxfoundation.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mchehab@kernel.org \
--cc=skomatineni@nvidia.com \
--cc=thierry.reding@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®