Skip to content

Commit 41dbc03

Browse files
committed
Merge remote-tracking branch 'regmap/for-next' into sound/upstream-20250102
2 parents 15a132e + eb708cd commit 41dbc03

5 files changed

Lines changed: 15 additions & 19 deletions

File tree

drivers/base/regmap/regcache-maple.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
7373

7474
rcu_read_unlock();
7575

76-
entry = kmalloc((last - index + 1) * sizeof(unsigned long),
77-
map->alloc_flags);
76+
entry = kmalloc_array(last - index + 1, sizeof(*entry), map->alloc_flags);
7877
if (!entry)
7978
return -ENOMEM;
8079

@@ -204,7 +203,7 @@ static int regcache_maple_sync_block(struct regmap *map, unsigned long *entry,
204203
* overheads.
205204
*/
206205
if (max - min > 1 && regmap_can_raw_write(map)) {
207-
buf = kmalloc(val_bytes * (max - min), map->alloc_flags);
206+
buf = kmalloc_array(max - min, val_bytes, map->alloc_flags);
208207
if (!buf) {
209208
ret = -ENOMEM;
210209
goto out;
@@ -320,7 +319,7 @@ static int regcache_maple_insert_block(struct regmap *map, int first,
320319
unsigned long *entry;
321320
int i, ret;
322321

323-
entry = kcalloc(last - first + 1, sizeof(unsigned long), map->alloc_flags);
322+
entry = kmalloc_array(last - first + 1, sizeof(*entry), map->alloc_flags);
324323
if (!entry)
325324
return -ENOMEM;
326325

drivers/base/regmap/regcache-rbtree.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,16 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
275275
pos = (reg - base_reg) / map->reg_stride;
276276
offset = (rbnode->base_reg - base_reg) / map->reg_stride;
277277

278-
blk = krealloc(rbnode->block,
279-
blklen * map->cache_word_size,
280-
map->alloc_flags);
278+
blk = krealloc_array(rbnode->block, blklen, map->cache_word_size, map->alloc_flags);
281279
if (!blk)
282280
return -ENOMEM;
283281

284282
rbnode->block = blk;
285283

286284
if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
287-
present = krealloc(rbnode->cache_present,
288-
BITS_TO_LONGS(blklen) * sizeof(*present),
289-
map->alloc_flags);
285+
present = krealloc_array(rbnode->cache_present,
286+
BITS_TO_LONGS(blklen), sizeof(*present),
287+
map->alloc_flags);
290288
if (!present)
291289
return -ENOMEM;
292290

drivers/base/regmap/regcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
154154
map->num_reg_defaults = config->num_reg_defaults;
155155
map->num_reg_defaults_raw = config->num_reg_defaults_raw;
156156
map->reg_defaults_raw = config->reg_defaults_raw;
157-
map->cache_word_size = DIV_ROUND_UP(config->val_bits, 8);
157+
map->cache_word_size = BITS_TO_BYTES(config->val_bits);
158158
map->cache_size_raw = map->cache_word_size * config->num_reg_defaults_raw;
159159

160160
map->cache = NULL;

drivers/base/regmap/regmap.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,13 @@ struct regmap *__regmap_init(struct device *dev,
769769
map->alloc_flags = GFP_KERNEL;
770770

771771
map->reg_base = config->reg_base;
772+
map->reg_shift = config->pad_bits % 8;
772773

773-
map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
774774
map->format.pad_bytes = config->pad_bits / 8;
775775
map->format.reg_shift = config->reg_shift;
776-
map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
777-
map->format.buf_size = DIV_ROUND_UP(config->reg_bits +
778-
config->val_bits + config->pad_bits, 8);
779-
map->reg_shift = config->pad_bits % 8;
776+
map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
777+
map->format.val_bytes = BITS_TO_BYTES(config->val_bits);
778+
map->format.buf_size = BITS_TO_BYTES(config->reg_bits + config->val_bits + config->pad_bits);
780779
if (config->reg_stride)
781780
map->reg_stride = config->reg_stride;
782781
else
@@ -3116,7 +3115,7 @@ int regmap_fields_read(struct regmap_field *field, unsigned int id,
31163115
EXPORT_SYMBOL_GPL(regmap_fields_read);
31173116

31183117
static int _regmap_bulk_read(struct regmap *map, unsigned int reg,
3119-
unsigned int *regs, void *val, size_t val_count)
3118+
const unsigned int *regs, void *val, size_t val_count)
31203119
{
31213120
u32 *u32 = val;
31223121
u16 *u16 = val;
@@ -3210,7 +3209,7 @@ EXPORT_SYMBOL_GPL(regmap_bulk_read);
32103209
* A value of zero will be returned on success, a negative errno will
32113210
* be returned in error cases.
32123211
*/
3213-
int regmap_multi_reg_read(struct regmap *map, unsigned int *regs, void *val,
3212+
int regmap_multi_reg_read(struct regmap *map, const unsigned int *regs, void *val,
32143213
size_t val_count)
32153214
{
32163215
if (val_count == 0)

include/linux/regmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg,
12441244
void *val, size_t val_len);
12451245
int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
12461246
size_t val_count);
1247-
int regmap_multi_reg_read(struct regmap *map, unsigned int *reg, void *val,
1247+
int regmap_multi_reg_read(struct regmap *map, const unsigned int *reg, void *val,
12481248
size_t val_count);
12491249
int regmap_update_bits_base(struct regmap *map, unsigned int reg,
12501250
unsigned int mask, unsigned int val,

0 commit comments

Comments
 (0)