[PATCH v4] cache: sifive_ccache: create debugfs after driver registration
From: Pengpeng Hou
Date: Wed Dec 02 2026 - 22:41:09 EST
sifive_ccache_init() creates the debugfs injection file before
registering the driver. If registration fails, the error path unmaps the
controller but leaves the file behind. Create the file only after
registration succeeds. This avoids adding a conditional remove path;
the existing guard on setup is unchanged.
Fixes: c90847bcbfb6 ("cache: sifive_ccache: Partially convert to a platform driver")
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
Changes since v3:
Defer debugfs creation instead of adding a guarded remove call on
failure.
Previous version: https://lore.kernel.org/r/20260814081334.25771-1-pengpeng@xxxxxxxxxxx
Codex assisted with patch preparation and the changelog.
Current review: Codex (Assisted-by: gpt 5).
Static review only; this revision was not built.
drivers/cache/sifive_ccache.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c
index 71d3f94987fa55e53043a06cb70f798697de1208..a7ecd8f70b475cde14599ba04cfa544a1bb56906 100644
--- a/drivers/cache/sifive_ccache.c
+++ b/drivers/cache/sifive_ccache.c
@@ -332,14 +332,14 @@ static int __init sifive_ccache_init(void)
ccache_cache_ops.get_priv_group = ccache_get_priv_group;
riscv_set_cacheinfo_ops(&ccache_cache_ops);
-#ifdef CONFIG_DEBUG_FS
- setup_sifive_debug();
-#endif
-
rc = platform_driver_register(&sifive_ccache_driver);
if (rc)
goto err_unmap;
+#ifdef CONFIG_DEBUG_FS
+ setup_sifive_debug();
+#endif
+
of_node_put(np);
return 0;
base-commit: 693c2e04e3f1d4c59af236e1211b7b8cb165a790