Skip to content

Commit 08ef484

Browse files
committed
ASoC: da7219: Fix change notifications for tone generator frequency
The tone generator frequency control just returns 0 on successful write, not a boolean value indicating if there was a change or not. Compare what was written with the value that was there previously so that notifications are generated appropriately when the value changes. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220420133437.569229-1-broonie@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3756aa1 commit 08ef484

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sound/soc/codecs/da7219.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,27 @@ static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol,
446446
struct soc_mixer_control *mixer_ctrl =
447447
(struct soc_mixer_control *) kcontrol->private_value;
448448
unsigned int reg = mixer_ctrl->reg;
449-
__le16 val;
449+
__le16 val_new, val_old;
450450
int ret;
451451

452452
/*
453453
* Frequency value spans two 8-bit registers, lower then upper byte.
454454
* Therefore we need to convert to little endian here to align with
455455
* HW registers.
456456
*/
457-
val = cpu_to_le16(ucontrol->value.integer.value[0]);
457+
val_new = cpu_to_le16(ucontrol->value.integer.value[0]);
458458

459459
mutex_lock(&da7219->ctrl_lock);
460-
ret = regmap_raw_write(da7219->regmap, reg, &val, sizeof(val));
460+
ret = regmap_raw_read(da7219->regmap, reg, &val_old, sizeof(val_old));
461+
if (ret == 0 && (val_old != val_new))
462+
ret = regmap_raw_write(da7219->regmap, reg,
463+
&val_new, sizeof(val_new));
461464
mutex_unlock(&da7219->ctrl_lock);
462465

463-
return ret;
466+
if (ret < 0)
467+
return ret;
468+
469+
return val_old != val_new;
464470
}
465471

466472

0 commit comments

Comments
 (0)