Commit 827b0913 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mark Brown

ASoC: DAPM: Cover regression by kctl change notification fix

The recent fix for DAPM to correct the kctl change notification by the
commit 5af82c81 ("ASoC: DAPM: Fix missing kctl change
notifications") caused other regressions since it changed the behavior
of snd_soc_dapm_set_pin() that is called from several API functions.
Formerly it returned always 0 for success, but now it returns 0 or 1.

This patch addresses it, restoring the old behavior of
snd_soc_dapm_set_pin() while keeping the fix in
snd_soc_dapm_put_pin_switch().

Fixes: 5af82c81 ("ASoC: DAPM: Fix missing kctl change notifications")
Reported-by: default avatarYu-Hsuan Hsu <yuhsuan@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20211105090925.20575-1-tiwai@suse.deSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fd572393
...@@ -2559,8 +2559,13 @@ static struct snd_soc_dapm_widget *dapm_find_widget( ...@@ -2559,8 +2559,13 @@ static struct snd_soc_dapm_widget *dapm_find_widget(
return NULL; return NULL;
} }
static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, /*
const char *pin, int status) * set the DAPM pin status:
* returns 1 when the value has been updated, 0 when unchanged, or a negative
* error code; called from kcontrol put callback
*/
static int __snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
const char *pin, int status)
{ {
struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
int ret = 0; int ret = 0;
...@@ -2586,6 +2591,18 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, ...@@ -2586,6 +2591,18 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
return ret; return ret;
} }
/*
* similar as __snd_soc_dapm_set_pin(), but returns 0 when successful;
* called from several API functions below
*/
static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
const char *pin, int status)
{
int ret = __snd_soc_dapm_set_pin(dapm, pin, status);
return ret < 0 ? ret : 0;
}
/** /**
* snd_soc_dapm_sync_unlocked - scan and power dapm paths * snd_soc_dapm_sync_unlocked - scan and power dapm paths
* @dapm: DAPM context * @dapm: DAPM context
...@@ -3589,10 +3606,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, ...@@ -3589,10 +3606,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
const char *pin = (const char *)kcontrol->private_value; const char *pin = (const char *)kcontrol->private_value;
int ret; int ret;
if (ucontrol->value.integer.value[0]) mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
ret = snd_soc_dapm_enable_pin(&card->dapm, pin); ret = __snd_soc_dapm_set_pin(&card->dapm, pin,
else !!ucontrol->value.integer.value[0]);
ret = snd_soc_dapm_disable_pin(&card->dapm, pin); mutex_unlock(&card->dapm_mutex);
snd_soc_dapm_sync(&card->dapm); snd_soc_dapm_sync(&card->dapm);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment