aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-12-07 15:58:27 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-08 23:45:54 -0500
commit2610ab7767bba916f65094d71cfed3b8281cba08 (patch)
treeac57b90f8712120b1d15abc86439accde067c585 /sound/soc/soc-core.c
parent7b9b5e11704afb8f05aa6490c3b4bb2cc328647c (diff)
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: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 5195f0653b35..ebb104878c48 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -763,10 +763,11 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
763 } 763 }
764 /* no, then find CPU DAI from registered DAIs*/ 764 /* no, then find CPU DAI from registered DAIs*/
765 list_for_each_entry(cpu_dai, &dai_list, list) { 765 list_for_each_entry(cpu_dai, &dai_list, list) {
766 if (!strcmp(cpu_dai->name, dai_link->cpu_dai_name)) { 766 if (strcmp(cpu_dai->name, dai_link->cpu_dai_name))
767 rtd->cpu_dai = cpu_dai; 767 continue;
768 goto find_codec; 768
769 } 769 rtd->cpu_dai = cpu_dai;
770 goto find_codec;
770 } 771 }
771 dev_dbg(card->dev, "CPU DAI %s not registered\n", 772 dev_dbg(card->dev, "CPU DAI %s not registered\n",
772 dai_link->cpu_dai_name); 773 dai_link->cpu_dai_name);
@@ -779,22 +780,28 @@ find_codec:
779 780
780 /* no, then find CODEC from registered CODECs*/ 781 /* no, then find CODEC from registered CODECs*/
781 list_for_each_entry(codec, &codec_list, list) { 782 list_for_each_entry(codec, &codec_list, list) {
782 if (!strcmp(codec->name, dai_link->codec_name)) { 783 if (strcmp(codec->name, dai_link->codec_name))
783 rtd->codec = codec; 784 continue;
784 785
785 /* CODEC found, so find CODEC DAI from registered DAIs from this CODEC*/ 786 rtd->codec = codec;
786 list_for_each_entry(codec_dai, &dai_list, list) {
787 if (codec->dev == codec_dai->dev &&
788 !strcmp(codec_dai->name, dai_link->codec_dai_name)) {
789 rtd->codec_dai = codec_dai;
790 goto find_platform;
791 }
792 }
793 dev_dbg(card->dev, "CODEC DAI %s not registered\n",
794 dai_link->codec_dai_name);
795 787
796 goto find_platform; 788 /*
789 * CODEC found, so find CODEC DAI from registered DAIs from
790 * this CODEC
791 */
792 list_for_each_entry(codec_dai, &dai_list, list) {
793 if (codec->dev == codec_dai->dev &&
794 !strcmp(codec_dai->name,
795 dai_link->codec_dai_name)) {
796
797 rtd->codec_dai = codec_dai;
798 goto find_platform;
799 }
797 } 800 }
801 dev_dbg(card->dev, "CODEC DAI %s not registered\n",
802 dai_link->codec_dai_name);
803
804 goto find_platform;
798 } 805 }
799 dev_dbg(card->dev, "CODEC %s not registered\n", 806 dev_dbg(card->dev, "CODEC %s not registered\n",
800 dai_link->codec_name); 807 dai_link->codec_name);
@@ -811,10 +818,11 @@ find_platform:
811 818
812 /* no, then find one from the set of registered platforms */ 819 /* no, then find one from the set of registered platforms */
813 list_for_each_entry(platform, &platform_list, list) { 820 list_for_each_entry(platform, &platform_list, list) {
814 if (!strcmp(platform->name, platform_name)) { 821 if (strcmp(platform->name, platform_name))
815 rtd->platform = platform; 822 continue;
816 goto out; 823
817 } 824 rtd->platform = platform;
825 goto out;
818 } 826 }
819 827
820 dev_dbg(card->dev, "platform %s not registered\n", 828 dev_dbg(card->dev, "platform %s not registered\n",