[alsa-devel] [PATCH 03/13] ASoC: dapm: add snd_soc_dapm_route_scan macro for DAPM route

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Fri Mar 13 02:22:11 CET 2015


From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>

snd_soc_dapm_add_route() searches DAPM sink/source path for DAPM,
but it is using unreadable raw code for complex path searching.
This patch adds new snd_soc_dapm_route_scan() macro for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 sound/soc/soc-dapm.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index b6f8820..d4b331d 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2403,6 +2403,15 @@ err:
 	return ret;
 }
 
+#define snd_soc_dapm_route_scan(w, dapm, name, wnode, wtnode, node)	\
+if (name && (!*wnode && !(strcmp(name, node)))) {	\
+	*wtnode = w;					\
+	if (w->dapm == dapm)				\
+		*wnode = w;				\
+	continue;					\
+}
+
+
 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 				  const struct snd_soc_dapm_route *route)
 {
@@ -2433,17 +2442,8 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
 	 * current DAPM context
 	 */
 	list_for_each_entry(w, &dapm->card->widgets, list) {
-		if (!wsink && !(strcmp(w->name, sink))) {
-			wtsink = w;
-			if (w->dapm == dapm)
-				wsink = w;
-			continue;
-		}
-		if (!wsource && !(strcmp(w->name, source))) {
-			wtsource = w;
-			if (w->dapm == dapm)
-				wsource = w;
-		}
+		snd_soc_dapm_route_scan(w, dapm, w->name, &wsource, &wtsource, source);
+		snd_soc_dapm_route_scan(w, dapm, w->name, &wsink,   &wtsink,   sink);
 	}
 	/* use widget from another DAPM context if not found from this */
 	if (!wsink)
-- 
1.9.1



More information about the Alsa-devel mailing list