On Fri Sep 25 14:55:52 2026 -0400, Yury Norov wrote:
> Get rid of bitmap_weight(), and use find_nth_bit() in the function,
> instead of the for-loop.
> 
> Signed-off-by: Yury Norov <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 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 6a5f66da348b..d8c77d1290ef 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;
 }
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to