From: Niranjan H Y Date: Fri, 12 Sep 2025 08:36:20 +0000 (+0530) Subject: ASoC: ops: improve snd_soc_get_volsw X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a0ce874cfaaab9792d657440b9d050e2112f6e4d;p=users%2Fhch%2Fmisc.git ASoC: ops: improve snd_soc_get_volsw * clamp the values if the register value read is out of range Signed-off-by: Niranjan H Y [This patch originally had two changes in it, I removed a second buggy one -- broonie] -- v5: - remove clamp parameter - move the boundary check after sign-bit extension Link: https://patch.msgid.link/20250912083624.804-1-niranjan.hy@ti.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index a629e0eacb20..d2b6fb8e0b6c 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -118,6 +118,7 @@ static int soc_mixer_reg_to_ctl(struct soc_mixer_control *mc, unsigned int reg_v if (mc->sign_bit) val = sign_extend32(val, mc->sign_bit); + val = clamp(val, mc->min, mc->max); val -= mc->min; if (mc->invert)