Commit d5d1e0be authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: Move DAPM widget debugfs entry creation to snd_soc_dapm_new_widgets

Currently debugfs entries for a DAPM widgets are only added in
snd_soc_dapm_debugfs_init. If a widget is added later (for example in the
dai_link's probe callback) it will not show up in debugfs.
This patch moves the creation of the widget debugfs entry to
snd_soc_dapm_new_widgets where it will be added after the widget has been
properly instantiated.

As a side-effect this will also reduce the number of times the DAPM widget list
is iterated during a card's instantiation.

Since it is possible that snd_soc_dapm_new_widgets is invoked form the codecs or
cards probe callbacks, the creation of the debugfs dapm directory has to be
moved before these are called.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 8eecaf62
...@@ -1493,6 +1493,8 @@ static int soc_probe_codec(struct snd_soc_card *card, ...@@ -1493,6 +1493,8 @@ static int soc_probe_codec(struct snd_soc_card *card,
if (!try_module_get(codec->dev->driver->owner)) if (!try_module_get(codec->dev->driver->owner))
return -ENODEV; return -ENODEV;
soc_init_codec_debugfs(codec);
if (driver->probe) { if (driver->probe) {
ret = driver->probe(codec); ret = driver->probe(codec);
if (ret < 0) { if (ret < 0) {
...@@ -1513,8 +1515,6 @@ static int soc_probe_codec(struct snd_soc_card *card, ...@@ -1513,8 +1515,6 @@ static int soc_probe_codec(struct snd_soc_card *card,
snd_soc_dapm_add_routes(&codec->dapm, driver->dapm_routes, snd_soc_dapm_add_routes(&codec->dapm, driver->dapm_routes,
driver->num_dapm_routes); driver->num_dapm_routes);
soc_init_codec_debugfs(codec);
/* mark codec as probed and add to card codec list */ /* mark codec as probed and add to card codec list */
codec->probed = 1; codec->probed = 1;
list_add(&codec->card_list, &card->codec_dev_list); list_add(&codec->card_list, &card->codec_dev_list);
...@@ -1523,6 +1523,7 @@ static int soc_probe_codec(struct snd_soc_card *card, ...@@ -1523,6 +1523,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
return 0; return 0;
err_probe: err_probe:
soc_cleanup_codec_debugfs(codec);
module_put(codec->dev->driver->owner); module_put(codec->dev->driver->owner);
return ret; return ret;
...@@ -1873,6 +1874,10 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) ...@@ -1873,6 +1874,10 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
card->dapm.card = card; card->dapm.card = card;
list_add(&card->dapm.list, &card->dapm_list); list_add(&card->dapm.list, &card->dapm_list);
#ifdef CONFIG_DEBUG_FS
snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root);
#endif
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
/* deferred resume work */ /* deferred resume work */
INIT_WORK(&card->deferred_resume_work, soc_resume_deferred); INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
...@@ -1919,10 +1924,6 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) ...@@ -1919,10 +1924,6 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
card->num_dapm_routes); card->num_dapm_routes);
#ifdef CONFIG_DEBUG_FS
snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root);
#endif
snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
"%s", card->name); "%s", card->name);
snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
......
...@@ -1257,7 +1257,6 @@ static const struct file_operations dapm_bias_fops = { ...@@ -1257,7 +1257,6 @@ static const struct file_operations dapm_bias_fops = {
void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
struct dentry *parent) struct dentry *parent)
{ {
struct snd_soc_dapm_widget *w;
struct dentry *d; struct dentry *d;
dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); dapm->debugfs_dapm = debugfs_create_dir("dapm", parent);
...@@ -1274,10 +1273,15 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, ...@@ -1274,10 +1273,15 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
if (!d) if (!d)
dev_warn(dapm->dev, dev_warn(dapm->dev,
"ASoC: Failed to create bias level debugfs file\n"); "ASoC: Failed to create bias level debugfs file\n");
}
list_for_each_entry(w, &dapm->card->widgets, list) { static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
if (!w->name || w->dapm != dapm) {
continue; struct snd_soc_dapm_context *dapm = w->dapm;
struct dentry *d;
if (!dapm->debugfs_dapm || !w->name)
return;
d = debugfs_create_file(w->name, 0444, d = debugfs_create_file(w->name, 0444,
dapm->debugfs_dapm, w, dapm->debugfs_dapm, w,
...@@ -1286,13 +1290,18 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, ...@@ -1286,13 +1290,18 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
dev_warn(w->dapm->dev, dev_warn(w->dapm->dev,
"ASoC: Failed to create %s debugfs file\n", "ASoC: Failed to create %s debugfs file\n",
w->name); w->name);
}
} }
#else #else
void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
struct dentry *parent) struct dentry *parent)
{ {
} }
static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
{
}
#endif #endif
/* test and update the power status of a mux widget */ /* test and update the power status of a mux widget */
...@@ -1765,6 +1774,8 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm) ...@@ -1765,6 +1774,8 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
} }
w->new = 1; w->new = 1;
dapm_debugfs_add_widget(w);
} }
dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP); dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment