

Stephen Warren swarren at nvidia.com
Wed May 25 01:12:01 CEST 2011

function dapm_is_shared_kcontrol.

possibly a widget's naming prefix).

A bug in the implementation of dapm_is_shared_kcontrol made it return 1
all controls instead of just shared controls.

Specifically, a control is always considered shared because it is always
compared against itself. Solve this by never comparing against the widget
containing the control being created.

I tested that with the Tegra WM8903 driver:
* The expected controls are still generated after this change.

Howwever, I don't have any systems that have a widget/control naming
prefix, so I can't test that aspect.

Reported-by: Liam Girdwood <lrg at ti.com>
Root-caused-by: Jarkko Nikula <jhnikula at gmail.com>
 sound/soc/soc-dapm.c |    5 ++++-

index 456617e..5397699 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -325,6 +325,7 @@ static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm,
+	struct snd_soc_dapm_widget *kcontrolw,
 	const struct snd_kcontrol_new *kcontrol_new,
 	struct snd_kcontrol **kcontrol)
@@ -334,6 +335,8 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm,
 	*kcontrol = NULL;
 	list_for_each_entry(w, &dapm->card->widgets, list) {
+		if (w == kcontrolw)
+			continue;
 		for (i = 0; i < w->num_kcontrols; i++) {
 			if (&w->kcontrol_news[i] == kcontrol_new) {
 				if (w->kcontrols)
@@ -468,7 +471,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
 		return -EINVAL;
-	shared = dapm_is_shared_kcontrol(dapm, &w->kcontrol_news[0],
+	shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[0],
 	if (kcontrol) {
 		wlist = kcontrol->private_data;

More information about the Alsa-devel mailing list