Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: dapm: fix prefixed stream name matching in snd_soc_dapm_link_dai_widgets
@ 2015-06-05 13:41 Arnaud Mouiche
  2015-06-05 14:12 ` arnaud.mouiche
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaud Mouiche @ 2015-06-05 13:41 UTC (permalink / raw)
  To: alsa-devel; +Cc: Arnaud Mouiche

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 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index e19a676..7194df4 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:
@@ -3416,6 +3419,8 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
 			}
 
 			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) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-05 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05 13:41 [PATCH] ASoC: dapm: fix prefixed stream name matching in snd_soc_dapm_link_dai_widgets Arnaud Mouiche
2015-06-05 14:12 ` arnaud.mouiche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox