[alsa-devel] [PATCH 2/2] ASoC: cs42l51: Fix off-by-one for reg_cache_size

Axel Lin axel.lin at gmail.com
Wed Nov 23 05:46:11 CET 2011


Just checking the code in cs42l51_fill_cache():
The cache pointer points to codec->reg_cache + 1.
I think it is because CS42L51_FIRSTREG is 0x01,
so codec->reg_cache[0] is not used here.

Then we read CS42L51_NUMREGS bytes to cache.
So we need reg_cache_size to be CS42L51_NUMREGS + 1.

Signed-off-by: Axel Lin <axel.lin at gmail.com>
---
 sound/soc/codecs/cs42l51.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
index 35c5ac3..c0b0a39 100644
--- a/sound/soc/codecs/cs42l51.c
+++ b/sound/soc/codecs/cs42l51.c
@@ -553,7 +553,7 @@ static int cs42l51_probe(struct snd_soc_codec *codec)
 
 static struct snd_soc_codec_driver soc_codec_device_cs42l51 = {
 	.probe =	cs42l51_probe,
-	.reg_cache_size = CS42L51_NUMREGS,
+	.reg_cache_size = CS42L51_NUMREGS + 1,
 	.reg_word_size = sizeof(u8),
 };
 
-- 
1.7.5.4





More information about the Alsa-devel mailing list