[PATCH 3/6] ASoC: aw88166: fix error checks in aw_dev_fw_crc_check()
From: Marco Giunta
Date: Thu Nov 26 2026 - 16:29:15 EST
aw_dev_fw_crc_check() does not store the return value of the regmap_read()
of the CRC result, so the error check after it tests the earlier
regmap_update_bits() call instead. A failed read therefore goes unnoticed,
and the CRC result is taken from an uninitialized variable.
Store the return value of the read, and check the regmap_update_bits()
call immediately, before sleeping and reading the result, as the aw883xx
vendor driver does.
Fixes: 94e412c28e61 ("ASoC: codecs: Add aw88166 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@xxxxxxxxxx>
---
sound/soc/codecs/aw88166.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88166.c b/sound/soc/codecs/aw88166.c
index b3d11e1b5d67..5e891bf99bff 100644
--- a/sound/soc/codecs/aw88166.c
+++ b/sound/soc/codecs/aw88166.c
@@ -461,11 +461,13 @@ static int aw_dev_fw_crc_check(struct aw_device *aw_dev)
/* enable fw crc check */
ret = regmap_update_bits(aw_dev->regmap, AW88166_CRCCTRL_REG,
~AW88166_CRC_CODE_EN_MASK, AW88166_CRC_CODE_EN_ENABLE_VALUE);
+ if (ret)
+ return ret;
usleep_range(AW88166_2000_US, AW88166_2000_US + 10);
/* read crc check result */
- regmap_read(aw_dev->regmap, AW88166_HAGCST_REG, ®_val);
+ ret = regmap_read(aw_dev->regmap, AW88166_HAGCST_REG, ®_val);
if (ret)
return ret;
--
2.56.1