Skip to content

Commit 8ad13cd

Browse files
wenliangwubroonie
authored andcommitted
ASoC: soc-dapm.c: clean up debugfs for freed widget
When a widget is added to dapm via snd_soc_dapm_new_widgets, dapm_debugfs_add_widget is also called to create a corresponding debugfs file. However, when a widget is freed by snd_soc_dapm_free_widget, the corresponding debugfs is not cleared. As a result, the freed widget is still seen in the dapm directory. This patch adds dapm_debugfs_free_widget to free the debugfs of a specified widget, and it's called at snd_soc_dapm_free_widget to clean up the debugfs for freed widget. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230526093150.22923-6-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c0e7390 commit 8ad13cd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sound/soc/soc-dapm.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,6 +2216,16 @@ static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
22162216
&dapm_widget_power_fops);
22172217
}
22182218

2219+
static void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w)
2220+
{
2221+
struct snd_soc_dapm_context *dapm = w->dapm;
2222+
2223+
if (!dapm->debugfs_dapm || !w->name)
2224+
return;
2225+
2226+
debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm);
2227+
}
2228+
22192229
static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
22202230
{
22212231
debugfs_remove_recursive(dapm->debugfs_dapm);
@@ -2232,6 +2242,10 @@ static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
22322242
{
22332243
}
22342244

2245+
static inline void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w)
2246+
{
2247+
}
2248+
22352249
static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
22362250
{
22372251
}
@@ -2495,6 +2509,8 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
24952509
dapm_free_path(p);
24962510
}
24972511

2512+
dapm_debugfs_free_widget(w);
2513+
24982514
kfree(w->kcontrols);
24992515
kfree_const(w->name);
25002516
kfree_const(w->sname);

0 commit comments

Comments
 (0)