diff mbox series

[20/21] ASoC: soc-core: remove topology specific operation

Message ID 87zhiah754.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: soc-core cleanup - step 4 | expand

Commit Message

Kuninori Morimoto Oct. 9, 2019, 4:31 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc-core has some API which is used from topology, but it is doing
topology specific operation at soc-core.
soc-core should care about core things, and topology should care
about topology things, otherwise, it is very confusable.

For example topology type is not related to soc-core,
it is topology side issue.

This patch removes meaningless check from soc-core,
and moves topology specific operation to soc-topology.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c     | 32 --------------------------------
 sound/soc/soc-topology.c | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 34 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index bbcaac5..7904e839 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1439,20 +1439,7 @@  int snd_soc_add_dai_link(struct snd_soc_card *card,
 {
 	int ret;
 
-	if (dai_link->dobj.type
-	    && dai_link->dobj.type != SND_SOC_DOBJ_DAI_LINK) {
-		dev_err(card->dev, "Invalid dai link type %d\n",
-			dai_link->dobj.type);
-		return -EINVAL;
-	}
-
 	lockdep_assert_held(&client_mutex);
-	/*
-	 * Notify the machine driver for extra initialization
-	 * on the link created by topology.
-	 */
-	if (dai_link->dobj.type && card->add_dai_link)
-		card->add_dai_link(card, dai_link);
 
 	ret = soc_bind_dai_link(card, dai_link);
 	if (ret < 0)
@@ -1478,20 +1465,7 @@  EXPORT_SYMBOL_GPL(snd_soc_add_dai_link);
 void snd_soc_remove_dai_link(struct snd_soc_card *card,
 			     struct snd_soc_dai_link *dai_link)
 {
-	if (dai_link->dobj.type
-	    && dai_link->dobj.type != SND_SOC_DOBJ_DAI_LINK) {
-		dev_err(card->dev, "Invalid dai link type %d\n",
-			dai_link->dobj.type);
-		return;
-	}
-
 	lockdep_assert_held(&client_mutex);
-	/*
-	 * Notify the machine driver for extra destruction
-	 * on the link created by topology.
-	 */
-	if (dai_link->dobj.type && card->remove_dai_link)
-		card->remove_dai_link(card, dai_link);
 
 	list_del(&dai_link->list);
 
@@ -2613,12 +2587,6 @@  struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 	struct device *dev = component->dev;
 	struct snd_soc_dai *dai;
 
-	if (dai_drv->dobj.type &&
-	    dai_drv->dobj.type != SND_SOC_DOBJ_PCM) {
-		dev_err(dev, "Invalid dai type %d\n", dai_drv->dobj.type);
-		return NULL;
-	}
-
 	dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name);
 
 	lockdep_assert_held(&client_mutex);
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 81d2af0..92ada84 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -541,6 +541,7 @@  static void remove_link(struct snd_soc_component *comp,
 {
 	struct snd_soc_dai_link *link =
 		container_of(dobj, struct snd_soc_dai_link, dobj);
+	struct snd_soc_card *card = comp->card;
 
 	if (pass != SOC_TPLG_PASS_PCM_DAI)
 		return;
@@ -553,7 +554,12 @@  static void remove_link(struct snd_soc_component *comp,
 	kfree(link->cpus->dai_name);
 
 	list_del(&dobj->list);
-	snd_soc_remove_dai_link(comp->card, link);
+
+	/* Notify the machine driver */
+	if (card->remove_dai_link)
+		card->remove_dai_link(card, link);
+
+	snd_soc_remove_dai_link(card, link);
 	kfree(link);
 }
 
@@ -1889,6 +1895,7 @@  static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
 {
 	struct snd_soc_dai_link *link;
 	struct snd_soc_dai_link_component *dlc;
+	struct snd_soc_card *card = tplg->comp->card;
 	int ret;
 
 	/* link + cpu + codec + platform */
@@ -1945,7 +1952,11 @@  static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
 	link->dobj.type = SND_SOC_DOBJ_DAI_LINK;
 	list_add(&link->dobj.list, &tplg->comp->dobj_list);
 
-	snd_soc_add_dai_link(tplg->comp->card, link);
+	/* Notify the machine driver */
+	if (card->add_dai_link)
+		card->add_dai_link(card, link);
+
+	snd_soc_add_dai_link(card, link);
 	return 0;
 }