[media] media: Use all bits of an enumeration
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 27 Jan 2016 14:47:54 +0000 (12:47 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 19 Feb 2016 13:45:03 +0000 (11:45 -0200)
The allocation takes place in longs. Assign the size of the enum
accordingly.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-entity.c

index f2e43603d6d24f6a3c27105369187a73d61d8175..48d87c6f5e90121378a7bc584aad42e5dc74f298 100644 (file)
@@ -73,8 +73,9 @@ static inline const char *intf_type(struct media_interface *intf)
 __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
                                          int idx_max)
 {
-       ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG),
-                                sizeof(long), GFP_KERNEL);
+       idx_max = ALIGN(idx_max, BITS_PER_LONG);
+       ent_enum->bmap = kcalloc(idx_max / BITS_PER_LONG, sizeof(long),
+                                GFP_KERNEL);
        if (!ent_enum->bmap)
                return -ENOMEM;