Skip to content

Commit

Permalink
ASoC: soc_bind_dai_link() directly returns success for a bound DAI link
Browse files Browse the repository at this point in the history
This function will return success immediately for a bound DAI link.
No need to look for the cpu/codec DAIs again.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Mengdong Lin authored and Mark Brown committed Dec 8, 2015
1 parent d6f220e commit 49a5ba1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,19 @@ static struct snd_soc_dai *snd_soc_find_dai(
return NULL;
}

static bool soc_is_dai_link_bound(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link)
{
struct snd_soc_pcm_runtime *rtd;

list_for_each_entry(rtd, &card->rtd_list, list) {
if (rtd->dai_link == dai_link)
return true;
}

return false;
}

static int soc_bind_dai_link(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link)
{
Expand All @@ -977,6 +990,12 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
if (!rtd)
return -ENOMEM;

if (soc_is_dai_link_bound(card, dai_link)) {
dev_dbg(card->dev, "ASoC: dai link %s already bound\n",
dai_link->name);
return 0;
}

cpu_dai_component.name = dai_link->cpu_name;
cpu_dai_component.of_node = dai_link->cpu_of_node;
cpu_dai_component.dai_name = dai_link->cpu_dai_name;
Expand Down

0 comments on commit 49a5ba1

Please sign in to comment.