soc: dapm: do not update register if value is invalid

Register address SND_SOC_NOPM gets updated at times
which is not desired.
Add checks to ensure this register is not updated.

Change-Id: I25284f60f42a8c5ac70f203d328005befcd95bde
Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
This commit is contained in:
Aravind Kumar 2015-05-20 15:02:10 +05:30 committed by Gerrit - the friendly Code Review server
parent 3734b49d50
commit aa1c8351fa

View file

@ -261,12 +261,16 @@ static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w,
bool change;
unsigned int old, new;
int ret;
unsigned int reg_sign = (short)reg;
if (w->codec && w->codec->using_regmap) {
ret = regmap_update_bits_check(w->codec->control_data,
if (reg_sign != SND_SOC_NOPM) {
ret = regmap_update_bits_check(w->codec->control_data,
reg, mask, value, &change);
if (ret != 0)
return ret;
if (ret != 0)
return ret;
} else
change = true;
} else {
soc_widget_lock(w);
ret = soc_widget_read(w, reg);
@ -351,12 +355,15 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert;
val = soc_widget_read(w, reg);
val = (val >> shift) & mask;
if (invert)
val = max - val;
p->connect = !!val;
if (reg != SND_SOC_NOPM) {
val = soc_widget_read(w, reg);
val = (val >> shift) & mask;
if (invert)
val = max - val;
p->connect = !!val;
} else {
p->connect = 0;
}
}
break;
case snd_soc_dapm_mux: {
@ -2661,8 +2668,9 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
"ASoC: Control '%s' is stereo, which is not supported\n",
kcontrol->id.name);
ucontrol->value.integer.value[0] =
(snd_soc_read(widget->codec, reg) >> shift) & mask;
if (reg != SND_SOC_NOPM)
ucontrol->value.integer.value[0] =
(snd_soc_read(widget->codec, reg) >> shift) & mask;
if (invert)
ucontrol->value.integer.value[0] =
max - ucontrol->value.integer.value[0];
@ -2714,7 +2722,10 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
change = snd_soc_test_bits(widget->codec, reg, mask, val);
if (reg != SND_SOC_NOPM)
change = snd_soc_test_bits(widget->codec, reg, mask, val);
else
change = true;
if (change) {
for (wi = 0; wi < wlist->num_widgets; wi++) {
widget = wlist->widgets[wi];