ASoC: soc-core: add snd_soc_unregister_dai()

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and is difficult to debug.

This patch adds missing soc_del_dai() and snd_soc_unregister_dai().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87v9ry251z.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2019-11-05 15:47:04 +09:00 committed by Mark Brown
parent 3f6674ae13
commit e11381f38f
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 15 additions and 5 deletions

View File

@ -1328,6 +1328,7 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
int snd_soc_register_dai(struct snd_soc_component *component, int snd_soc_register_dai(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv); struct snd_soc_dai_driver *dai_drv);
void snd_soc_unregister_dai(struct snd_soc_dai *dai);
struct snd_soc_dai *snd_soc_find_dai( struct snd_soc_dai *snd_soc_find_dai(
const struct snd_soc_dai_link_component *dlc); const struct snd_soc_dai_link_component *dlc);

View File

@ -2532,6 +2532,12 @@ static inline char *fmt_multiple_name(struct device *dev,
return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL); return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL);
} }
static void soc_del_dai(struct snd_soc_dai *dai)
{
dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name);
list_del(&dai->list);
}
/* Create a DAI and add it to the component's DAI list */ /* Create a DAI and add it to the component's DAI list */
static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component, static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv, struct snd_soc_dai_driver *dai_drv,
@ -2581,6 +2587,12 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
return dai; return dai;
} }
void snd_soc_unregister_dai(struct snd_soc_dai *dai)
{
soc_del_dai(dai);
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
/** /**
* snd_soc_register_dai - Register a DAI dynamically & create its widgets * snd_soc_register_dai - Register a DAI dynamically & create its widgets
* *
@ -2633,11 +2645,8 @@ static void snd_soc_unregister_dais(struct snd_soc_component *component)
{ {
struct snd_soc_dai *dai, *_dai; struct snd_soc_dai *dai, *_dai;
for_each_component_dais_safe(component, dai, _dai) { for_each_component_dais_safe(component, dai, _dai)
dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n", snd_soc_unregister_dai(dai);
dai->name);
list_del(&dai->list);
}
} }
/** /**