Commit 5aaa062c authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by Mark Brown

ASoC: soc-cache: Use BUG_ON() for unsupported hw_read() calls

Instead of dereferencing a NULL function pointer and falling apart
use BUG_ON() for any unimplemented hw_read() calls.
Signed-off-by: default avatarDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 989db200
...@@ -25,6 +25,7 @@ static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec, ...@@ -25,6 +25,7 @@ static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec,
if (codec->cache_only) if (codec->cache_only)
return -1; return -1;
BUG_ON(!codec->hw_read);
return codec->hw_read(codec, reg); return codec->hw_read(codec, reg);
} }
...@@ -99,6 +100,7 @@ static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec, ...@@ -99,6 +100,7 @@ static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
if (codec->cache_only) if (codec->cache_only)
return -1; return -1;
BUG_ON(!codec->hw_read);
return codec->hw_read(codec, reg); return codec->hw_read(codec, reg);
} }
...@@ -199,6 +201,7 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec, ...@@ -199,6 +201,7 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec,
if (codec->cache_only) if (codec->cache_only)
return -1; return -1;
BUG_ON(!codec->hw_read);
return codec->hw_read(codec, reg); return codec->hw_read(codec, reg);
} }
...@@ -270,6 +273,7 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec, ...@@ -270,6 +273,7 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec,
if (codec->cache_only) if (codec->cache_only)
return -1; return -1;
BUG_ON(!codec->hw_read);
return codec->hw_read(codec, reg); return codec->hw_read(codec, reg);
} else { } else {
return cache[reg]; return cache[reg];
...@@ -420,6 +424,7 @@ static unsigned int snd_soc_16_8_read(struct snd_soc_codec *codec, ...@@ -420,6 +424,7 @@ static unsigned int snd_soc_16_8_read(struct snd_soc_codec *codec,
if (codec->cache_only) if (codec->cache_only)
return -1; return -1;
BUG_ON(!codec->hw_read);
return codec->hw_read(codec, reg); return codec->hw_read(codec, reg);
} }
...@@ -531,6 +536,7 @@ static unsigned int snd_soc_16_16_read(struct snd_soc_codec *codec, ...@@ -531,6 +536,7 @@ static unsigned int snd_soc_16_16_read(struct snd_soc_codec *codec,
if (codec->cache_only) if (codec->cache_only)
return -1; return -1;
BUG_ON(!codec->hw_read);
return codec->hw_read(codec, reg); return codec->hw_read(codec, reg);
} }
......
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