PCI: xgene-msi: Use bitmap_zalloc() when applicable
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 23 Oct 2021 20:02:05 +0000 (22:02 +0200)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 29 Nov 2021 17:29:15 +0000 (17:29 +0000)
'xgene_msi->bitmap' 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.

Link: https://lore.kernel.org/r/32f3bc1fbfbd6ee0815e565012904758ca9eff7e.1635019243.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Krzysztof WilczyƄski <kw@linux.com>
drivers/pci/controller/pci-xgene-msi.c

index c50ff279903c2a5a216bd40798d5fdd532f0a8b7..bfa259781b692dc4792332e8474d79df8ad0dd12 100644 (file)
@@ -269,9 +269,7 @@ static void xgene_free_domains(struct xgene_msi *msi)
 
 static int xgene_msi_init_allocator(struct xgene_msi *xgene_msi)
 {
-       int size = BITS_TO_LONGS(NR_MSI_VEC) * sizeof(long);
-
-       xgene_msi->bitmap = kzalloc(size, GFP_KERNEL);
+       xgene_msi->bitmap = bitmap_zalloc(NR_MSI_VEC, GFP_KERNEL);
        if (!xgene_msi->bitmap)
                return -ENOMEM;
 
@@ -360,7 +358,7 @@ static int xgene_msi_remove(struct platform_device *pdev)
 
        kfree(msi->msi_groups);
 
-       kfree(msi->bitmap);
+       bitmap_free(msi->bitmap);
        msi->bitmap = NULL;
 
        xgene_free_domains(msi);