Commit 549e08a0 authored by lixiubo's avatar lixiubo Committed by Mark Brown

regmap: replace kmalloc with kmalloc_array

Replace kmalloc with specialized function kmalloc_array when the size
is a multiplication of : number * size
Signed-off-by: default avatarlixiubo <lixiubo@cmss.chinamobile.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent eeda1bd6
...@@ -152,8 +152,8 @@ static int regcache_lzo_init(struct regmap *map) ...@@ -152,8 +152,8 @@ static int regcache_lzo_init(struct regmap *map)
* that register. * that register.
*/ */
bmp_size = map->num_reg_defaults_raw; bmp_size = map->num_reg_defaults_raw;
sync_bmp = kmalloc(BITS_TO_LONGS(bmp_size) * sizeof(long), sync_bmp = kmalloc_array(BITS_TO_LONGS(bmp_size), sizeof(long),
GFP_KERNEL); GFP_KERNEL);
if (!sync_bmp) { if (!sync_bmp) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
......
...@@ -361,8 +361,8 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg) ...@@ -361,8 +361,8 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
rbnode->base_reg = reg; rbnode->base_reg = reg;
} }
rbnode->block = kmalloc(rbnode->blklen * map->cache_word_size, rbnode->block = kmalloc_array(rbnode->blklen, map->cache_word_size,
GFP_KERNEL); GFP_KERNEL);
if (!rbnode->block) if (!rbnode->block)
goto err_free; goto err_free;
......
...@@ -422,8 +422,9 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, ...@@ -422,8 +422,9 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
if (!map->use_single_read && map->reg_stride == 1 && if (!map->use_single_read && map->reg_stride == 1 &&
d->irq_reg_stride == 1) { d->irq_reg_stride == 1) {
d->status_reg_buf = kmalloc(map->format.val_bytes * d->status_reg_buf = kmalloc_array(chip->num_regs,
chip->num_regs, GFP_KERNEL); map->format.val_bytes,
GFP_KERNEL);
if (!d->status_reg_buf) if (!d->status_reg_buf)
goto err_alloc; goto err_alloc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment