Skip to contentSkip to conversation

ASoC: max9877: Update register if either val or val2 is changed

PATCH Applied Axel Lin 2 participants 2 messages Nov 22, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

In the case of ((max9877_regs[reg] >> shift) & mask) != val but ((max9877_regs[reg2] >> shift) & mask) == val2, current code does not update the registers.

Fix the logic to update registers if either val or val2 is changed.

---
 sound/soc/codecs/max9877.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/max9877.c +5 -5
index 9e7e964..dcf6f2a 100644
@@ -106,13 +106,13 @@ static int max9877_set_2reg(struct snd_kcontrol *kcontrol,
 	unsigned int mask = mc->max;
 	unsigned int val = (ucontrol->value.integer.value[0] & mask);
 	unsigned int val2 = (ucontrol->value.integer.value[1] & mask);
-	unsigned int change = 1;
+	unsigned int change = 0;
 
-	if (((max9877_regs[reg] >> shift) & mask) == val)
-		change = 0;
+	if (((max9877_regs[reg] >> shift) & mask) != val)
+		change = 1;
 
-	if (((max9877_regs[reg2] >> shift) & mask) == val2)
-		change = 0;
+	if (((max9877_regs[reg2] >> shift) & mask) != val2)
+		change = 1;
 
 	if (change) {
 		max9877_regs[reg] &= ~(mask << shift);
Signature · 1 line
1.7.5.4
Applied
#1 lore raw
Quoted 3 lines · Axel Lin

In the case of ((max9877_regs[reg] >> shift) & mask) != val but ((max9877_regs[reg2] >> shift) & mask) == val2, current code does not update the registers.

Applied, thanks.