From patchwork Fri Aug 19 10:14:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengdong.lin@linux.intel.com X-Patchwork-Id: 9290007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 89F11600CB for ; Fri, 19 Aug 2016 10:17:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79FE629396 for ; Fri, 19 Aug 2016 10:17:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E8E229398; Fri, 19 Aug 2016 10:17:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E6C29396 for ; Fri, 19 Aug 2016 10:17:08 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E2222266E04; Fri, 19 Aug 2016 12:17:07 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4AB39266D87; Fri, 19 Aug 2016 12:11:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 551EC266D84; Fri, 19 Aug 2016 12:11:47 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by alsa0.perex.cz (Postfix) with ESMTP id 46BB6266D87 for ; Fri, 19 Aug 2016 12:08:40 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 19 Aug 2016 03:08:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,544,1464678000"; d="scan'208"; a="1044103654" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga002.fm.intel.com with ESMTP; 19 Aug 2016 03:08:37 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org, broonie@kernel.org Date: Fri, 19 Aug 2016 18:14:32 +0800 Message-Id: <823f27d0ca644b75c29246715d0c9c06d3ceb49f.1471599648.git.mengdong.lin@linux.intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Cc: Mengdong Lin , tiwai@suse.de, mengdong.lin@intel.com, guneshwor.o.singh@intel.com, liam.r.girdwood@linux.intel.com, vinod.koul@intel.com, hardik.t.shah@intel.com Subject: [alsa-devel] [PATCH 12/13] ASoC: Probe link components after finding new links X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mengdong Lin Probing link components may bring new links from topolgy and these new links may need new components. So there will be multiple rounds of components probing until there is no new links found during the process. Probing of aux_dev is moved earlier to simply the code. There is no need to probe aux_devices multiple times. Signed-off-by: Mengdong Lin diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6b1d198..dbd2169 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1862,6 +1862,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; int ret, i, order; + bool find_new_link; /* topolgy may create new links */ mutex_lock(&client_mutex); mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); @@ -1934,7 +1935,13 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto card_probe_error; } + /* probe auxiliary components */ + ret = soc_probe_aux_devices(card); + if (ret < 0) + goto probe_dai_err; + /* probe all components used by DAI links on this card */ +probe_link_cmpnt: for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; order++) { list_for_each_entry(rtd, &card->rtd_list, list) { @@ -1948,18 +1955,15 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) } } - /* probe auxiliary components */ - ret = soc_probe_aux_devices(card); - if (ret < 0) - goto probe_dai_err; - /* Find new DAI links added during probing components and bind them. * Components with topology may bring new DAIs and DAI links. */ + find_new_link = false; list_for_each_entry(dai_link, &card->dai_link_list, list) { if (soc_is_dai_link_bound(card, dai_link)) continue; + find_new_link = true; ret = soc_init_dai_link(card, dai_link); if (ret) goto probe_dai_err; @@ -1968,6 +1972,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto probe_dai_err; } + if (find_new_link) /* new link may have unprobed components */ + goto probe_link_cmpnt; + /* probe all DAI links on this card */ for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; order++) {