Skip to contentSkip to conversation

Avoid useless loop

PATCH In review [email protected] 2 participants 2 messages Apr 10, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Avoid useless loop

From: xingchao <[email protected]>

Only drop to the for loop to bind DAI when the work is not finished.

---
 sound/soc/soc-core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
sound/soc/soc-core.c +4 -2
index 4dda589..0380a26 100644
@@ -1810,8 +1810,10 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 	}
 
 	/* bind DAIs */
-	for (i = 0; i < card->num_links; i++)
-		soc_bind_dai_link(card, i);
+	if (card->num_rtds != card->num_links) {
+		for (i = 0; i < card->num_links; i++)
+			soc_bind_dai_link(card, i);
+	}
 
 	/* bind completed ? */
 	if (card->num_rtd != card->num_links) {
Signature · 1 line
1.7.1
#1 lore raw

sound/soc/soc-core.c static void snd_soc_instantiate_card(struct snd_soc_card *card) · line 1819

Quoted 10 lines · On Sun, Apr 10, 2011 at 07:19:20PM -0400, [email protected] wrote:
sound/soc/soc-core.c +4 -2
 	/* bind DAIs */
-	for (i = 0; i < card->num_links; i++)
-		soc_bind_dai_link(card, i);
+	if (card->num_rtds != card->num_links) {
+		for (i = 0; i < card->num_links; i++)
+			soc_bind_dai_link(card, i);
+	}
 
 	/* bind completed ? */
 	if (card->num_rtd != card->num_links) {

It seems odd to have two if statements testing the same condition in immediate succession, though we do need the second check after the flor loop to match the final bind. I'm not sure this is doing much except adding a little complexity - it's not like this is a hot path.