summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2023-12-04 12:47:35 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-13 18:45:31 +0100
commit395e52b7a1ad01e1b51adb09854a0aa5347428de (patch)
treec2072aab4c9b55751622fee1019a3e434df8d747
parent6df51c525a2d4f8cce843ced0da00452dc6f30a7 (diff)
downloadlinux-starfive-395e52b7a1ad01e1b51adb09854a0aa5347428de.tar.gz
linux-starfive-395e52b7a1ad01e1b51adb09854a0aa5347428de.tar.bz2
linux-starfive-395e52b7a1ad01e1b51adb09854a0aa5347428de.zip
ASoC: ops: add correct range check for limiting volume
commit fb9ad24485087e0f00d84bee7a5914640b2b9024 upstream. Volume can have ranges that start with negative values, ex: -84dB to +40dB. Apply correct range check in snd_soc_limit_volume before setting the platform_max. Without this patch, for example setting a 0dB limit on a volume range of -84dB to +40dB would fail. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Tested-by: Johan Hovold <johan+linaro@kernel.org> Reviewed-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20231204124736.132185-2-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--sound/soc/soc-ops.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 55b009d3c681..2d25748ca706 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -661,7 +661,7 @@ int snd_soc_limit_volume(struct snd_soc_card *card,
kctl = snd_soc_card_get_kcontrol(card, name);
if (kctl) {
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
- if (max <= mc->max) {
+ if (max <= mc->max - mc->min) {
mc->platform_max = max;
ret = 0;
}