[alsa-devel] ASoC: about the array to cache registers

Joonyoung Shim jy0922.shim at samsung.com
Fri Jul 24 09:06:43 CEST 2009


Hi,

Many ASoC codec drivers have an array to cache registers.
The array is not used any longer after memcpy to codec->reg_cache.
I think that memcpy is unnecessary, and it a waste of the memory.

How about continue using the array instead of memcpy?

For example, i modified such following patch in wm8731.c


diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 1560028..43f8de3 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -36,7 +36,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8731;
 /* codec private data */
 struct wm8731_priv {
 	struct snd_soc_codec codec;
-	u16 reg_cache[WM8731_CACHEREGNUM];
 	unsigned int sysclk;
 };
 
@@ -50,7 +49,7 @@ static int wm8731_spi_write(struct spi_device *spi, const char *data, int len);
  * using 2 wire for device control, so we cache them instead.
  * There is no point in caching the reset register
  */
-static const u16 wm8731_reg[WM8731_CACHEREGNUM] = {
+static u16 wm8731_reg[WM8731_CACHEREGNUM] = {
     0x0097, 0x0097, 0x0079, 0x0079,
     0x000a, 0x0008, 0x009f, 0x000a,
     0x0000, 0x0000
@@ -586,9 +585,7 @@ static int wm8731_register(struct wm8731_priv *wm8731)
 	codec->dai = &wm8731_dai;
 	codec->num_dai = 1;
 	codec->reg_cache_size = WM8731_CACHEREGNUM;
-	codec->reg_cache = &wm8731->reg_cache;
-
-	memcpy(codec->reg_cache, wm8731_reg, sizeof(wm8731_reg));
+	codec->reg_cache = &wm8731_reg;
 
 	ret = wm8731_reset(codec);
 	if (ret < 0) {


More information about the Alsa-devel mailing list