ASoC: soc-core: don't use soc_find_component() at snd_soc_find_dai()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 26 Jun 2019 01:40:59 +0000 (10:40 +0900)
committerMark Brown <broonie@kernel.org>
Wed, 26 Jun 2019 11:28:56 +0000 (12:28 +0100)
commit b9f2e25c599bb ("ASoC: soc-core: use soc_find_component() at
snd_soc_find_dai()") used soc_find_component() at snd_soc_find_dai(),
but, some CPU driver has CPU component for DAI and Platform component,
for example generic DMAEngine component.
In such case, CPU component and Platform component have same
of_node / name.

Here soc_find_component() returns *1st* found component.
Thus, we shouldn't use soc_find_component() at snd_soc_find_dai().
This patch fixup this it, and add comment to indicate this limitation.

Fixes: commit b9f2e25c599bb ("ASoC: soc-core: use soc_find_component() at snd_soc_find_dai()")
Reported-by: Dmitry Osipenko <digetx@gmail.com>
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 358f1fbf9a300b16b5d73473de5a78f1c7d42fb0..8ccaf63e428c4874bb5e02b5f688c0db9f19eddb 100644 (file)
@@ -786,6 +786,14 @@ static struct snd_soc_component *soc_find_component(
 
        lockdep_assert_held(&client_mutex);
 
+       /*
+        * NOTE
+        *
+        * It returns *1st* found component, but some driver
+        * has few components by same of_node/name
+        * ex)
+        *      CPU component and generic DMAEngine component
+        */
        for_each_component(component)
                if (snd_soc_is_matching_component(dlc, component))
                        return component;
@@ -813,8 +821,9 @@ struct snd_soc_dai *snd_soc_find_dai(
        lockdep_assert_held(&client_mutex);
 
        /* Find CPU DAI from registered DAIs */
-       component = soc_find_component(dlc);
-       if (component) {
+       for_each_component(component) {
+               if (!snd_soc_is_matching_component(dlc, component))
+                       continue;
                for_each_component_dais(component, dai) {
                        if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
                            && (!dai->driver->name