Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: codecs: lpass-macro: Gracefully handle unknown version

Qualcomm LPASS macro codec driver parses registers in order to
detect version of the codec. It recognizes codecs v2.0 - v2.8, however
we know that there are earlier versions and 'enum lpass_codec_version'
has also v1.0, v1.1 and v1.2. If by any chance we run on unrecognized
version, driver will use random value from the stack as the codec
version.

Fix it by mapping such cases to an enum of value 0:
LPASS_CODEC_VERSION_UNKNOWN.

Fixes: 378918d59181 ("ASoC: codecs: lpass-macro: add helpers to get codec version")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patch.msgid.link/20240625165736.722106-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
ebc1a540 727de4fb

+4 -2
+2 -1
sound/soc/codecs/lpass-macro-common.h
··· 19 19 }; 20 20 21 21 enum lpass_codec_version { 22 - LPASS_CODEC_VERSION_1_0 = 1, 22 + LPASS_CODEC_VERSION_UNKNOWN, 23 + LPASS_CODEC_VERSION_1_0, 23 24 LPASS_CODEC_VERSION_1_1, 24 25 LPASS_CODEC_VERSION_1_2, 25 26 LPASS_CODEC_VERSION_2_0,
+2 -1
sound/soc/codecs/lpass-va-macro.c
··· 1463 1463 1464 1464 static void va_macro_set_lpass_codec_version(struct va_macro *va) 1465 1465 { 1466 - int core_id_0 = 0, core_id_1 = 0, core_id_2 = 0, version; 1466 + int core_id_0 = 0, core_id_1 = 0, core_id_2 = 0; 1467 + int version = LPASS_CODEC_VERSION_UNKNOWN; 1467 1468 1468 1469 regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_0, &core_id_0); 1469 1470 regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_1, &core_id_1);