diff options
author | Dimitris Papastamos <dp@opensource.wolfsonmicro.com> | 2010-12-02 11:11:05 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-12-03 11:37:06 -0500 |
commit | 3335ddca9367675f4ee0bd50cc70402c4919a10d (patch) | |
tree | 4391baddac89dc25cd242e44168a0bbf3e1442bc /sound/soc/soc-cache.c | |
parent | ff819b8357df0ca9903ff7c9ad518b949c410123 (diff) |
ASoC: soc-cache: Use reg_def_copy instead of reg_cache_default
Make sure to use codec->reg_def_copy instead of codec_drv->reg_cache_default
wherever necessary. This change is necessary because in the next patch we
move the cache initialization code outside snd_soc_register_codec() and by that
time any data marked as __devinitconst such as the original reg_cache_default
array might have already been freed by the kernel.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-cache.c')
-rw-r--r-- | sound/soc/soc-cache.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index cb58b11d4f47..6c6ced7a3819 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
@@ -933,7 +933,7 @@ static int snd_soc_rbtree_cache_init(struct snd_soc_codec *codec) | |||
933 | rbtree_ctx = codec->reg_cache; | 933 | rbtree_ctx = codec->reg_cache; |
934 | rbtree_ctx->root = RB_ROOT; | 934 | rbtree_ctx->root = RB_ROOT; |
935 | 935 | ||
936 | if (!codec->driver->reg_cache_default) | 936 | if (!codec->reg_def_copy) |
937 | return 0; | 937 | return 0; |
938 | 938 | ||
939 | /* | 939 | /* |
@@ -951,7 +951,7 @@ static int snd_soc_rbtree_cache_init(struct snd_soc_codec *codec) | |||
951 | struct snd_soc_rbtree_node *rbtree_node; \ | 951 | struct snd_soc_rbtree_node *rbtree_node; \ |
952 | \ | 952 | \ |
953 | ret = 0; \ | 953 | ret = 0; \ |
954 | cache = codec->driver->reg_cache_default; \ | 954 | cache = codec->reg_def_copy; \ |
955 | for (i = 0; i < codec->driver->reg_cache_size; ++i) { \ | 955 | for (i = 0; i < codec->driver->reg_cache_size; ++i) { \ |
956 | if (!cache[i]) \ | 956 | if (!cache[i]) \ |
957 | continue; \ | 957 | continue; \ |
@@ -1316,13 +1316,13 @@ static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec) | |||
1316 | * and remember to free it afterwards. | 1316 | * and remember to free it afterwards. |
1317 | */ | 1317 | */ |
1318 | tofree = 0; | 1318 | tofree = 0; |
1319 | if (!codec_drv->reg_cache_default) | 1319 | if (!codec->reg_def_copy) |
1320 | tofree = 1; | 1320 | tofree = 1; |
1321 | 1321 | ||
1322 | if (!codec_drv->reg_cache_default) { | 1322 | if (!codec->reg_def_copy) { |
1323 | codec_drv->reg_cache_default = kzalloc(reg_size, | 1323 | codec->reg_def_copy = kzalloc(reg_size, |
1324 | GFP_KERNEL); | 1324 | GFP_KERNEL); |
1325 | if (!codec_drv->reg_cache_default) | 1325 | if (!codec->reg_def_copy) |
1326 | return -ENOMEM; | 1326 | return -ENOMEM; |
1327 | } | 1327 | } |
1328 | 1328 | ||
@@ -1368,8 +1368,8 @@ static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec) | |||
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | blksize = snd_soc_lzo_get_blksize(codec); | 1370 | blksize = snd_soc_lzo_get_blksize(codec); |
1371 | p = codec_drv->reg_cache_default; | 1371 | p = codec->reg_def_copy; |
1372 | end = codec_drv->reg_cache_default + reg_size; | 1372 | end = codec->reg_def_copy + reg_size; |
1373 | /* compress the register map and fill the lzo blocks */ | 1373 | /* compress the register map and fill the lzo blocks */ |
1374 | for (i = 0; i < blkcount; ++i, p += blksize) { | 1374 | for (i = 0; i < blkcount; ++i, p += blksize) { |
1375 | lzo_blocks[i]->src = p; | 1375 | lzo_blocks[i]->src = p; |
@@ -1385,14 +1385,18 @@ static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec) | |||
1385 | lzo_blocks[i]->src_len; | 1385 | lzo_blocks[i]->src_len; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | if (tofree) | 1388 | if (tofree) { |
1389 | kfree(codec_drv->reg_cache_default); | 1389 | kfree(codec->reg_def_copy); |
1390 | codec->reg_def_copy = NULL; | ||
1391 | } | ||
1390 | return 0; | 1392 | return 0; |
1391 | err: | 1393 | err: |
1392 | snd_soc_cache_exit(codec); | 1394 | snd_soc_cache_exit(codec); |
1393 | err_tofree: | 1395 | err_tofree: |
1394 | if (tofree) | 1396 | if (tofree) { |
1395 | kfree(codec_drv->reg_cache_default); | 1397 | kfree(codec->reg_def_copy); |
1398 | codec->reg_def_copy = NULL; | ||
1399 | } | ||
1396 | return ret; | 1400 | return ret; |
1397 | } | 1401 | } |
1398 | 1402 | ||
@@ -1506,6 +1510,14 @@ static int snd_soc_flat_cache_init(struct snd_soc_codec *codec) | |||
1506 | codec_drv = codec->driver; | 1510 | codec_drv = codec->driver; |
1507 | reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; | 1511 | reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; |
1508 | 1512 | ||
1513 | /* | ||
1514 | * for flat compression, we don't need to keep a copy of the | ||
1515 | * original defaults register cache as it will definitely not | ||
1516 | * be marked as __devinitconst | ||
1517 | */ | ||
1518 | kfree(codec->reg_def_copy); | ||
1519 | codec->reg_def_copy = NULL; | ||
1520 | |||
1509 | if (codec_drv->reg_cache_default) | 1521 | if (codec_drv->reg_cache_default) |
1510 | codec->reg_cache = kmemdup(codec_drv->reg_cache_default, | 1522 | codec->reg_cache = kmemdup(codec_drv->reg_cache_default, |
1511 | reg_size, GFP_KERNEL); | 1523 | reg_size, GFP_KERNEL); |