From: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: Mark Brown
<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>,
Liam Girdwood <lrg-l0cyMroinI0@public.gmane.org>
Cc: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH v2 3/6] ASoC: Refactor some conditions and loop in soc_bind_dai_link()
Date: Wed, 7 Dec 2011 13:58:27 -0700 [thread overview]
Message-ID: <1323291510-22338-3-git-send-email-swarren@nvidia.com> (raw)
In-Reply-To: <1323291510-22338-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
v2: New patch
sound/soc/soc-core.c | 52 ++++++++++++++++++++++++++++---------------------
1 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f60e04f..d2f9df5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -764,10 +764,11 @@ 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)) {
- rtd->cpu_dai = cpu_dai;
- goto find_codec;
- }
+ 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);
@@ -780,22 +781,28 @@ find_codec:
/* no, then find CODEC from registered CODECs*/
list_for_each_entry(codec, &codec_list, list) {
- if (!strcmp(codec->name, dai_link->codec_name)) {
- rtd->codec = 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)) {
- rtd->codec_dai = codec_dai;
- goto find_platform;
- }
- }
- dev_dbg(card->dev, "CODEC DAI %s not registered\n",
- dai_link->codec_dai_name);
+ if (strcmp(codec->name, dai_link->codec_name))
+ continue;
+
+ rtd->codec = codec;
- goto find_platform;
+ /*
+ * 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)) {
+
+ rtd->codec_dai = codec_dai;
+ goto find_platform;
+ }
}
+ dev_dbg(card->dev, "CODEC DAI %s not registered\n",
+ dai_link->codec_dai_name);
+
+ goto find_platform;
}
dev_dbg(card->dev, "CODEC %s not registered\n",
dai_link->codec_name);
@@ -812,10 +819,11 @@ find_platform:
/* no, then find one from the set of registered platforms */
list_for_each_entry(platform, &platform_list, list) {
- if (!strcmp(platform->name, platform_name)) {
- rtd->platform = platform;
- goto out;
- }
+ if (strcmp(platform->name, platform_name))
+ continue;
+
+ rtd->platform = platform;
+ goto out;
}
dev_dbg(card->dev, "platform %s not registered\n",
--
1.7.0.4
next prev parent reply other threads:[~2011-12-07 20:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-07 20:58 [PATCH v2 1/6] ASoC: Allow device tree to specify a card's name Stephen Warren
[not found] ` <1323291510-22338-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-07 20:58 ` [PATCH v2 2/6] ASoC: Allow the DAPM routes to be stored in device tree Stephen Warren
[not found] ` <1323291510-22338-2-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-08 4:31 ` Mark Brown
[not found] ` <20111208043149.GA31372-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-12-09 21:52 ` Stephen Warren
[not found] ` <74CDBE0F657A3D45AFBB94109FB122FF17518605B1-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-12-10 12:49 ` Mark Brown
[not found] ` <20111210124921.GA20568-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-12-12 19:08 ` Stephen Warren
[not found] ` <4EE65128.2090209-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-13 1:32 ` Mark Brown
2011-12-12 19:34 ` Stephen Warren
2011-12-13 4:07 ` Mark Brown
2011-12-07 20:58 ` Stephen Warren [this message]
[not found] ` <1323291510-22338-3-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-09 4:46 ` [PATCH v2 3/6] ASoC: Refactor some conditions and loop in soc_bind_dai_link() Mark Brown
2011-12-07 20:58 ` [PATCH v2 4/6] ASoC: Allow DAI links to be specified using device tree nodes Stephen Warren
[not found] ` <1323291510-22338-4-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-09 6:03 ` Mark Brown
2011-12-07 20:58 ` [PATCH v2 5/6] ASoC: Tegra: Move DAS configuration into DAS driver Stephen Warren
[not found] ` <1323291510-22338-5-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-08 4:34 ` Mark Brown
2011-12-07 20:58 ` [PATCH v2 6/6] ASoC: Tegra+WM8903 machine: Add device tree binding Stephen Warren
2011-12-08 1:31 ` [PATCH v2 1/6] ASoC: Allow device tree to specify a card's name Mark Brown
2011-12-08 19:17 ` Liam Girdwood
2011-12-09 3:17 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2011-12-07 22:13 [PATCH v2 0/8] arm/tegra: Device tree support for audio Stephen Warren
[not found] ` <1323296033-28730-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-07 22:13 ` [PATCH v2 3/6] ASoC: Refactor some conditions and loop in soc_bind_dai_link() Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323291510-22338-3-git-send-email-swarren@nvidia.com \
--to=swarren-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lrg-l0cyMroinI0@public.gmane.org \
--cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).