提交 2610ab77 编写于 作者: S Stephen Warren 提交者: Mark Brown

ASoC: Refactor some conditions and loop in soc_bind_dai_link()

Transform some loops from:

for_each(x) {
    if (f(x)) {
        work_on(x);
    }
}

to new structure:

for_each(x) {
    if (!f(x))
        continue;

    work_on(x);
}

This will allow future modification of f(x) with less impact to the code.
Signed-off-by: NStephen Warren <swarren@nvidia.com>
Acked-by: NLiam Girdwood <lrg@ti.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 7b9b5e11
......@@ -763,11 +763,12 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
}
/* no, then find CPU DAI from registered DAIs*/
list_for_each_entry(cpu_dai, &dai_list, list) {
if (!strcmp(cpu_dai->name, dai_link->cpu_dai_name)) {
if (strcmp(cpu_dai->name, dai_link->cpu_dai_name))
continue;
rtd->cpu_dai = cpu_dai;
goto find_codec;
}
}
dev_dbg(card->dev, "CPU DAI %s not registered\n",
dai_link->cpu_dai_name);
......@@ -779,13 +780,20 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
/* no, then find CODEC from registered CODECs*/
list_for_each_entry(codec, &codec_list, list) {
if (!strcmp(codec->name, dai_link->codec_name)) {
if (strcmp(codec->name, dai_link->codec_name))
continue;
rtd->codec = codec;
/* CODEC found, so find CODEC DAI from registered DAIs from this CODEC*/
/*
* CODEC found, so find CODEC DAI from registered DAIs from
* this CODEC
*/
list_for_each_entry(codec_dai, &dai_list, list) {
if (codec->dev == codec_dai->dev &&
!strcmp(codec_dai->name, dai_link->codec_dai_name)) {
!strcmp(codec_dai->name,
dai_link->codec_dai_name)) {
rtd->codec_dai = codec_dai;
goto find_platform;
}
......@@ -795,7 +803,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
goto find_platform;
}
}
dev_dbg(card->dev, "CODEC %s not registered\n",
dai_link->codec_name);
......@@ -811,11 +818,12 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
/* no, then find one from the set of registered platforms */
list_for_each_entry(platform, &platform_list, list) {
if (!strcmp(platform->name, platform_name)) {
if (strcmp(platform->name, platform_name))
continue;
rtd->platform = platform;
goto out;
}
}
dev_dbg(card->dev, "platform %s not registered\n",
dai_link->platform_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册