]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: codecs: lpass-macro: Gracefully handle unknown version
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 25 Jun 2024 16:57:35 +0000 (18:57 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 26 Jun 2024 15:34:54 +0000 (16:34 +0100)
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>
sound/soc/codecs/lpass-macro-common.h
sound/soc/codecs/lpass-va-macro.c

index f6f1bfe8eb77b660d7e5ee327c02bcd30033fca1..94697d0ba8c9397002907aa917447cd3ceb21785 100644 (file)
@@ -19,7 +19,8 @@ enum lpass_version {
 };
 
 enum lpass_codec_version {
-       LPASS_CODEC_VERSION_1_0 = 1,
+       LPASS_CODEC_VERSION_UNKNOWN,
+       LPASS_CODEC_VERSION_1_0,
        LPASS_CODEC_VERSION_1_1,
        LPASS_CODEC_VERSION_1_2,
        LPASS_CODEC_VERSION_2_0,
index b0006f4ce8a220ce02bbd0efa99b5cc0c4dd3645..b852cc7ffad9d9417897acbf79fa64e6a9b58dbe 100644 (file)
@@ -1463,7 +1463,8 @@ undefined_rate:
 
 static void va_macro_set_lpass_codec_version(struct va_macro *va)
 {
-       int core_id_0 = 0, core_id_1 = 0, core_id_2 = 0, version;
+       int core_id_0 = 0, core_id_1 = 0, core_id_2 = 0;
+       int version = LPASS_CODEC_VERSION_UNKNOWN;
 
        regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_0, &core_id_0);
        regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_1, &core_id_1);