[PATCH] soc: mediatek: mtk-svs: clean up debugfs entries
Pengpeng Hou
pengpeng at iscas.ac.cn
Tue Jun 16 08:14:06 PDT 2026
svs_create_debug_cmds() publishes debugfs files whose private data points
at the SVS platform and bank state, but neither partial debugfs creation
failures nor device teardown remove the tree before that state is
released.
Remove the debugfs tree on partial creation failures and register a devm
action so successful probes remove the tree before devm-managed SVS state
is freed.
Signed-off-by: Pengpeng Hou <pengpeng at iscas.ac.cn>
---
drivers/soc/mediatek/mtk-svs.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 99edecb204f2..2caab6a89698 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -172,6 +172,11 @@ static DEFINE_SPINLOCK(svs_lock);
}
#define svs_dentry_data(name) {__stringify(name), &svs_##name##_debug_fops}
+
+static void svs_remove_debug_cmds(void *data)
+{
+ debugfs_remove_recursive(data);
+}
#endif
/**
@@ -887,7 +892,7 @@ static int svs_create_debug_cmds(struct svs_platform *svsp)
if (IS_ERR(file_entry)) {
dev_err(svsp->dev, "cannot create %s/%s: %ld\n",
d, svs_entries[i].name, PTR_ERR(file_entry));
- return PTR_ERR(file_entry);
+ goto err_remove_debugfs;
}
}
@@ -901,7 +906,8 @@ static int svs_create_debug_cmds(struct svs_platform *svsp)
if (IS_ERR(svsb_dir)) {
dev_err(svsp->dev, "cannot create %s/%s: %ld\n",
d, svsb->name, PTR_ERR(svsb_dir));
- return PTR_ERR(svsb_dir);
+ file_entry = svsb_dir;
+ goto err_remove_debugfs;
}
for (i = 0; i < ARRAY_SIZE(svsb_entries); i++) {
@@ -912,12 +918,17 @@ static int svs_create_debug_cmds(struct svs_platform *svsp)
dev_err(svsp->dev, "no %s/%s/%s?: %ld\n",
d, svsb->name, svsb_entries[i].name,
PTR_ERR(file_entry));
- return PTR_ERR(file_entry);
+ goto err_remove_debugfs;
}
}
}
- return 0;
+ return devm_add_action_or_reset(svsp->dev, svs_remove_debug_cmds,
+ svs_dir);
+
+err_remove_debugfs:
+ debugfs_remove_recursive(svs_dir);
+ return PTR_ERR(file_entry);
}
#endif /* CONFIG_DEBUG_FS */
--
2.43.0
More information about the linux-arm-kernel
mailing list