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

mtd: gen_probe: Use bitmap_zalloc() when applicable

'chip_map' 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.

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/a6fe58dffe553a3e79303777d3ba9c60d7613c5b.1637510255.git.christophe.jaillet@wanadoo.fr

authored by

Christophe JAILLET and committed by
Miquel Raynal
dd8a2e88 67b967dd

+4 -5
+4 -5
drivers/mtd/chips/gen_probe.c
··· 61 61 struct cfi_private cfi; 62 62 struct cfi_private *retcfi; 63 63 unsigned long *chip_map; 64 - int i, j, mapsize; 65 64 int max_chips; 65 + int i, j; 66 66 67 67 memset(&cfi, 0, sizeof(cfi)); 68 68 ··· 111 111 max_chips = 1; 112 112 } 113 113 114 - mapsize = sizeof(long) * DIV_ROUND_UP(max_chips, BITS_PER_LONG); 115 - chip_map = kzalloc(mapsize, GFP_KERNEL); 114 + chip_map = bitmap_zalloc(max_chips, GFP_KERNEL); 116 115 if (!chip_map) { 117 116 kfree(cfi.cfiq); 118 117 return NULL; ··· 138 139 139 140 if (!retcfi) { 140 141 kfree(cfi.cfiq); 141 - kfree(chip_map); 142 + bitmap_free(chip_map); 142 143 return NULL; 143 144 } 144 145 ··· 156 157 } 157 158 } 158 159 159 - kfree(chip_map); 160 + bitmap_free(chip_map); 160 161 return retcfi; 161 162 } 162 163