return -EINVAL;
        }
 
-       /* check client and interface hw capabilities */
-       if (codec_dai) {
-               if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
-                   snd_soc_dai_stream_valid(cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK))
-                       playback = 1;
-               if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
-                   snd_soc_dai_stream_valid(cpu_dai,   SNDRV_PCM_STREAM_CAPTURE))
-                       capture = 1;
+       if (!codec_dai) {
+               dev_err(rtd->card->dev, "Missing codec\n");
+               return -EINVAL;
        }
 
+       /* check client and interface hw capabilities */
+       if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
+           snd_soc_dai_stream_valid(cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK))
+               playback = 1;
+       if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
+           snd_soc_dai_stream_valid(cpu_dai,   SNDRV_PCM_STREAM_CAPTURE))
+               capture = 1;
+
        /*
         * Compress devices are unidirectional so only one of the directions
         * should be set, check for that (xor)