[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 f2e4360..48d87c6 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;