OSDN Git Service

ASoC: soc-core: remove soc_remove_dai_links()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 2 Oct 2019 05:22:40 +0000 (14:22 +0900)
committerMark Brown <broonie@kernel.org>
Thu, 3 Oct 2019 13:36:01 +0000 (14:36 +0100)
commit7ce6088f60624805a8d3127185e2830e299849f1
tree06c7b6a15e2f8cc16c9d66d1041b2cdd196e9336
parent4dc0e7df62839d052476de0f8447f29f857cecda
ASoC: soc-core: remove soc_remove_dai_links()

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 it will be difficult to
debug.

soc_cleanup_card_resources() (a) which is paired function of
snd_soc_instantiate_card() (A) is calling soc_remove_dai_links() (*)
to remove card related resources, but it is breaking
add/remove balance (B)(b)(C)(c)(D)(d), in other words
these should be called from soc_cleanup_card_resources() (a)
from balance point of view.

More headacke is that it is using original removing method for
dai_link even though we already have snd_soc_remove_dai_link()
which is the function for it (d).

This patch removes snd_soc_remove_dai_links() and balance up code.

static void soc_remove_dai_links(...)
{
...
(b) soc_remove_link_dais(card);
(c) soc_remove_link_components(card);

for_each_card_links_safe(card, link, _link) {
...
/* it should use snd_soc_remove_dai_link() here */
(d) list_del(&link->list);
}
}

(a) static int soc_cleanup_card_resources(...)
{
...

/* remove and free each DAI */
(*) soc_remove_dai_links(card);
...
}

(A) static int snd_soc_instantiate_card(struct snd_soc_card *card)
{
...
/* add predefined DAI links to the list */
for_each_card_prelinks(card, i, dai_link)
(B) snd_soc_add_dai_link(card, dai_link);
...
/* probe all components used by DAI links on this card */
(C) ret = soc_probe_link_components(card);
...
/* probe all DAI links on this card */
(D) ret = soc_probe_link_dais(card);
...
}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875zl7bu1r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c