Commit b012aa61 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: Remove reg_def_copy

reg_def_copy was introduced in commit 3335ddca ("ASoC: soc-cache: Use
reg_def_copy instead of reg_cache_default") to keep a copy of the register
defaults around in case the register defaults where placed in the __devinitdata
section. With the __devinitdata section gone we effectivly keep the same data
around twice. This patch removes reg_def_copy and uses reg_cache_default
directly instead.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 2a1212a8
...@@ -687,7 +687,6 @@ struct snd_soc_codec { ...@@ -687,7 +687,6 @@ struct snd_soc_codec {
unsigned int (*read)(struct snd_soc_codec *, unsigned int); unsigned int (*read)(struct snd_soc_codec *, unsigned int);
int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
void *reg_cache; void *reg_cache;
const void *reg_def_copy;
const struct snd_soc_cache_ops *cache_ops; const struct snd_soc_cache_ops *cache_ops;
struct mutex cache_rw_mutex; struct mutex cache_rw_mutex;
int val_bytes; int val_bytes;
......
...@@ -78,8 +78,8 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) ...@@ -78,8 +78,8 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
ret = snd_soc_cache_read(codec, i, &val); ret = snd_soc_cache_read(codec, i, &val);
if (ret) if (ret)
return ret; return ret;
if (codec->reg_def_copy) if (codec_drv->reg_cache_default)
if (snd_soc_get_cache_val(codec->reg_def_copy, if (snd_soc_get_cache_val(codec_drv->reg_cache_default,
i, codec_drv->reg_word_size) == val) i, codec_drv->reg_word_size) == val)
continue; continue;
...@@ -121,8 +121,10 @@ static int snd_soc_flat_cache_exit(struct snd_soc_codec *codec) ...@@ -121,8 +121,10 @@ static int snd_soc_flat_cache_exit(struct snd_soc_codec *codec)
static int snd_soc_flat_cache_init(struct snd_soc_codec *codec) static int snd_soc_flat_cache_init(struct snd_soc_codec *codec)
{ {
if (codec->reg_def_copy) const struct snd_soc_codec_driver *codec_drv = codec->driver;
codec->reg_cache = kmemdup(codec->reg_def_copy,
if (codec_drv->reg_cache_default)
codec->reg_cache = kmemdup(codec_drv->reg_cache_default,
codec->reg_size, GFP_KERNEL); codec->reg_size, GFP_KERNEL);
else else
codec->reg_cache = kzalloc(codec->reg_size, GFP_KERNEL); codec->reg_cache = kzalloc(codec->reg_size, GFP_KERNEL);
......
...@@ -4201,20 +4201,6 @@ int snd_soc_register_codec(struct device *dev, ...@@ -4201,20 +4201,6 @@ int snd_soc_register_codec(struct device *dev,
if (codec_drv->reg_cache_size && codec_drv->reg_word_size) { if (codec_drv->reg_cache_size && codec_drv->reg_word_size) {
reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
codec->reg_size = reg_size; codec->reg_size = reg_size;
/* it is necessary to make a copy of the default register cache
* because in the case of using a compression type that requires
* the default register cache to be marked as the
* kernel might have freed the array by the time we initialize
* the cache.
*/
if (codec_drv->reg_cache_default) {
codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
reg_size, GFP_KERNEL);
if (!codec->reg_def_copy) {
ret = -ENOMEM;
goto fail_codec_name;
}
}
} }
for (i = 0; i < num_dai; i++) { for (i = 0; i < num_dai; i++) {
...@@ -4273,7 +4259,6 @@ void snd_soc_unregister_codec(struct device *dev) ...@@ -4273,7 +4259,6 @@ void snd_soc_unregister_codec(struct device *dev)
dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name); dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name);
snd_soc_cache_exit(codec); snd_soc_cache_exit(codec);
kfree(codec->reg_def_copy);
kfree(codec->name); kfree(codec->name);
kfree(codec); kfree(codec);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment