diff mbox

[03/13] ASoC: dapm: add snd_soc_dapm_route_scan macro for DAPM route

Message ID 87y4n1r8sx.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kuninori Morimoto March 13, 2015, 1:22 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@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@renesas.com>
---
 sound/soc/soc-dapm.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff mbox

Patch

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)