Commit 8798975b authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'regmap/topic/core' into regmap-next

parents 6cca6712 fcac0233
...@@ -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;
...@@ -152,7 +152,7 @@ static int regcache_lzo_init(struct regmap *map) ...@@ -152,7 +152,7 @@ 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;
......
...@@ -361,13 +361,14 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg) ...@@ -361,13 +361,14 @@ 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;
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;
...@@ -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;
} }
......
...@@ -1513,7 +1513,7 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val) ...@@ -1513,7 +1513,7 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val)
{ {
int ret; int ret;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
map->lock(map->lock_arg); map->lock(map->lock_arg);
...@@ -1540,7 +1540,7 @@ int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val) ...@@ -1540,7 +1540,7 @@ int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val)
{ {
int ret; int ret;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
map->lock(map->lock_arg); map->lock(map->lock_arg);
...@@ -1714,7 +1714,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, ...@@ -1714,7 +1714,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
if (map->bus && !map->format.parse_inplace) if (map->bus && !map->format.parse_inplace)
return -EINVAL; return -EINVAL;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
/* /*
...@@ -1983,7 +1983,7 @@ static int _regmap_multi_reg_write(struct regmap *map, ...@@ -1983,7 +1983,7 @@ static int _regmap_multi_reg_write(struct regmap *map,
int reg = regs[i].reg; int reg = regs[i].reg;
if (!map->writeable_reg(map->dev, reg)) if (!map->writeable_reg(map->dev, reg))
return -EINVAL; return -EINVAL;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
} }
...@@ -2133,7 +2133,7 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg, ...@@ -2133,7 +2133,7 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg,
if (val_len % map->format.val_bytes) if (val_len % map->format.val_bytes)
return -EINVAL; return -EINVAL;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
map->lock(map->lock_arg); map->lock(map->lock_arg);
...@@ -2260,7 +2260,7 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val) ...@@ -2260,7 +2260,7 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val)
{ {
int ret; int ret;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
map->lock(map->lock_arg); map->lock(map->lock_arg);
...@@ -2296,7 +2296,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, ...@@ -2296,7 +2296,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
return -EINVAL; return -EINVAL;
if (val_len % map->format.val_bytes) if (val_len % map->format.val_bytes)
return -EINVAL; return -EINVAL;
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
if (val_count == 0) if (val_count == 0)
return -EINVAL; return -EINVAL;
...@@ -2414,7 +2414,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, ...@@ -2414,7 +2414,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
size_t val_bytes = map->format.val_bytes; size_t val_bytes = map->format.val_bytes;
bool vol = regmap_volatile_range(map, reg, val_count); bool vol = regmap_volatile_range(map, reg, val_count);
if (reg % map->reg_stride) if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL; return -EINVAL;
if (map->bus && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) { if (map->bus && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
......
...@@ -1021,7 +1021,7 @@ static inline void regmap_async_complete(struct regmap *map) ...@@ -1021,7 +1021,7 @@ static inline void regmap_async_complete(struct regmap *map)
} }
static inline int regmap_register_patch(struct regmap *map, static inline int regmap_register_patch(struct regmap *map,
const struct reg_default *regs, const struct reg_sequence *regs,
int num_regs) int num_regs)
{ {
WARN_ONCE(1, "regmap API is disabled"); WARN_ONCE(1, "regmap API is disabled");
......
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