diff mbox

[v2] ASoC: dapm: fix prefixed stream name matching in snd_soc_dapm_link_dai_widgets

Message ID 1433522305-10339-1-git-send-email-arnaud.mouiche@invoxia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arnaud Mouiche June 5, 2015, 4:38 p.m. UTC
commit "ASoC: dapm: Modify widget stream name according to prefix"
fixed a part of the problem when dai_w->name and w->sname are equal
before being prefixed.

Remains the case where w->sname is only a sub string of dai_w->name.

For example, TLV320AIC3x codec defines the widget
	SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0)

In snd_soc_dapm_link_dai_widgets, we will failed to match
	"[prefix] Left Playback"
with
	"[prefix] Playback".

Since dai_w and w necessarily belongs to the same dapm when strstr()
is called, they necessarily have the same prefix which allow us to
compare 'w->sname + prefix_len' with  'dai_w->name + prefix_len' directly
without length check.

Signed-off-by: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
---
 sound/soc/soc-dapm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index e19a676..fc4408b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3392,6 +3392,9 @@  int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
 
 	/* For each DAI widget... */
 	list_for_each_entry(dai_w, &card->widgets, list) {
+		const char *prefix = soc_dapm_prefix(dai_w->dapm);
+		size_t prefix_len = prefix ? strlen(prefix)+1 : 0;
+
 		switch (dai_w->id) {
 		case snd_soc_dapm_dai_in:
 		case snd_soc_dapm_dai_out:
@@ -3415,7 +3418,8 @@  int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
 				break;
 			}
 
-			if (!w->sname || !strstr(w->sname, dai_w->name))
+			if (!w->sname ||
+			    !strstr(w->sname + prefix_len, dai_w->name + prefix_len))
 				continue;
 
 			if (dai_w->id == snd_soc_dapm_dai_in) {