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

dm: use vmalloc_array() to simplify code

Remove array_size() calls and replace vmalloc() with vmalloc_array() to
simplify the code.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

authored by

Qianfeng Rong and committed by
Mikulas Patocka
c3797175 a3191475

+6 -6
+1 -1
drivers/md/dm-cache-policy-smq.c
··· 590 590 nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u)); 591 591 ht->hash_bits = __ffs(nr_buckets); 592 592 593 - ht->buckets = vmalloc(array_size(nr_buckets, sizeof(*ht->buckets))); 593 + ht->buckets = vmalloc_array(nr_buckets, sizeof(*ht->buckets)); 594 594 if (!ht->buckets) 595 595 return -ENOMEM; 596 596
+1 -1
drivers/md/dm-region-hash.c
··· 206 206 rh->shift = RH_HASH_SHIFT; 207 207 rh->prime = RH_HASH_MULT; 208 208 209 - rh->buckets = vmalloc(array_size(nr_buckets, sizeof(*rh->buckets))); 209 + rh->buckets = vmalloc_array(nr_buckets, sizeof(*rh->buckets)); 210 210 if (!rh->buckets) { 211 211 DMERR("unable to allocate region hash bucket memory"); 212 212 kfree(rh);
+2 -2
drivers/md/dm-switch.c
··· 114 114 return -EINVAL; 115 115 } 116 116 117 - sctx->region_table = vmalloc(array_size(nr_slots, 118 - sizeof(region_table_slot_t))); 117 + sctx->region_table = vmalloc_array(nr_slots, 118 + sizeof(region_table_slot_t)); 119 119 if (!sctx->region_table) { 120 120 ti->error = "Cannot allocate region table"; 121 121 return -ENOMEM;
+2 -2
drivers/md/dm-thin.c
··· 3031 3031 } 3032 3032 3033 3033 pool->cell_sort_array = 3034 - vmalloc(array_size(CELL_SORT_ARRAY_SIZE, 3035 - sizeof(*pool->cell_sort_array))); 3034 + vmalloc_array(CELL_SORT_ARRAY_SIZE, 3035 + sizeof(*pool->cell_sort_array)); 3036 3036 if (!pool->cell_sort_array) { 3037 3037 *error = "Error allocating cell sort array"; 3038 3038 err_p = ERR_PTR(-ENOMEM);