mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: media: tegra-video: simplify formats enumeration
@ 2026-09-25 18:55 Yury Norov
  0 siblings, 0 replies; only message in thread
From: Yury Norov @ 2026-09-25 18:55 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
	Luca Ceresoli, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	linux-media, linux-tegra, linux-staging, linux-kernel
  Cc: Yury Norov, Yury Norov

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-25 18:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 18:55 [PATCH] staging: media: tegra-video: simplify formats enumeration Yury Norov

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®