Skip to content

Commit fc247ea

Browse files
Demon000mehmetb0
authored andcommitted
regmap: detach regmap from dev on regmap_exit
BugLink: https://bugs.launchpad.net/bugs/2098441 commit 3061e17 upstream. At the end of __regmap_init(), if dev is not NULL, regmap_attach_dev() is called, which adds a devres reference to the regmap, to be able to retrieve a dev's regmap by name using dev_get_regmap(). When calling regmap_exit, the opposite does not happen, and the reference is kept until the dev is detached. Add a regmap_detach_dev() function and call it in regmap_exit() to make sure that the devres reference is not kept. Cc: [email protected] Fixes: 72b39f6 ("regmap: Implement dev_get_regmap()") Signed-off-by: Cosmin Tanislav <[email protected]> Rule: add Link: https://lore.kernel.org/stable/20241128130554.362486-1-demonsingur%40gmail.com Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Koichiro Den <[email protected]>
1 parent 510b8ae commit fc247ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/base/regmap/regmap.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,17 @@ int regmap_attach_dev(struct device *dev, struct regmap *map,
663663
}
664664
EXPORT_SYMBOL_GPL(regmap_attach_dev);
665665

666+
static int dev_get_regmap_match(struct device *dev, void *res, void *data);
667+
668+
static int regmap_detach_dev(struct device *dev, struct regmap *map)
669+
{
670+
if (!dev)
671+
return 0;
672+
673+
return devres_release(dev, dev_get_regmap_release,
674+
dev_get_regmap_match, (void *)map->name);
675+
}
676+
666677
static enum regmap_endian regmap_get_reg_endian(const struct regmap_bus *bus,
667678
const struct regmap_config *config)
668679
{
@@ -1531,6 +1542,7 @@ void regmap_exit(struct regmap *map)
15311542
{
15321543
struct regmap_async *async;
15331544

1545+
regmap_detach_dev(map->dev, map);
15341546
regcache_exit(map);
15351547
regmap_debugfs_exit(map);
15361548
regmap_range_exit(map);

0 commit comments

Comments
 (0)