Skip to content

Commit ce560ee

Browse files
tititiou36mchehab
authored andcommitted
media: mc: mc-entity.c: Use bitmap_zalloc() when applicable
'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()'. Link: https://lore.kernel.org/linux-media/b11f646dda189f490c06bf671f64a2cc0af4d45c.1638397089.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Kieran Bingham <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 34b1df9 commit ce560ee

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/media/mc/mc-entity.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
4848
int idx_max)
4949
{
5050
idx_max = ALIGN(idx_max, BITS_PER_LONG);
51-
ent_enum->bmap = kcalloc(idx_max / BITS_PER_LONG, sizeof(long),
52-
GFP_KERNEL);
51+
ent_enum->bmap = bitmap_zalloc(idx_max, GFP_KERNEL);
5352
if (!ent_enum->bmap)
5453
return -ENOMEM;
5554

56-
bitmap_zero(ent_enum->bmap, idx_max);
5755
ent_enum->idx_max = idx_max;
5856

5957
return 0;
@@ -62,7 +60,7 @@ EXPORT_SYMBOL_GPL(__media_entity_enum_init);
6260

6361
void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
6462
{
65-
kfree(ent_enum->bmap);
63+
bitmap_free(ent_enum->bmap);
6664
}
6765
EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
6866

0 commit comments

Comments
 (0)