All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 2/3] ASoC: soc-core: add snd_soc_find_component()
Date: Thu, 6 Sep 2018 03:06:07 +0000	[thread overview]
Message-ID: <877ejzbabm.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87a7ovbadh.wl-kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@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@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

  parent reply	other threads:[~2018-09-06  3:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06  3:05 [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto
2018-09-06  3:05 ` [PATCH 1/3] ASoC: soc-core: manage platform name under snd_soc_init_platform() Kuninori Morimoto
2018-09-06  3:06 ` Kuninori Morimoto [this message]
2018-09-06  3:06 ` [PATCH 3/3] ASoC: soc-core: find platform by using snd_soc_find_component() Kuninori Morimoto
2018-09-11  1:56 ` [PATCH 0/3] ASoC: soc-core: use more generic method to find platform Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877ejzbabm.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.