From: Johan Hovold <johan+linaro@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sasha Levin <sashal@kernel.org>,
stable@vger.kernel.org, broonie@kernel.org,
alsa-devel@alsa-project.org, perex@perex.cz, tiwai@suse.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
johan+linaro@kernel.org, srinivas.kandagatla@linaro.org
Subject: [PATCH stable-6.6 1/2] ASoC: ops: add correct range check for limiting volume
Date: Mon, 11 Dec 2023 14:26:07 +0100 [thread overview]
Message-ID: <20231211132608.27861-2-johan+linaro@kernel.org> (raw)
In-Reply-To: <20231211132608.27861-1-johan+linaro@kernel.org>
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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: Johan Hovold <johan+linaro@kernel.org>
---
sound/soc/soc-ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
}
--
2.41.0
next prev parent reply other threads:[~2023-12-11 13:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 13:26 [PATCH stable-6.6 0/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes Johan Hovold
2023-12-11 13:26 ` Johan Hovold [this message]
2023-12-11 13:26 ` [PATCH stable-6.6 2/2] " Johan Hovold
2023-12-11 17:28 ` [PATCH " kernel test robot
2023-12-11 17:39 ` Johan Hovold
2023-12-12 8:48 ` Yujie Liu
2023-12-13 12:32 ` Johan Hovold
2023-12-11 13:40 ` [PATCH stable-6.6 0/2] " Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231211132608.27861-2-johan+linaro@kernel.org \
--to=johan+linaro@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sashal@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox