![](https://secure.gravatar.com/avatar/2ea1ea42072986bc3dd023464d0c2de6.jpg?s=120&d=mm&r=g)
If snd_soc_card has some dai_link, there is a possibility that the snd_coc_codec value which came from function is not da7210's codec. This patch make sure it for da7210
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/da7210.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index a83aa18..2b1c65e 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -172,7 +172,11 @@ static const u8 da7210_reg[] = { */ static inline u32 da7210_read_reg_cache(struct snd_soc_codec *codec, u32 reg) { - u8 *cache = codec->reg_cache; + u8 *cache; + + codec = da7210_codec; + cache = codec->reg_cache; + BUG_ON(reg >= ARRAY_SIZE(da7210_reg)); return cache[reg]; } @@ -182,9 +186,12 @@ static inline u32 da7210_read_reg_cache(struct snd_soc_codec *codec, u32 reg) */ static int da7210_write(struct snd_soc_codec *codec, u32 reg, u32 value) { - u8 *cache = codec->reg_cache; + u8 *cache; u8 data[2];
+ codec = da7210_codec; + cache = codec->reg_cache; + BUG_ON(codec->volatile_register);
data[0] = reg & 0xff; @@ -205,6 +212,8 @@ static int da7210_write(struct snd_soc_codec *codec, u32 reg, u32 value) */ static inline u32 da7210_read(struct snd_soc_codec *codec, u32 reg) { + codec = da7210_codec; + if (DA7210_STATUS == reg) return i2c_smbus_read_byte_data(codec->control_data, reg);
@@ -215,7 +224,7 @@ static int da7210_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_codec *codec = da7210_codec;
if (is_play) { /* PlayBack Volume 40 */ @@ -246,9 +255,7 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->card->codec; + struct snd_soc_codec *codec = da7210_codec; u32 dai_cfg1; u32 hpf_reg, hpf_mask, hpf_value; u32 fs, bypass; @@ -362,7 +369,7 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, */ static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_codec *codec = da7210_codec; u32 dai_cfg1; u32 dai_cfg3;