diff mbox series

[v1,2/4] ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_sx()

Message ID 20220201155629.120510-3-broonie@kernel.org
State Accepted
Commit 7f3d90a3519680dfa23e750f80bfdefc0f5eda4a
Headers show
Series [v1,1/4] ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw() | expand

Commit Message

Mark Brown Feb. 1, 2022, 3:56 p.m. UTC
When writing out a stereo control we discard the change notification from
the first channel, meaning that events are only generated based on changes
to the second channel. Ensure that we report a change if either channel
has changed.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
 sound/soc/soc-ops.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 73c9d53de25b..f0d1aeb38346 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -413,6 +413,7 @@  int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 	int min = mc->min;
 	unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
 	int err = 0;
+	int ret;
 	unsigned int val, val_mask;
 
 	val_mask = mask << shift;
@@ -422,6 +423,7 @@  int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 	err = snd_soc_component_update_bits(component, reg, val_mask, val);
 	if (err < 0)
 		return err;
+	ret = err;
 
 	if (snd_soc_volsw_is_stereo(mc)) {
 		unsigned int val2;
@@ -432,6 +434,11 @@  int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 
 		err = snd_soc_component_update_bits(component, reg2, val_mask,
 			val2);
+
+		/* Don't discard any error code or drop change flag */
+		if (ret == 0 || err < 0) {
+			ret = err;
+		}
 	}
 	return err;
 }