Merge branch 'for-5.5' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-2.6-microblaze.git] / sound / soc / soc-topology.c
index 92e4f4d..69d6a52 100644 (file)
@@ -549,7 +549,8 @@ static void remove_link(struct snd_soc_component *comp,
                dobj->ops->link_unload(comp, dobj);
 
        list_del(&dobj->list);
-       snd_soc_remove_dai_link(comp->card, link);
+       snd_soc_remove_pcm_runtime(comp->card,
+                       snd_soc_get_pcm_runtime(comp->card, link));
 
        kfree(link->name);
        kfree(link->stream_name);
@@ -1936,7 +1937,7 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
                goto err;
        }
 
-       ret = snd_soc_add_dai_link(tplg->comp->card, link);
+       ret = snd_soc_add_pcm_runtime(tplg->comp->card, link);
        if (ret < 0) {
                dev_err(tplg->comp->dev, "ASoC: adding FE link failed\n");
                goto err;
@@ -2220,6 +2221,47 @@ static int link_new_ver(struct soc_tplg *tplg,
        return 0;
 }
 
+/**
+ * snd_soc_find_dai_link - Find a DAI link
+ *
+ * @card: soc card
+ * @id: DAI link ID to match
+ * @name: DAI link name to match, optional
+ * @stream_name: DAI link stream name to match, optional
+ *
+ * This function will search all existing DAI links of the soc card to
+ * find the link of the same ID. Since DAI links may not have their
+ * unique ID, so name and stream name should also match if being
+ * specified.
+ *
+ * Return: pointer of DAI link, or NULL if not found.
+ */
+static struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
+                                                     int id, const char *name,
+                                                     const char *stream_name)
+{
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai_link *link;
+
+       for_each_card_rtds(card, rtd) {
+               link = rtd->dai_link;
+
+               if (link->id != id)
+                       continue;
+
+               if (name && (!link->name || strcmp(name, link->name)))
+                       continue;
+
+               if (stream_name && (!link->stream_name
+                                   || strcmp(stream_name, link->stream_name)))
+                       continue;
+
+               return link;
+       }
+
+       return NULL;
+}
+
 /* Find and configure an existing physical DAI link */
 static int soc_tplg_link_config(struct soc_tplg *tplg,
        struct snd_soc_tplg_link_config *cfg)