提交 8e9bb423 编写于 作者: M Mark Brown

ASoC: wm2000: Lock state machine updates

Need to ensure we don't get confused by simultaneous updates.
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 949db153
...@@ -76,6 +76,8 @@ struct wm2000_priv { ...@@ -76,6 +76,8 @@ struct wm2000_priv {
int anc_download_size; int anc_download_size;
char *anc_download; char *anc_download;
struct mutex lock;
}; };
static int wm2000_write(struct i2c_client *i2c, unsigned int reg, static int wm2000_write(struct i2c_client *i2c, unsigned int reg,
...@@ -599,13 +601,20 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, ...@@ -599,13 +601,20 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
int anc_active = ucontrol->value.enumerated.item[0]; int anc_active = ucontrol->value.enumerated.item[0];
int ret;
if (anc_active > 1) if (anc_active > 1)
return -EINVAL; return -EINVAL;
mutex_lock(&wm2000->lock);
wm2000->anc_active = anc_active; wm2000->anc_active = anc_active;
return wm2000_anc_set_mode(wm2000); ret = wm2000_anc_set_mode(wm2000);
mutex_unlock(&wm2000->lock);
return ret;
} }
static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, static int wm2000_speaker_get(struct snd_kcontrol *kcontrol,
...@@ -625,13 +634,20 @@ static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, ...@@ -625,13 +634,20 @@ static int wm2000_speaker_put(struct snd_kcontrol *kcontrol,
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
int val = ucontrol->value.enumerated.item[0]; int val = ucontrol->value.enumerated.item[0];
int ret;
if (val > 1) if (val > 1)
return -EINVAL; return -EINVAL;
mutex_lock(&wm2000->lock);
wm2000->spk_ena = val; wm2000->spk_ena = val;
return wm2000_anc_set_mode(wm2000); ret = wm2000_anc_set_mode(wm2000);
mutex_unlock(&wm2000->lock);
return ret;
} }
static const struct snd_kcontrol_new wm2000_controls[] = { static const struct snd_kcontrol_new wm2000_controls[] = {
...@@ -648,6 +664,9 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, ...@@ -648,6 +664,9 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w,
{ {
struct snd_soc_codec *codec = w->codec; struct snd_soc_codec *codec = w->codec;
struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
int ret;
mutex_lock(&wm2000->lock);
if (SND_SOC_DAPM_EVENT_ON(event)) if (SND_SOC_DAPM_EVENT_ON(event))
wm2000->anc_eng_ena = 1; wm2000->anc_eng_ena = 1;
...@@ -655,7 +674,11 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, ...@@ -655,7 +674,11 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w,
if (SND_SOC_DAPM_EVENT_OFF(event)) if (SND_SOC_DAPM_EVENT_OFF(event))
wm2000->anc_eng_ena = 0; wm2000->anc_eng_ena = 0;
return wm2000_anc_set_mode(wm2000); ret = wm2000_anc_set_mode(wm2000);
mutex_unlock(&wm2000->lock);
return ret;
} }
static const struct snd_soc_dapm_widget wm2000_dapm_widgets[] = { static const struct snd_soc_dapm_widget wm2000_dapm_widgets[] = {
...@@ -782,6 +805,8 @@ static int wm2000_i2c_probe(struct i2c_client *i2c, ...@@ -782,6 +805,8 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
return -ENOMEM; return -ENOMEM;
} }
mutex_init(&wm2000->lock);
dev_set_drvdata(&i2c->dev, wm2000); dev_set_drvdata(&i2c->dev, wm2000);
wm2000->regmap = devm_regmap_init_i2c(i2c, &wm2000_regmap); wm2000->regmap = devm_regmap_init_i2c(i2c, &wm2000_regmap);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册