octeontx2-af: Use the bitmap API to allocate bitmaps
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 25 Nov 2022 12:23:59 +0000 (13:23 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Dec 2022 04:42:19 +0000 (20:42 -0800)
Use devm_bitmap_zalloc() instead of hand-writing it.

This also makes the comment "Allocate bitmap for 32 entry mcam" more
explicit because now 32 is really used in the allocation function, instead
of an obscure 'sizeof(long)'.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/24177a9ee7043259448b735263d9cfd6a70e89a4.1669378798.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c

index c584680f2d2be2c5d614235fc18b85f49eff5c6f..3f94b620ef5a4094db31e33ae96897b1ebffdcfa 100644 (file)
@@ -1898,15 +1898,15 @@ int rvu_npc_exact_init(struct rvu *rvu)
        table_size = table->mem_table.depth * table->mem_table.ways;
 
        /* Allocate bitmap for 4way 2K table */
-       table->mem_table.bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(table_size),
-                                            sizeof(long), GFP_KERNEL);
+       table->mem_table.bmap = devm_bitmap_zalloc(rvu->dev, table_size,
+                                                  GFP_KERNEL);
        if (!table->mem_table.bmap)
                return -ENOMEM;
 
        dev_dbg(rvu->dev, "%s: Allocated bitmap for 4way 2K entry table\n", __func__);
 
        /* Allocate bitmap for 32 entry mcam */
-       table->cam_table.bmap = devm_kcalloc(rvu->dev, 1, sizeof(long), GFP_KERNEL);
+       table->cam_table.bmap = devm_bitmap_zalloc(rvu->dev, 32, GFP_KERNEL);
 
        if (!table->cam_table.bmap)
                return -ENOMEM;