[PATCH 4.4 32/44] ASoC: DAPM: Fix missing kctl change notifications

From: Greg Kroah-Hartman
Date: Mon Oct 25 2021 - 15:16:48 EST


From: Takashi Iwai <tiwai@xxxxxxx>

commit 5af82c81b2c49cfb1cad84d9eb6eab0e3d1c4842 upstream.

The put callback of a kcontrol is supposed to return 1 when the value
is changed, and this will be notified to user-space. However, some
DAPM kcontrols always return 0 (except for errors), hence the
user-space misses the update of a control value.

This patch corrects the behavior by properly returning 1 when the
value gets updated.

Reported-and-tested-by: Hans de Goede <hdegoede@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Link: https://lore.kernel.org/r/20211006141712.2439-1-tiwai@xxxxxxx
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
sound/soc/soc-dapm.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2377,6 +2377,7 @@ static int snd_soc_dapm_set_pin(struct s
const char *pin, int status)
{
struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
+ int ret = 0;

dapm_assert_locked(dapm);

@@ -2389,13 +2390,14 @@ static int snd_soc_dapm_set_pin(struct s
dapm_mark_dirty(w, "pin configuration");
dapm_widget_invalidate_input_paths(w);
dapm_widget_invalidate_output_paths(w);
+ ret = 1;
}

w->connected = status;
if (status == 0)
w->force = 0;

- return 0;
+ return ret;
}

/**
@@ -3290,14 +3292,15 @@ int snd_soc_dapm_put_pin_switch(struct s
{
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
const char *pin = (const char *)kcontrol->private_value;
+ int ret;

if (ucontrol->value.integer.value[0])
- snd_soc_dapm_enable_pin(&card->dapm, pin);
+ ret = snd_soc_dapm_enable_pin(&card->dapm, pin);
else
- snd_soc_dapm_disable_pin(&card->dapm, pin);
+ ret = snd_soc_dapm_disable_pin(&card->dapm, pin);

snd_soc_dapm_sync(&card->dapm);
- return 0;
+ return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);

@@ -3657,7 +3660,7 @@ static int snd_soc_dapm_dai_link_put(str

w->params_select = ucontrol->value.enumerated.item[0];

- return 0;
+ return 1;
}

int snd_soc_dapm_new_pcm(struct snd_soc_card *card,