mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-21 03:43:03 +00:00
ASoC: dapm: Fix race condition with dapm mutex lock
In headset usecase, observe race condition for dapm mutex lock. snd_soc_dapm_put_pin_switch, snd_soc_dapm_force_enable_pin, snd_soc_dapm_set_pin APIs are updated to handle the lock correctly. Change-Id: I6910d28869dc172f80232f8fd6b11db10f52f59b Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
parent
f28b6e365b
commit
0517f5ae6f
|
@ -2175,8 +2175,10 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
|
|||
{
|
||||
struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
|
||||
|
||||
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
|
||||
if (!w) {
|
||||
dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin);
|
||||
mutex_unlock(&dapm->card->dapm_mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2187,6 +2189,7 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
|
|||
if (status == 0)
|
||||
w->force = 0;
|
||||
|
||||
mutex_unlock(&dapm->card->dapm_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3059,15 +3062,11 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
|
|||
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
||||
const char *pin = (const char *)kcontrol->private_value;
|
||||
|
||||
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
|
||||
|
||||
if (ucontrol->value.integer.value[0])
|
||||
snd_soc_dapm_enable_pin(&card->dapm, pin);
|
||||
else
|
||||
snd_soc_dapm_disable_pin(&card->dapm, pin);
|
||||
|
||||
mutex_unlock(&card->dapm_mutex);
|
||||
|
||||
snd_soc_dapm_sync(&card->dapm);
|
||||
return 0;
|
||||
}
|
||||
|
@ -3603,8 +3602,10 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
|
|||
{
|
||||
struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
|
||||
|
||||
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
|
||||
if (!w) {
|
||||
dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin);
|
||||
mutex_unlock(&dapm->card->dapm_mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -3612,6 +3613,7 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
|
|||
w->connected = 1;
|
||||
w->force = 1;
|
||||
dapm_mark_dirty(w, "force enable");
|
||||
mutex_unlock(&dapm->card->dapm_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue