firmware: cirrus: cs_dsp: Initialize debugfs_root to invalid
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 7 Mar 2024 10:53:53 +0000 (10:53 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 7 Mar 2024 13:03:54 +0000 (13:03 +0000)
Initialize debugfs_root to -ENODEV so that if the client never sets a
valid debugfs root the debugfs files will not be created.

A NULL pointer passed to any of the debugfs_create_*() functions means
"create in the root of debugfs". It doesn't mean "ignore".

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://msgid.link/r/20240307105353.40067-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/firmware/cirrus/cs_dsp.c

index 79d4254d1f9bc537be6ad3e958928b89d40efba3..9f3d665cfdcf77bc1f405a811c06799104badf7d 100644 (file)
@@ -522,7 +522,7 @@ void cs_dsp_cleanup_debugfs(struct cs_dsp *dsp)
 {
        cs_dsp_debugfs_clear(dsp);
        debugfs_remove_recursive(dsp->debugfs_root);
-       dsp->debugfs_root = NULL;
+       dsp->debugfs_root = ERR_PTR(-ENODEV);
 }
 EXPORT_SYMBOL_NS_GPL(cs_dsp_cleanup_debugfs, FW_CS_DSP);
 #else
@@ -2246,6 +2246,11 @@ static int cs_dsp_common_init(struct cs_dsp *dsp)
 
        mutex_init(&dsp->pwr_lock);
 
+#ifdef CONFIG_DEBUG_FS
+       /* Ensure this is invalid if client never provides a debugfs root */
+       dsp->debugfs_root = ERR_PTR(-ENODEV);
+#endif
+
        return 0;
 }