[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YamGQbD+abET4rmx@pendragon.ideasonboard.com>
Date: Fri, 3 Dec 2021 04:51:45 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: sakari.ailus@...ux.intel.com, mchehab@...nel.org,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] media: mc: mc-entity.c: Use bitmap_zalloc() when
applicable
Hi Christophe,
Thank you for the patch.
On Wed, Dec 01, 2021 at 11:19:40PM +0100, Christophe JAILLET wrote:
> 'ent_enum->bmap' is a bitmap. So use 'bitmap_zalloc()' to simplify
> code, improve the semantic and avoid some open-coded arithmetic in
> allocator arguments.
>
> Also change the corresponding 'kfree()' into 'bitmap_free()' to keep
> consistency.
>
> While at it, remove a useless 'bitmap_zero()'.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
> ---
> drivers/media/mc/mc-entity.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index c02340698ad6..b411f9796191 100644
> --- a/drivers/media/mc/mc-entity.c
> +++ b/drivers/media/mc/mc-entity.c
> @@ -48,12 +48,10 @@ __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
> int idx_max)
> {
> idx_max = ALIGN(idx_max, BITS_PER_LONG);
> - ent_enum->bmap = kcalloc(idx_max / BITS_PER_LONG, sizeof(long),
> - GFP_KERNEL);
> + ent_enum->bmap = bitmap_zalloc(idx_max, GFP_KERNEL);
> if (!ent_enum->bmap)
> return -ENOMEM;
>
> - bitmap_zero(ent_enum->bmap, idx_max);
> ent_enum->idx_max = idx_max;
>
> return 0;
> @@ -62,7 +60,7 @@ EXPORT_SYMBOL_GPL(__media_entity_enum_init);
>
> void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
> {
> - kfree(ent_enum->bmap);
> + bitmap_free(ent_enum->bmap);
> }
> EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
>
--
Regards,
Laurent Pinchart
Powered by blists - more mailing lists