All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Fix wm8753 register cache size and initialization
@ 2009-07-02 22:46 ` Lars-Peter Clausen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars-Peter Clausen @ 2009-07-02 22:46 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, Lars-Peter Clausen, linux-kernel

The register cache size is of by one. There are 63 registers in use but the
register cache size has only space for 62.
Furthermore the codec's reg_cache_size is of by another one. Since the wm8753
register cache uses one-based indexing we have to add one to its size.

Register cache initialization only copied the first sizeof(void*) elements leaving the others
uninitialized. Fix it by using the size of the reg cache template.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/wm8753.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index d28eeac..18a3ef9 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -79,7 +79,7 @@ static const u16 wm8753_reg[] = {
 	0x0097, 0x0097, 0x0000, 0x0004,
 	0x0000, 0x0083, 0x0024, 0x01ba,
 	0x0000, 0x0083, 0x0024, 0x01ba,
-	0x0000, 0x0000
+	0x0000, 0x0000, 0x0000
 };
 
 /* codec private data */
@@ -1660,11 +1660,11 @@ static int wm8753_register(struct wm8753_priv *wm8753)
 	codec->set_bias_level = wm8753_set_bias_level;
 	codec->dai = wm8753_dai;
 	codec->num_dai = 2;
-	codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache);
+	codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache) + 1;
 	codec->reg_cache = &wm8753->reg_cache;
 	codec->private_data = wm8753;
 
-	memcpy(codec->reg_cache, wm8753_reg, sizeof(codec->reg_cache));
+	memcpy(codec->reg_cache, wm8753_reg, sizeof(wm8753_reg));
 	INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
 
 	ret = wm8753_reset(codec);
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-03 10:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-02 22:46 [PATCH] ASoC: Fix wm8753 register cache size and initialization Lars-Peter Clausen
2009-07-02 22:46 ` Lars-Peter Clausen
2009-07-03  9:32 ` Mark Brown
2009-07-03 10:15   ` Lars-Peter Clausen
2009-07-03 10:35     ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.