[alsa-devel] [PATCH 2/3] ASoC: soc-core: add snd_soc_find_component()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Thu Sep 6 05:06:07 CEST 2018
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
ALSA SoC has snd_soc_find_dai() which find DAI from
component_list by using snd_soc_dai_link_component information.
It finds component first, and find DAI from it.
This patch adds new snd_soc_find_component() to find component.
And exising snd_soc_find_dai() uses it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
sound/soc/soc-core.c | 51 +++++++++++++++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 24d8338..c4a40dd 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -736,6 +736,31 @@ static struct snd_soc_component *soc_find_component(
return NULL;
}
+struct snd_soc_component *snd_soc_find_component(
+ const struct snd_soc_dai_link_component *dlc)
+{
+ struct snd_soc_component *component;
+ struct device_node *component_of_node;
+
+ lockdep_assert_held(&client_mutex);
+
+ /* Find CPU DAI from registered DAIs*/
+ list_for_each_entry(component, &component_list, list) {
+ component_of_node = component->dev->of_node;
+ if (!component_of_node && component->dev->parent)
+ component_of_node = component->dev->parent->of_node;
+
+ if (dlc->of_node && component_of_node != dlc->of_node)
+ continue;
+ if (dlc->name && strcmp(component->name, dlc->name))
+ continue;
+
+ return component;
+ }
+
+ return NULL;
+}
+
/**
* snd_soc_find_dai - Find a registered DAI
*
@@ -752,28 +777,18 @@ struct snd_soc_dai *snd_soc_find_dai(
{
struct snd_soc_component *component;
struct snd_soc_dai *dai;
- struct device_node *component_of_node;
-
- lockdep_assert_held(&client_mutex);
- /* Find CPU DAI from registered DAIs*/
- list_for_each_entry(component, &component_list, list) {
- component_of_node = component->dev->of_node;
- if (!component_of_node && component->dev->parent)
- component_of_node = component->dev->parent->of_node;
+ component = snd_soc_find_component(dlc);
+ if (!component)
+ return NULL;
- if (dlc->of_node && component_of_node != dlc->of_node)
- continue;
- if (dlc->name && strcmp(component->name, dlc->name))
+ list_for_each_entry(dai, &component->dai_list, list) {
+ if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
+ && (!dai->driver->name
+ || strcmp(dai->driver->name, dlc->dai_name)))
continue;
- list_for_each_entry(dai, &component->dai_list, list) {
- if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
- && (!dai->driver->name
- || strcmp(dai->driver->name, dlc->dai_name)))
- continue;
- return dai;
- }
+ return dai;
}
return NULL;
--
2.7.4
More information about the Alsa-devel
mailing list