Commit eeda1bd6 authored by lixiubo's avatar lixiubo Committed by Mark Brown

regmap: replace kzalloc with kcalloc

Replace kzalloc with specialized function kcalloc when the size is
a multiplication of : number * sizeof
Signed-off-by: default avatarlixiubo <lixiubo@cmss.chinamobile.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8005c49d
...@@ -21,7 +21,7 @@ static int regcache_flat_init(struct regmap *map) ...@@ -21,7 +21,7 @@ static int regcache_flat_init(struct regmap *map)
int i; int i;
unsigned int *cache; unsigned int *cache;
map->cache = kzalloc(sizeof(unsigned int) * (map->max_register + 1), map->cache = kcalloc(map->max_register + 1, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!map->cache) if (!map->cache)
return -ENOMEM; return -ENOMEM;
......
...@@ -139,7 +139,7 @@ static int regcache_lzo_init(struct regmap *map) ...@@ -139,7 +139,7 @@ static int regcache_lzo_init(struct regmap *map)
ret = 0; ret = 0;
blkcount = regcache_lzo_block_count(map); blkcount = regcache_lzo_block_count(map);
map->cache = kzalloc(blkcount * sizeof *lzo_blocks, map->cache = kcalloc(blkcount, sizeof(*lzo_blocks),
GFP_KERNEL); GFP_KERNEL);
if (!map->cache) if (!map->cache)
return -ENOMEM; return -ENOMEM;
......
...@@ -366,8 +366,9 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg) ...@@ -366,8 +366,9 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
if (!rbnode->block) if (!rbnode->block)
goto err_free; goto err_free;
rbnode->cache_present = kzalloc(BITS_TO_LONGS(rbnode->blklen) * rbnode->cache_present = kcalloc(BITS_TO_LONGS(rbnode->blklen),
sizeof(*rbnode->cache_present), GFP_KERNEL); sizeof(*rbnode->cache_present),
GFP_KERNEL);
if (!rbnode->cache_present) if (!rbnode->cache_present)
goto err_free_block; goto err_free_block;
......
...@@ -386,23 +386,23 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, ...@@ -386,23 +386,23 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
if (!d) if (!d)
return -ENOMEM; return -ENOMEM;
d->status_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, d->status_buf = kcalloc(chip->num_regs, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!d->status_buf) if (!d->status_buf)
goto err_alloc; goto err_alloc;
d->mask_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, d->mask_buf = kcalloc(chip->num_regs, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!d->mask_buf) if (!d->mask_buf)
goto err_alloc; goto err_alloc;
d->mask_buf_def = kzalloc(sizeof(unsigned int) * chip->num_regs, d->mask_buf_def = kcalloc(chip->num_regs, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!d->mask_buf_def) if (!d->mask_buf_def)
goto err_alloc; goto err_alloc;
if (chip->wake_base) { if (chip->wake_base) {
d->wake_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, d->wake_buf = kcalloc(chip->num_regs, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!d->wake_buf) if (!d->wake_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