Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: bbt: Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/b18c2b6711b8930f0dfb8318b5d19ef6e41f0f9a.1656864573.git.christophe.jaillet@wanadoo.fr

authored by

Christophe JAILLET and committed by
Miquel Raynal
054c6b58 7471a53d

+2 -5
+2 -5
drivers/mtd/nand/bbt.c
··· 24 24 { 25 25 unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS); 26 26 unsigned int nblocks = nanddev_neraseblocks(nand); 27 - unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block, 28 - BITS_PER_LONG); 29 27 30 - nand->bbt.cache = kcalloc(nwords, sizeof(*nand->bbt.cache), 31 - GFP_KERNEL); 28 + nand->bbt.cache = bitmap_zalloc(nblocks * bits_per_block, GFP_KERNEL); 32 29 if (!nand->bbt.cache) 33 30 return -ENOMEM; 34 31 ··· 41 44 */ 42 45 void nanddev_bbt_cleanup(struct nand_device *nand) 43 46 { 44 - kfree(nand->bbt.cache); 47 + bitmap_free(nand->bbt.cache); 45 48 } 46 49 EXPORT_SYMBOL_GPL(nanddev_bbt_cleanup); 47 50