ASoC: Fix register cache sync register_writable WARN_ONs
Currently the condition for these WARN_ONs is reversed and they are placed before the actual check whether we are going to write to that register. So if the codec implements the register_writable callback we'll get a warning for each writable register when syncing the register cache. While we are at it change the check to use snd_soc_codec_writable_register instead of open-coding it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
63fa0a288c
commit
6c5b756aaa
@ -203,14 +203,14 @@ static int snd_soc_rbtree_cache_sync(struct snd_soc_codec *codec)
|
|||||||
rbnode = rb_entry(node, struct snd_soc_rbtree_node, node);
|
rbnode = rb_entry(node, struct snd_soc_rbtree_node, node);
|
||||||
for (i = 0; i < rbnode->blklen; ++i) {
|
for (i = 0; i < rbnode->blklen; ++i) {
|
||||||
regtmp = rbnode->base_reg + i;
|
regtmp = rbnode->base_reg + i;
|
||||||
WARN_ON(codec->writable_register &&
|
|
||||||
codec->writable_register(codec, regtmp));
|
|
||||||
val = snd_soc_rbtree_get_register(rbnode, i);
|
val = snd_soc_rbtree_get_register(rbnode, i);
|
||||||
def = snd_soc_get_cache_val(codec->reg_def_copy, i,
|
def = snd_soc_get_cache_val(codec->reg_def_copy, i,
|
||||||
rbnode->word_size);
|
rbnode->word_size);
|
||||||
if (val == def)
|
if (val == def)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
WARN_ON(!snd_soc_codec_writable_register(codec, regtmp));
|
||||||
|
|
||||||
codec->cache_bypass = 1;
|
codec->cache_bypass = 1;
|
||||||
ret = snd_soc_write(codec, regtmp, val);
|
ret = snd_soc_write(codec, regtmp, val);
|
||||||
codec->cache_bypass = 0;
|
codec->cache_bypass = 0;
|
||||||
@ -563,8 +563,7 @@ static int snd_soc_lzo_cache_sync(struct snd_soc_codec *codec)
|
|||||||
|
|
||||||
lzo_blocks = codec->reg_cache;
|
lzo_blocks = codec->reg_cache;
|
||||||
for_each_set_bit(i, lzo_blocks[0]->sync_bmp, lzo_blocks[0]->sync_bmp_nbits) {
|
for_each_set_bit(i, lzo_blocks[0]->sync_bmp, lzo_blocks[0]->sync_bmp_nbits) {
|
||||||
WARN_ON(codec->writable_register &&
|
WARN_ON(!snd_soc_codec_writable_register(codec, i));
|
||||||
codec->writable_register(codec, i));
|
|
||||||
ret = snd_soc_cache_read(codec, i, &val);
|
ret = snd_soc_cache_read(codec, i, &val);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -823,8 +822,6 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
|
|||||||
|
|
||||||
codec_drv = codec->driver;
|
codec_drv = codec->driver;
|
||||||
for (i = 0; i < codec_drv->reg_cache_size; ++i) {
|
for (i = 0; i < codec_drv->reg_cache_size; ++i) {
|
||||||
WARN_ON(codec->writable_register &&
|
|
||||||
codec->writable_register(codec, i));
|
|
||||||
ret = snd_soc_cache_read(codec, i, &val);
|
ret = snd_soc_cache_read(codec, i, &val);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -832,6 +829,9 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
|
|||||||
if (snd_soc_get_cache_val(codec->reg_def_copy,
|
if (snd_soc_get_cache_val(codec->reg_def_copy,
|
||||||
i, codec_drv->reg_word_size) == val)
|
i, codec_drv->reg_word_size) == val)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
WARN_ON(!snd_soc_codec_writable_register(codec, i));
|
||||||
|
|
||||||
ret = snd_soc_write(codec, i, val);
|
ret = snd_soc_write(codec, i, val);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user