[PATCH] ASoC: Fix wm8753 register cache size and initialization

Mark Brown broonie at opensource.wolfsonmicro.com
Fri Jul 3 12:19:52 CEST 2009

On Fri, Jul 03, 2009 at 01:04:16AM +0200, Lars-Peter Clausen wrote:
> 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.

As discussed in reply to your posting on lkml only 62 of the registers
are cached so the adjustments in cache size would appear to be

> 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.

I've published a fix for this one, see below.

> This could be related to the 'heisenbug' reported in
> http://docs.openmoko.org/trac/ticket/1172

No, that predates the change in the driver by a very long time.

commit 1df892cba45f9856d369a6a317ad2d1e44bca423
Author: Mark Brown <broonie at opensource.wolfsonmicro.com>
Date:   Fri Jul 3 10:33:39 2009 +0100

    ASoC: Fix register cache initialisation for WM8753
    The wrong register cache variable was being used to provide the size for
    the memcpy(), resulting in a copy of only a void * of data.
    Reported-by: Lars-Peter Clausen <lars at metafoo.de>
    Signed-off-by: Mark Brown <broonie at opensource.wolfsonmicro.com>
    Cc: stable at kernel.org

diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index d28eeac..e06b0cf 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -1664,7 +1664,7 @@ static int wm8753_register(struct wm8753_priv *wm8753)
 	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_cache));
 	INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
 	ret = wm8753_reset(codec);

More information about the openmoko-kernel mailing list