]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - sound/soc/soc-core.c
ASoC: soc-core: remove OF adjusting for snd_soc_of_parse_card_name
[karo-tx-linux.git] / sound / soc / soc-core.c
index f35ec5bf3b781292212ef3fa8495ca6fc8e0dac2..ebaebc7c96992abb03cc1d7d44703afc45912677 100644 (file)
@@ -972,6 +972,48 @@ struct snd_soc_dai *snd_soc_find_dai(
 }
 EXPORT_SYMBOL_GPL(snd_soc_find_dai);
 
+
+/**
+ * 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.
+ */
+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_dai_link *link, *_link;
+
+       lockdep_assert_held(&client_mutex);
+
+       list_for_each_entry_safe(link, _link, &card->dai_link_list, list) {
+               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;
+}
+EXPORT_SYMBOL_GPL(snd_soc_find_dai_link);
+
 static bool soc_is_dai_link_bound(struct snd_soc_card *card,
                struct snd_soc_dai_link *dai_link)
 {
@@ -993,6 +1035,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
        struct snd_soc_dai_link_component cpu_dai_component;
        struct snd_soc_dai **codec_dais;
        struct snd_soc_platform *platform;
+       struct device_node *platform_of_node;
        const char *platform_name;
        int i;
 
@@ -1042,9 +1085,12 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 
        /* find one from the set of registered platforms */
        list_for_each_entry(platform, &platform_list, list) {
+               platform_of_node = platform->dev->of_node;
+               if (!platform_of_node && platform->dev->parent->of_node)
+                       platform_of_node = platform->dev->parent->of_node;
+
                if (dai_link->platform_of_node) {
-                       if (platform->dev->of_node !=
-                           dai_link->platform_of_node)
+                       if (platform_of_node != dai_link->platform_of_node)
                                continue;
                } else {
                        if (strcmp(platform->component.name, platform_name))
@@ -3806,7 +3852,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
-static int snd_soc_get_dai_name(struct of_phandle_args *args,
+int snd_soc_get_dai_name(struct of_phandle_args *args,
                                const char **dai_name)
 {
        struct snd_soc_component *pos;
@@ -3858,6 +3904,7 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args,
        mutex_unlock(&client_mutex);
        return ret;
 }
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
 
 int snd_soc_of_get_dai_name(struct device_node *of_node,
                            const char **dai_name)