lkml.org 
[lkml]   [2022]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 34/49] media: tegra-video: replace bitmap_weight with bitmap_weight_le
    Date
    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 (or can't be) met.

    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    ---
    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.32.0
    \
     
     \ /
      Last update: 2022-02-11 01:07    [W:4.090 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site