Skip to content

Commit ae0acef

Browse files
mszyprowbroonie
authored andcommitted
regcache: use map->alloc_flags also for allocating cache
Commit fd4ebc0 ("regmap: Hold the regmap lock when allocating and freeing the cache") introduced a locking around the allocating and freeing a regmap cache, so adjust the memory allocation flags to the ones given in the regmap configuration instead of the hardcoded GFP_KERNEL. This fixes the "BUG: sleeping function called from invalid context" introduced by the mentioned commit. Fixes: fd4ebc0 ("regmap: Hold the regmap lock when allocating and freeing the cache") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://patch.msgid.link/20240828122834.3778031-1-m.szyprowski@samsung.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 290d6e5 commit ae0acef

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/base/regmap/regcache-flat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int regcache_flat_init(struct regmap *map)
2727
return -EINVAL;
2828

2929
map->cache = kcalloc(regcache_flat_get_index(map, map->max_register)
30-
+ 1, sizeof(unsigned int), GFP_KERNEL);
30+
+ 1, sizeof(unsigned int), map->alloc_flags);
3131
if (!map->cache)
3232
return -ENOMEM;
3333

drivers/base/regmap/regcache-maple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int regcache_maple_init(struct regmap *map)
348348
int ret;
349349
int range_start;
350350

351-
mt = kmalloc(sizeof(*mt), GFP_KERNEL);
351+
mt = kmalloc(sizeof(*mt), map->alloc_flags);
352352
if (!mt)
353353
return -ENOMEM;
354354
map->cache = mt;

drivers/base/regmap/regcache-rbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int regcache_rbtree_init(struct regmap *map)
187187
int i;
188188
int ret;
189189

190-
map->cache = kmalloc(sizeof *rbtree_ctx, GFP_KERNEL);
190+
map->cache = kmalloc(sizeof *rbtree_ctx, map->alloc_flags);
191191
if (!map->cache)
192192
return -ENOMEM;
193193

0 commit comments

Comments
 (0)