summaryrefslogtreecommitdiff
path: root/sound/soc/soc-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-io.c')
-rw-r--r--sound/soc/soc-io.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index 9b3939049cef..a90a1630ab1c 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -195,9 +195,14 @@ EXPORT_SYMBOL_GPL(snd_soc_component_test_bits);
unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
{
+ struct snd_card *snd_card = codec->component.card->snd_card;
unsigned int val;
int ret;
+ if (unlikely(!snd_card_is_online_state(snd_card))) {
+ dev_err(codec->dev, "read 0x%02x while offline\n", reg);
+ return -ENODEV;
+ }
ret = snd_soc_component_read(&codec->component, reg, &val);
if (ret < 0)
return -1;
@@ -209,6 +214,12 @@ EXPORT_SYMBOL_GPL(snd_soc_read);
int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int val)
{
+ struct snd_card *snd_card = codec->component.card->snd_card;
+
+ if (unlikely(!snd_card_is_online_state(snd_card))) {
+ dev_err(codec->dev, "write 0x%02x while offline\n", reg);
+ return -ENODEV;
+ }
return snd_soc_component_write(&codec->component, reg, val);
}
EXPORT_SYMBOL_GPL(snd_soc_write);