diff options
-rw-r--r-- | drivers/base/regmap/regcache-flat.c | 2 | ||||
-rw-r--r-- | drivers/base/regmap/regcache-lzo.c | 6 | ||||
-rw-r--r-- | drivers/base/regmap/regcache-rbtree.c | 9 | ||||
-rw-r--r-- | drivers/base/regmap/regmap-irq.c | 13 | ||||
-rw-r--r-- | drivers/base/regmap/regmap.c | 16 | ||||
-rw-r--r-- | include/linux/regmap.h | 2 |
6 files changed, 25 insertions, 23 deletions
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c index 0246f44ded74..686c9e0b930e 100644 --- a/drivers/base/regmap/regcache-flat.c +++ b/drivers/base/regmap/regcache-flat.c | |||
@@ -21,7 +21,7 @@ static int regcache_flat_init(struct regmap *map) | |||
21 | int i; | 21 | int i; |
22 | unsigned int *cache; | 22 | unsigned int *cache; |
23 | 23 | ||
24 | map->cache = kzalloc(sizeof(unsigned int) * (map->max_register + 1), | 24 | map->cache = kcalloc(map->max_register + 1, sizeof(unsigned int), |
25 | GFP_KERNEL); | 25 | GFP_KERNEL); |
26 | if (!map->cache) | 26 | if (!map->cache) |
27 | return -ENOMEM; | 27 | return -ENOMEM; |
diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c index 736e0d378567..6f77d7319fc6 100644 --- a/drivers/base/regmap/regcache-lzo.c +++ b/drivers/base/regmap/regcache-lzo.c | |||
@@ -139,7 +139,7 @@ static int regcache_lzo_init(struct regmap *map) | |||
139 | ret = 0; | 139 | ret = 0; |
140 | 140 | ||
141 | blkcount = regcache_lzo_block_count(map); | 141 | blkcount = regcache_lzo_block_count(map); |
142 | map->cache = kzalloc(blkcount * sizeof *lzo_blocks, | 142 | map->cache = kcalloc(blkcount, sizeof(*lzo_blocks), |
143 | GFP_KERNEL); | 143 | GFP_KERNEL); |
144 | if (!map->cache) | 144 | if (!map->cache) |
145 | return -ENOMEM; | 145 | return -ENOMEM; |
@@ -152,8 +152,8 @@ static int regcache_lzo_init(struct regmap *map) | |||
152 | * that register. | 152 | * that register. |
153 | */ | 153 | */ |
154 | bmp_size = map->num_reg_defaults_raw; | 154 | bmp_size = map->num_reg_defaults_raw; |
155 | sync_bmp = kmalloc(BITS_TO_LONGS(bmp_size) * sizeof(long), | 155 | sync_bmp = kmalloc_array(BITS_TO_LONGS(bmp_size), sizeof(long), |
156 | GFP_KERNEL); | 156 | GFP_KERNEL); |
157 | if (!sync_bmp) { | 157 | if (!sync_bmp) { |
158 | ret = -ENOMEM; | 158 | ret = -ENOMEM; |
159 | goto err; | 159 | goto err; |
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index 56486d92c4e7..9d7ced559cba 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c | |||
@@ -361,13 +361,14 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg) | |||
361 | rbnode->base_reg = reg; | 361 | rbnode->base_reg = reg; |
362 | } | 362 | } |
363 | 363 | ||
364 | rbnode->block = kmalloc(rbnode->blklen * map->cache_word_size, | 364 | rbnode->block = kmalloc_array(rbnode->blklen, map->cache_word_size, |
365 | GFP_KERNEL); | 365 | GFP_KERNEL); |
366 | if (!rbnode->block) | 366 | if (!rbnode->block) |
367 | goto err_free; | 367 | goto err_free; |
368 | 368 | ||
369 | rbnode->cache_present = kzalloc(BITS_TO_LONGS(rbnode->blklen) * | 369 | rbnode->cache_present = kcalloc(BITS_TO_LONGS(rbnode->blklen), |
370 | sizeof(*rbnode->cache_present), GFP_KERNEL); | 370 | sizeof(*rbnode->cache_present), |
371 | GFP_KERNEL); | ||
371 | if (!rbnode->cache_present) | 372 | if (!rbnode->cache_present) |
372 | goto err_free_block; | 373 | goto err_free_block; |
373 | 374 | ||
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 8d16db533527..4d2cb21254aa 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c | |||
@@ -386,23 +386,23 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, | |||
386 | if (!d) | 386 | if (!d) |
387 | return -ENOMEM; | 387 | return -ENOMEM; |
388 | 388 | ||
389 | d->status_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, | 389 | d->status_buf = kcalloc(chip->num_regs, sizeof(unsigned int), |
390 | GFP_KERNEL); | 390 | GFP_KERNEL); |
391 | if (!d->status_buf) | 391 | if (!d->status_buf) |
392 | goto err_alloc; | 392 | goto err_alloc; |
393 | 393 | ||
394 | d->mask_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, | 394 | d->mask_buf = kcalloc(chip->num_regs, sizeof(unsigned int), |
395 | GFP_KERNEL); | 395 | GFP_KERNEL); |
396 | if (!d->mask_buf) | 396 | if (!d->mask_buf) |
397 | goto err_alloc; | 397 | goto err_alloc; |
398 | 398 | ||
399 | d->mask_buf_def = kzalloc(sizeof(unsigned int) * chip->num_regs, | 399 | d->mask_buf_def = kcalloc(chip->num_regs, sizeof(unsigned int), |
400 | GFP_KERNEL); | 400 | GFP_KERNEL); |
401 | if (!d->mask_buf_def) | 401 | if (!d->mask_buf_def) |
402 | goto err_alloc; | 402 | goto err_alloc; |
403 | 403 | ||
404 | if (chip->wake_base) { | 404 | if (chip->wake_base) { |
405 | d->wake_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, | 405 | d->wake_buf = kcalloc(chip->num_regs, sizeof(unsigned int), |
406 | GFP_KERNEL); | 406 | GFP_KERNEL); |
407 | if (!d->wake_buf) | 407 | if (!d->wake_buf) |
408 | goto err_alloc; | 408 | goto err_alloc; |
@@ -422,8 +422,9 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, | |||
422 | 422 | ||
423 | if (!map->use_single_read && map->reg_stride == 1 && | 423 | if (!map->use_single_read && map->reg_stride == 1 && |
424 | d->irq_reg_stride == 1) { | 424 | d->irq_reg_stride == 1) { |
425 | d->status_reg_buf = kmalloc(map->format.val_bytes * | 425 | d->status_reg_buf = kmalloc_array(chip->num_regs, |
426 | chip->num_regs, GFP_KERNEL); | 426 | map->format.val_bytes, |
427 | GFP_KERNEL); | ||
427 | if (!d->status_reg_buf) | 428 | if (!d->status_reg_buf) |
428 | goto err_alloc; | 429 | goto err_alloc; |
429 | } | 430 | } |
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 4ac63c0e50c7..a8f6dd9457be 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -1513,7 +1513,7 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val) | |||
1513 | { | 1513 | { |
1514 | int ret; | 1514 | int ret; |
1515 | 1515 | ||
1516 | if (reg % map->reg_stride) | 1516 | if (!IS_ALIGNED(reg, map->reg_stride)) |
1517 | return -EINVAL; | 1517 | return -EINVAL; |
1518 | 1518 | ||
1519 | map->lock(map->lock_arg); | 1519 | map->lock(map->lock_arg); |
@@ -1540,7 +1540,7 @@ int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val) | |||
1540 | { | 1540 | { |
1541 | int ret; | 1541 | int ret; |
1542 | 1542 | ||
1543 | if (reg % map->reg_stride) | 1543 | if (!IS_ALIGNED(reg, map->reg_stride)) |
1544 | return -EINVAL; | 1544 | return -EINVAL; |
1545 | 1545 | ||
1546 | map->lock(map->lock_arg); | 1546 | map->lock(map->lock_arg); |
@@ -1714,7 +1714,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | |||
1714 | 1714 | ||
1715 | if (map->bus && !map->format.parse_inplace) | 1715 | if (map->bus && !map->format.parse_inplace) |
1716 | return -EINVAL; | 1716 | return -EINVAL; |
1717 | if (reg % map->reg_stride) | 1717 | if (!IS_ALIGNED(reg, map->reg_stride)) |
1718 | return -EINVAL; | 1718 | return -EINVAL; |
1719 | 1719 | ||
1720 | /* | 1720 | /* |
@@ -1983,7 +1983,7 @@ static int _regmap_multi_reg_write(struct regmap *map, | |||
1983 | int reg = regs[i].reg; | 1983 | int reg = regs[i].reg; |
1984 | if (!map->writeable_reg(map->dev, reg)) | 1984 | if (!map->writeable_reg(map->dev, reg)) |
1985 | return -EINVAL; | 1985 | return -EINVAL; |
1986 | if (reg % map->reg_stride) | 1986 | if (!IS_ALIGNED(reg, map->reg_stride)) |
1987 | return -EINVAL; | 1987 | return -EINVAL; |
1988 | } | 1988 | } |
1989 | 1989 | ||
@@ -2133,7 +2133,7 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg, | |||
2133 | 2133 | ||
2134 | if (val_len % map->format.val_bytes) | 2134 | if (val_len % map->format.val_bytes) |
2135 | return -EINVAL; | 2135 | return -EINVAL; |
2136 | if (reg % map->reg_stride) | 2136 | if (!IS_ALIGNED(reg, map->reg_stride)) |
2137 | return -EINVAL; | 2137 | return -EINVAL; |
2138 | 2138 | ||
2139 | map->lock(map->lock_arg); | 2139 | map->lock(map->lock_arg); |
@@ -2260,7 +2260,7 @@ int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val) | |||
2260 | { | 2260 | { |
2261 | int ret; | 2261 | int ret; |
2262 | 2262 | ||
2263 | if (reg % map->reg_stride) | 2263 | if (!IS_ALIGNED(reg, map->reg_stride)) |
2264 | return -EINVAL; | 2264 | return -EINVAL; |
2265 | 2265 | ||
2266 | map->lock(map->lock_arg); | 2266 | map->lock(map->lock_arg); |
@@ -2296,7 +2296,7 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, | |||
2296 | return -EINVAL; | 2296 | return -EINVAL; |
2297 | if (val_len % map->format.val_bytes) | 2297 | if (val_len % map->format.val_bytes) |
2298 | return -EINVAL; | 2298 | return -EINVAL; |
2299 | if (reg % map->reg_stride) | 2299 | if (!IS_ALIGNED(reg, map->reg_stride)) |
2300 | return -EINVAL; | 2300 | return -EINVAL; |
2301 | if (val_count == 0) | 2301 | if (val_count == 0) |
2302 | return -EINVAL; | 2302 | return -EINVAL; |
@@ -2414,7 +2414,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, | |||
2414 | size_t val_bytes = map->format.val_bytes; | 2414 | size_t val_bytes = map->format.val_bytes; |
2415 | bool vol = regmap_volatile_range(map, reg, val_count); | 2415 | bool vol = regmap_volatile_range(map, reg, val_count); |
2416 | 2416 | ||
2417 | if (reg % map->reg_stride) | 2417 | if (!IS_ALIGNED(reg, map->reg_stride)) |
2418 | return -EINVAL; | 2418 | return -EINVAL; |
2419 | 2419 | ||
2420 | if (map->bus && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) { | 2420 | if (map->bus && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) { |
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index d68bb402120e..4d9a1a04647b 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
@@ -1021,7 +1021,7 @@ static inline void regmap_async_complete(struct regmap *map) | |||
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | static inline int regmap_register_patch(struct regmap *map, | 1023 | static inline int regmap_register_patch(struct regmap *map, |
1024 | const struct reg_default *regs, | 1024 | const struct reg_sequence *regs, |
1025 | int num_regs) | 1025 | int num_regs) |
1026 | { | 1026 | { |
1027 | WARN_ONCE(1, "regmap API is disabled"); | 1027 | WARN_ONCE(1, "regmap API is disabled"); |