ASoC: SOF: topology: Check w->sname validity once in sof_connect_dai_widget()
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thu, 21 Apr 2022 20:18:47 +0000 (15:18 -0500)
committerMark Brown <broonie@kernel.org>
Fri, 22 Apr 2022 23:16:21 +0000 (00:16 +0100)
The 'w' (struct snd_soc_dapm_widget) is not changing within the function,
there is no reason to check the w->sname more than once as it is not
going to change.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220421201847.1545686-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/topology.c

index 38e560ccaa570681e6db9ae8f5348b0cc42d2d28..5e959f8c4cb9dd28bdf38c1df309553a5f00e5ef 100644 (file)
@@ -1012,15 +1012,18 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
        struct snd_soc_dai *cpu_dai;
        int i;
 
+       if (!w->sname) {
+               dev_err(scomp->dev, "Widget %s does not have stream\n", w->name);
+               return -EINVAL;
+       }
+
        list_for_each_entry(rtd, &card->rtd_list, list) {
                dev_vdbg(scomp->dev, "tplg: check widget: %s stream: %s dai stream: %s\n",
                         w->name,  w->sname, rtd->dai_link->stream_name);
 
-               if (!w->sname || !rtd->dai_link->stream_name)
-                       continue;
-
                /* does stream match DAI link ? */
-               if (strcmp(w->sname, rtd->dai_link->stream_name))
+               if (!rtd->dai_link->stream_name ||
+                   strcmp(w->sname, rtd->dai_link->stream_name))
                        continue;
 
                switch (w->id) {