alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4
@ 2019-10-30  1:23 Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Kuninori Morimoto
                   ` (19 more replies)
  0 siblings, 20 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:23 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

These are resend of soc-core cleanup step4.
These are based on mark/for-5.5 branch.
I already got report from Intel that these had no issue on Intel CI machine.

Kuninori Morimoto (18):
  ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()
  ASoC: soc-core: move soc_init_dai_link()
  ASoC: soc-core: tidyup soc_init_dai_link()
  ASoC: soc-core: remove duplicated soc_is_dai_link_bound()
  ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link()
  ASoC: soc-core: add soc_unbind_dai_link()
  ASoC: soc-core: move snd_soc_lookup_component()
  ASoC: soc-core: add snd_soc_del_component_unlocked()
  ASoC: soc-core: remove snd_soc_component_add/del()
  ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()
  ASoC: soc-core: move snd_soc_register_dai()
  ASoC: soc-core: move snd_soc_unregister_dais()
  ASoC: soc-core: add snd_soc_unregister_dai()
  ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai()
  ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()
  ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais()
  ASoC: soc-core: remove topology specific operation
  ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY

 include/sound/soc.h      |  15 +-
 sound/soc/soc-core.c     | 536 +++++++++++++++++++++--------------------------
 sound/soc/soc-topology.c |  17 +-
 3 files changed, 263 insertions(+), 305 deletions(-)

-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30 12:57   ` [alsa-devel] Applied "ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()" to the asoc tree Mark Brown
  2019-11-05  2:55   ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Sridharan, Ranjani
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link() Kuninori Morimoto
                   ` (18 subsequent siblings)
  19 siblings, 2 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_tplg_component_remove() is pair of snd_soc_tplg_component_load(),
and it is topology related cleanup function.

The driver which called _load() needs to call _remove() by its responsibility.
Today, skl-pcm and topology are the user, and these are calling both
_load() and _remove().

soc-core doesn't need to call it.
This patch remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f1b41b0..b07ecfa 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2890,8 +2890,6 @@ static int __snd_soc_unregister_component(struct device *dev)
 		if (dev != component->dev)
 			continue;
 
-		snd_soc_tplg_component_remove(component,
-					      SND_SOC_TPLG_INDEX_ALL);
 		snd_soc_component_del_unlocked(component);
 		found = 1;
 		break;
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-11-05  2:02   ` Pierre-Louis Bossart
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link() Kuninori Morimoto
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch moves soc_init_dai_link() next to soc_bind_dai_link().
This is prepare for soc_bind_dai_link() cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 192 +++++++++++++++++++++++++--------------------------
 1 file changed, 96 insertions(+), 96 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b07ecfa..a141828 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -941,6 +941,102 @@ static bool soc_is_dai_link_bound(struct snd_soc_card *card,
 	return false;
 }
 
+static int soc_init_dai_link(struct snd_soc_card *card,
+			     struct snd_soc_dai_link *link)
+{
+	int i;
+	struct snd_soc_dai_link_component *codec, *platform;
+
+	for_each_link_codecs(link, i, codec) {
+		/*
+		 * Codec must be specified by 1 of name or OF node,
+		 * not both or neither.
+		 */
+		if (!!codec->name == !!codec->of_node) {
+			dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
+				link->name);
+			return -EINVAL;
+		}
+
+		/* Codec DAI name must be specified */
+		if (!codec->dai_name) {
+			dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n",
+				link->name);
+			return -EINVAL;
+		}
+
+		/*
+		 * Defer card registration if codec component is not added to
+		 * component list.
+		 */
+		if (!soc_find_component(codec))
+			return -EPROBE_DEFER;
+	}
+
+	for_each_link_platforms(link, i, platform) {
+		/*
+		 * Platform may be specified by either name or OF node, but it
+		 * can be left unspecified, then no components will be inserted
+		 * in the rtdcom list
+		 */
+		if (!!platform->name == !!platform->of_node) {
+			dev_err(card->dev,
+				"ASoC: Neither/both platform name/of_node are set for %s\n",
+				link->name);
+			return -EINVAL;
+		}
+
+		/*
+		 * Defer card registration if platform component is not added to
+		 * component list.
+		 */
+		if (!soc_find_component(platform))
+			return -EPROBE_DEFER;
+	}
+
+	/* FIXME */
+	if (link->num_cpus > 1) {
+		dev_err(card->dev,
+			"ASoC: multi cpu is not yet supported %s\n",
+			link->name);
+		return -EINVAL;
+	}
+
+	/*
+	 * CPU device may be specified by either name or OF node, but
+	 * can be left unspecified, and will be matched based on DAI
+	 * name alone..
+	 */
+	if (link->cpus->name && link->cpus->of_node) {
+		dev_err(card->dev,
+			"ASoC: Neither/both cpu name/of_node are set for %s\n",
+			link->name);
+		return -EINVAL;
+	}
+
+	/*
+	 * Defer card registartion if cpu dai component is not added to
+	 * component list.
+	 */
+	if ((link->cpus->of_node || link->cpus->name) &&
+	    !soc_find_component(link->cpus))
+		return -EPROBE_DEFER;
+
+	/*
+	 * At least one of CPU DAI name or CPU device name/node must be
+	 * specified
+	 */
+	if (!link->cpus->dai_name &&
+	    !(link->cpus->name || link->cpus->of_node)) {
+		dev_err(card->dev,
+			"ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n",
+			link->name);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int soc_bind_dai_link(struct snd_soc_card *card,
 	struct snd_soc_dai_link *dai_link)
 {
@@ -1283,102 +1379,6 @@ static int soc_probe_link_components(struct snd_soc_card *card)
 	return 0;
 }
 
-static int soc_init_dai_link(struct snd_soc_card *card,
-			     struct snd_soc_dai_link *link)
-{
-	int i;
-	struct snd_soc_dai_link_component *codec, *platform;
-
-	for_each_link_codecs(link, i, codec) {
-		/*
-		 * Codec must be specified by 1 of name or OF node,
-		 * not both or neither.
-		 */
-		if (!!codec->name == !!codec->of_node) {
-			dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
-				link->name);
-			return -EINVAL;
-		}
-
-		/* Codec DAI name must be specified */
-		if (!codec->dai_name) {
-			dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n",
-				link->name);
-			return -EINVAL;
-		}
-
-		/*
-		 * Defer card registration if codec component is not added to
-		 * component list.
-		 */
-		if (!soc_find_component(codec))
-			return -EPROBE_DEFER;
-	}
-
-	for_each_link_platforms(link, i, platform) {
-		/*
-		 * Platform may be specified by either name or OF node, but it
-		 * can be left unspecified, then no components will be inserted
-		 * in the rtdcom list
-		 */
-		if (!!platform->name == !!platform->of_node) {
-			dev_err(card->dev,
-				"ASoC: Neither/both platform name/of_node are set for %s\n",
-				link->name);
-			return -EINVAL;
-		}
-
-		/*
-		 * Defer card registration if platform component is not added to
-		 * component list.
-		 */
-		if (!soc_find_component(platform))
-			return -EPROBE_DEFER;
-	}
-
-	/* FIXME */
-	if (link->num_cpus > 1) {
-		dev_err(card->dev,
-			"ASoC: multi cpu is not yet supported %s\n",
-			link->name);
-		return -EINVAL;
-	}
-
-	/*
-	 * CPU device may be specified by either name or OF node, but
-	 * can be left unspecified, and will be matched based on DAI
-	 * name alone..
-	 */
-	if (link->cpus->name && link->cpus->of_node) {
-		dev_err(card->dev,
-			"ASoC: Neither/both cpu name/of_node are set for %s\n",
-			link->name);
-		return -EINVAL;
-	}
-
-	/*
-	 * Defer card registartion if cpu dai component is not added to
-	 * component list.
-	 */
-	if ((link->cpus->of_node || link->cpus->name) &&
-	    !soc_find_component(link->cpus))
-		return -EPROBE_DEFER;
-
-	/*
-	 * At least one of CPU DAI name or CPU device name/node must be
-	 * specified
-	 */
-	if (!link->cpus->dai_name &&
-	    !(link->cpus->name || link->cpus->of_node)) {
-		dev_err(card->dev,
-			"ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n",
-			link->name);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 void snd_soc_disconnect_sync(struct device *dev)
 {
 	struct snd_soc_component *component =
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-11-05  3:02   ` Ranjani Sridharan
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 04/18] ASoC: soc-core: remove duplicated soc_is_dai_link_bound() Kuninori Morimoto
                   ` (16 subsequent siblings)
  19 siblings, 1 reply; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_init_dai_link() is needed to be called before soc_bind_dai_link().

	int snd_soc_instantiate_card()
	{
		for_each_card_prelinks(...) {
(1)			ret = soc_init_dai_link(...);
			...
		}
		...
		for_each_card_prelinks(...) {
(2)			ret = soc_bind_dai_link(...);
			...
		}
		...
		for_each_card_links(...) {
			...
(A)			ret = soc_init_dai_link(...);
			...
(B)			ret = soc_bind_dai_link(...);
		}
		...

(1) is for (2), and (A) is for (B)
(1) and (2) are for card prelink   dai_link.
(A) and (B) are for topology added dai_link.

soc_init_dai_link() is sanity check for dai_link, not initializing today.
Therefore, it is confusable naming. We can rename it as sanity_check.

And this check is for soc_bind_dai_link().
It can be more simple code if we can call it from soc_bind_dai_link().

This patch renames it to soc_dai_link_sanity_check(), and
call it from soc_bind_dai_link().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a141828..94763fc9c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -941,8 +941,8 @@ static bool soc_is_dai_link_bound(struct snd_soc_card *card,
 	return false;
 }
 
-static int soc_init_dai_link(struct snd_soc_card *card,
-			     struct snd_soc_dai_link *link)
+static int soc_dai_link_sanity_check(struct snd_soc_card *card,
+				     struct snd_soc_dai_link *link)
 {
 	int i;
 	struct snd_soc_dai_link_component *codec, *platform;
@@ -1043,11 +1043,15 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 	struct snd_soc_pcm_runtime *rtd;
 	struct snd_soc_dai_link_component *codec, *platform;
 	struct snd_soc_component *component;
-	int i;
+	int i, ret;
 
 	if (dai_link->ignore)
 		return 0;
 
+	ret = soc_dai_link_sanity_check(card, dai_link);
+	if (ret < 0)
+		return ret;
+
 	dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
 
 	if (soc_is_dai_link_bound(card, dai_link)) {
@@ -1985,15 +1989,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	int ret, i;
 
 	mutex_lock(&client_mutex);
-	for_each_card_prelinks(card, i, dai_link) {
-		ret = soc_init_dai_link(card, dai_link);
-		if (ret) {
-			dev_err(card->dev, "ASoC: failed to init link %s: %d\n",
-				dai_link->name, ret);
-			mutex_unlock(&client_mutex);
-			return ret;
-		}
-	}
 	mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
 
 	snd_soc_dapm_init(&card->dapm, card, NULL);
@@ -2073,9 +2068,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 		if (soc_is_dai_link_bound(card, dai_link))
 			continue;
 
-		ret = soc_init_dai_link(card, dai_link);
-		if (ret)
-			goto probe_end;
 		ret = soc_bind_dai_link(card, dai_link);
 		if (ret)
 			goto probe_end;
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 04/18] ASoC: soc-core: remove duplicated soc_is_dai_link_bound()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 05/18] ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link() Kuninori Morimoto
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_is_dai_link_bound() check will be called both
*before* soc_bind_dai_link() (A), and
*under*  soc_bind_dai_link() (B).
These are very verbose code. Let's remove one of them.

*	static int soc_bind_dai_link(...)
	{
		...
(B)		if (soc_is_dai_link_bound(...)) {
			...
			return 0;
		}
		...
	}

	static int snd_soc_instantiate_card(...)
	{
		...
		for_each_card_links(...) {
(A)			if (soc_is_dai_link_bound(...))
				continue;

*			ret = soc_bind_dai_link(...);
			if (ret)
				goto probe_end;
		}
		...
	}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 94763fc9c..91d3fd5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2065,9 +2065,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	 * Components with topology may bring new DAIs and DAI links.
 	 */
 	for_each_card_links(card, dai_link) {
-		if (soc_is_dai_link_bound(card, dai_link))
-			continue;
-
 		ret = soc_bind_dai_link(card, dai_link);
 		if (ret)
 			goto probe_end;
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 05/18] ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 04/18] ASoC: soc-core: remove duplicated soc_is_dai_link_bound() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 06/18] ASoC: soc-core: add soc_unbind_dai_link() Kuninori Morimoto
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

If we focus to soc_bind_dai_link() at snd_soc_instantiate_card(),
we will notice very complex operation.

static int snd_soc_instantiate_card(...)
{
	...
	/*
	 * (1) Bind dai_link via card pre-linked dai_link
	 *
	 * Bind dai_link via card pre-linked.
	 * 1 dai_link will be 1 rtd, and connected to card.
	 * for_each_card_prelinks() is for card pre-linked dai_link.
	 *
	 * Image
	 *
	 * card
	 * - rtd(A)
	 * - rtd(A)
	 */
	for_each_card_prelinks(card, i, dai_link) {
		ret = soc_bind_dai_link(card, dai_link);
		...
	}
	...
	/*
	 * (2) Connect card pre-linked dai_link to card list
	 *
	 * Connect all card pre-linked dai_link to *card list*.
	 * Here, (A) means from card pre-linked.
	 *
	 * Image
	 *
	 * card		card list
	 *  - rtd(A)	 - dai_link(A)
	 *  - rtd(A)	 - dai_link(A)
	 *  - ...	 - ...
	 */
	for_each_card_prelinks(card, i, dai_link) {
		ret = snd_soc_add_dai_link(card, dai_link);
		...
	}
	...
	/*
	 * (3) Probe binded component
	 *
	 * Each rtd has many components.
	 * Here probes each rtd connected components.
	 * rtd(A) in Image is the probe target.
	 *
	 * During this component probe, topology may add new dai_link to
	 * *card list* by using snd_soc_add_dai_link() which is
	 * used at (2).
	 * Here, (B) means from topology
	 *
	 * Image
	 *
	 * card		card list
	 *  - rtd(A)	 - dai_link(A)
	 *  - rtd(A)	 - dai_link(A)
	 *  - ...	 - ...
	 *		 - dai_link(B)
	 *		 - dai_link(B)
	 */
	ret = soc_probe_link_components(card);
	...

	/*
	 * (4) Bind dai_link again
	 *
	 * Bind dai_link again for topology.
	 * Note, (1) used for_each_card_prelinks(),
	 * here is using  for_each_card_links()
	 *
	 * This means from card list.
	 * As Image indicating, it has dai_link(A) (from card pre-link)
	 * and dai_link(B) (from topology).
	 * main target here is dai_link(B).
	 * soc_bind_dai_link() ignores already used
	 * dai_link (= dai_link(A))
	 *
	 * Image
	 *
	 * card		card list
	 *  - rtd(A)	 - dai_link(A)
	 *  - rtd(A)	 - dai_link(A)
	 *  - ...	 - ...
	 *  - rtd(B)	 - dai_link(B)
	 *  - rtd(B)	 - dai_link(B)
	 */
	for_each_card_links(card, dai_link) {
		ret = soc_bind_dai_link(card, dai_link);
		...
	}
	...
}

As you see above, it is doing very complex method.
The problem is binding dai_link via "card pre-linked" (= (1)) and
"topology added dai_link" (= (3)) are separated.
The code can be simple if we can bind dai_link when dai_link
is connected to *card list*.
This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 91d3fd5..40774c6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1409,6 +1409,8 @@ EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync);
 int snd_soc_add_dai_link(struct snd_soc_card *card,
 		struct snd_soc_dai_link *dai_link)
 {
+	int ret;
+
 	if (dai_link->dobj.type
 	    && dai_link->dobj.type != SND_SOC_DOBJ_DAI_LINK) {
 		dev_err(card->dev, "Invalid dai link type %d\n",
@@ -1424,6 +1426,10 @@ int snd_soc_add_dai_link(struct snd_soc_card *card,
 	if (dai_link->dobj.type && card->add_dai_link)
 		card->add_dai_link(card, dai_link);
 
+	ret = soc_bind_dai_link(card, dai_link);
+	if (ret < 0)
+		return ret;
+
 	/* see for_each_card_links */
 	list_add_tail(&dai_link->list, &card->dai_link_list);
 
@@ -1996,13 +2002,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	/* check whether any platform is ignore machine FE and using topology */
 	soc_check_tplg_fes(card);
 
-	/* bind DAIs */
-	for_each_card_prelinks(card, i, dai_link) {
-		ret = soc_bind_dai_link(card, dai_link);
-		if (ret != 0)
-			goto probe_end;
-	}
-
 	/* bind aux_devs too */
 	ret = soc_bind_aux_dev(card);
 	if (ret < 0)
@@ -2060,16 +2059,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	if (ret < 0)
 		goto probe_end;
 
-	/*
-	 * Find new DAI links added during probing components and bind them.
-	 * Components with topology may bring new DAIs and DAI links.
-	 */
-	for_each_card_links(card, dai_link) {
-		ret = soc_bind_dai_link(card, dai_link);
-		if (ret)
-			goto probe_end;
-	}
-
 	/* probe all DAI links on this card */
 	ret = soc_probe_link_dais(card);
 	if (ret < 0) {
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 06/18] ASoC: soc-core: add soc_unbind_dai_link()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 05/18] ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component() Kuninori Morimoto
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and it will be difficult to
debug.

ALSA SoC has soc_bind_dai_link(), but its paired soc_unbind_dai_link()
is not implemented.
More confusable is that soc_remove_pcm_runtimes() which should be
soc_unbind_dai_link() is implemented without synchronised
to soc_bind_dai_link().

This patch cleanup this unbalance.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 40774c6..fa837c0 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -470,14 +470,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
 	return NULL;
 }
 
-static void soc_remove_pcm_runtimes(struct snd_soc_card *card)
-{
-	struct snd_soc_pcm_runtime *rtd, *_rtd;
-
-	for_each_card_rtds_safe(card, rtd, _rtd)
-		soc_free_pcm_runtime(rtd);
-}
-
 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
 		const char *dai_link)
 {
@@ -1037,6 +1029,16 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card,
 	return 0;
 }
 
+static void soc_unbind_dai_link(struct snd_soc_card *card,
+				struct snd_soc_dai_link *dai_link)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	rtd = snd_soc_get_pcm_runtime(card, dai_link->name);
+	if (rtd)
+		soc_free_pcm_runtime(rtd);
+}
+
 static int soc_bind_dai_link(struct snd_soc_card *card,
 	struct snd_soc_dai_link *dai_link)
 {
@@ -1466,6 +1468,8 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,
 		card->remove_dai_link(card, dai_link);
 
 	list_del(&dai_link->list);
+
+	soc_unbind_dai_link(card, dai_link);
 }
 EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link);
 
@@ -1974,8 +1978,6 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
 	for_each_card_links_safe(card, link, _link)
 		snd_soc_remove_dai_link(card, link);
 
-	soc_remove_pcm_runtimes(card);
-
 	/* remove auxiliary devices */
 	soc_remove_aux_devices(card);
 	soc_unbind_aux_dev(card);
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 06/18] ASoC: soc-core: add soc_unbind_dai_link() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-11-05  2:22   ` Pierre-Louis Bossart
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 08/18] ASoC: soc-core: add snd_soc_del_component_unlocked() Kuninori Morimoto
                   ` (12 subsequent siblings)
  19 siblings, 1 reply; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch moves snd_soc_lookup_component() to upper side.
This is prepare for snd_soc_unregister_component()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fa837c0..72eb59c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -356,6 +356,32 @@ struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
 }
 EXPORT_SYMBOL_GPL(snd_soc_rtdcom_lookup);
 
+struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
+						   const char *driver_name)
+{
+	struct snd_soc_component *component;
+	struct snd_soc_component *ret;
+
+	ret = NULL;
+	mutex_lock(&client_mutex);
+	for_each_component(component) {
+		if (dev != component->dev)
+			continue;
+
+		if (driver_name &&
+		    (driver_name != component->driver->name) &&
+		    (strcmp(component->driver->name, driver_name) != 0))
+			continue;
+
+		ret = component;
+		break;
+	}
+	mutex_unlock(&client_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
+
 struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
 		const char *dai_link, int stream)
 {
@@ -2889,32 +2915,6 @@ void snd_soc_unregister_component(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
 
-struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
-						   const char *driver_name)
-{
-	struct snd_soc_component *component;
-	struct snd_soc_component *ret;
-
-	ret = NULL;
-	mutex_lock(&client_mutex);
-	for_each_component(component) {
-		if (dev != component->dev)
-			continue;
-
-		if (driver_name &&
-		    (driver_name != component->driver->name) &&
-		    (strcmp(component->driver->name, driver_name) != 0))
-			continue;
-
-		ret = component;
-		break;
-	}
-	mutex_unlock(&client_mutex);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
-
 /* Retrieve a card's name from device tree */
 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 			       const char *propname)
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 08/18] ASoC: soc-core: add snd_soc_del_component_unlocked()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 09/18] ASoC: soc-core: remove snd_soc_component_add/del() Kuninori Morimoto
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and is difficult to debug.

Now ALSA SoC has snd_soc_add_component(), but there is no paired
snd_soc_del_component(). Thus, snd_soc_unregister_component() is
calling cleanup function randomly. it is difficult to read.
This patch adds missing snd_soc_del_component_unlocked() and
balance up code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 72eb59c..defcd4c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2767,12 +2767,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)
 	mutex_unlock(&client_mutex);
 }
 
-static void snd_soc_component_cleanup(struct snd_soc_component *component)
-{
-	snd_soc_unregister_dais(component);
-}
-
-static void snd_soc_component_del_unlocked(struct snd_soc_component *component)
+static void snd_soc_component_del(struct snd_soc_component *component)
 {
 	struct snd_soc_card *card = component->card;
 
@@ -2826,6 +2821,12 @@ static void snd_soc_try_rebind_card(void)
 			list_del(&card->list);
 }
 
+static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
+{
+	snd_soc_unregister_dais(component);
+	snd_soc_component_del(component);
+}
+
 int snd_soc_add_component(struct device *dev,
 			struct snd_soc_component *component,
 			const struct snd_soc_component_driver *component_driver,
@@ -2858,7 +2859,7 @@ int snd_soc_add_component(struct device *dev,
 	return 0;
 
 err_cleanup:
-	snd_soc_component_cleanup(component);
+	snd_soc_del_component_unlocked(component);
 err_free:
 	return ret;
 }
@@ -2896,15 +2897,12 @@ static int __snd_soc_unregister_component(struct device *dev)
 		if (dev != component->dev)
 			continue;
 
-		snd_soc_component_del_unlocked(component);
+		snd_soc_del_component_unlocked(component);
 		found = 1;
 		break;
 	}
 	mutex_unlock(&client_mutex);
 
-	if (found)
-		snd_soc_component_cleanup(component);
-
 	return found;
 }
 
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 09/18] ASoC: soc-core: remove snd_soc_component_add/del()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 08/18] ASoC: soc-core: add snd_soc_del_component_unlocked() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 10/18] ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component() Kuninori Morimoto
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc-core has
snd_soc_add_component(), snd_soc_component_add(),
snd_soc_del_component(), snd_soc_component_del().

These are very confusing naming.
snd_soc_component_xxx() are called from snd_soc_xxx_component(),
and these are very small.
Let's merge these into snd_soc_xxx_component(), and
remove snd_soc_component_xxx().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 58 ++++++++++++++++++++++------------------------------
 1 file changed, 25 insertions(+), 33 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index defcd4c..1bb98ac 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2749,34 +2749,6 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
 
 #endif
 
-static void snd_soc_component_add(struct snd_soc_component *component)
-{
-	mutex_lock(&client_mutex);
-
-	if (!component->driver->write && !component->driver->read) {
-		if (!component->regmap)
-			component->regmap = dev_get_regmap(component->dev,
-							   NULL);
-		if (component->regmap)
-			snd_soc_component_setup_regmap(component);
-	}
-
-	/* see for_each_component */
-	list_add(&component->list, &component_list);
-
-	mutex_unlock(&client_mutex);
-}
-
-static void snd_soc_component_del(struct snd_soc_component *component)
-{
-	struct snd_soc_card *card = component->card;
-
-	if (card)
-		snd_soc_unbind_card(card, false);
-
-	list_del(&component->list);
-}
-
 #define ENDIANNESS_MAP(name) \
 	(SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE)
 static u64 endianness_format_map[] = {
@@ -2823,8 +2795,14 @@ static void snd_soc_try_rebind_card(void)
 
 static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
 {
+	struct snd_soc_card *card = component->card;
+
 	snd_soc_unregister_dais(component);
-	snd_soc_component_del(component);
+
+	if (card)
+		snd_soc_unbind_card(card, false);
+
+	list_del(&component->list);
 }
 
 int snd_soc_add_component(struct device *dev,
@@ -2836,6 +2814,8 @@ int snd_soc_add_component(struct device *dev,
 	int ret;
 	int i;
 
+	mutex_lock(&client_mutex);
+
 	ret = snd_soc_component_initialize(component, component_driver, dev);
 	if (ret)
 		goto err_free;
@@ -2853,14 +2833,26 @@ int snd_soc_add_component(struct device *dev,
 		goto err_cleanup;
 	}
 
-	snd_soc_component_add(component);
-	snd_soc_try_rebind_card();
+	if (!component->driver->write && !component->driver->read) {
+		if (!component->regmap)
+			component->regmap = dev_get_regmap(component->dev,
+							   NULL);
+		if (component->regmap)
+			snd_soc_component_setup_regmap(component);
+	}
 
-	return 0;
+	/* see for_each_component */
+	list_add(&component->list, &component_list);
 
 err_cleanup:
-	snd_soc_del_component_unlocked(component);
+	if (ret < 0)
+		snd_soc_del_component_unlocked(component);
 err_free:
+	mutex_unlock(&client_mutex);
+
+	if (ret == 0)
+		snd_soc_try_rebind_card();
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_add_component);
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 10/18] ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 09/18] ASoC: soc-core: remove snd_soc_component_add/del() Kuninori Morimoto
@ 2019-10-30  1:26 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 11/18] ASoC: soc-core: move snd_soc_register_dai() Kuninori Morimoto
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_unregister_component() is now finding component manually,
but we already have snd_soc_lookup_component() to find component;
Let's use existing function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1bb98ac..d05d95c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2879,29 +2879,19 @@ EXPORT_SYMBOL_GPL(snd_soc_register_component);
  *
  * @dev: The device to unregister
  */
-static int __snd_soc_unregister_component(struct device *dev)
+void snd_soc_unregister_component(struct device *dev)
 {
 	struct snd_soc_component *component;
-	int found = 0;
 
 	mutex_lock(&client_mutex);
-	for_each_component(component) {
-		if (dev != component->dev)
-			continue;
+	while (1) {
+		component = snd_soc_lookup_component(dev, NULL);
+		if (!component)
+			break;
 
 		snd_soc_del_component_unlocked(component);
-		found = 1;
-		break;
 	}
 	mutex_unlock(&client_mutex);
-
-	return found;
-}
-
-void snd_soc_unregister_component(struct device *dev)
-{
-	while (__snd_soc_unregister_component(dev))
-		;
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
 
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 11/18] ASoC: soc-core: move snd_soc_register_dai()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 10/18] ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component() Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 12/18] ASoC: soc-core: move snd_soc_unregister_dais() Kuninori Morimoto
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch moves snd_soc_register_dai() next to
snd_soc_register_dais().
This is prepare for snd_soc_register_dais() cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 72 ++++++++++++++++++++++++++--------------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d05d95c..2de9848 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2601,42 +2601,6 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
 }
 
 /**
- * snd_soc_register_dais - Register a DAI with the ASoC core
- *
- * @component: The component the DAIs are registered for
- * @dai_drv: DAI driver to use for the DAIs
- * @count: Number of DAIs
- */
-static int snd_soc_register_dais(struct snd_soc_component *component,
-				 struct snd_soc_dai_driver *dai_drv,
-				 size_t count)
-{
-	struct device *dev = component->dev;
-	struct snd_soc_dai *dai;
-	unsigned int i;
-	int ret;
-
-	dev_dbg(dev, "ASoC: dai register %s #%zu\n", dev_name(dev), count);
-
-	for (i = 0; i < count; i++) {
-
-		dai = soc_add_dai(component, dai_drv + i, count == 1 &&
-				  !component->driver->non_legacy_dai_naming);
-		if (dai == NULL) {
-			ret = -ENOMEM;
-			goto err;
-		}
-	}
-
-	return 0;
-
-err:
-	snd_soc_unregister_dais(component);
-
-	return ret;
-}
-
-/**
  * snd_soc_register_dai - Register a DAI dynamically & create its widgets
  *
  * @component: The component the DAIs are registered for
@@ -2679,6 +2643,42 @@ int snd_soc_register_dai(struct snd_soc_component *component,
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_dai);
 
+/**
+ * snd_soc_register_dais - Register a DAI with the ASoC core
+ *
+ * @component: The component the DAIs are registered for
+ * @dai_drv: DAI driver to use for the DAIs
+ * @count: Number of DAIs
+ */
+static int snd_soc_register_dais(struct snd_soc_component *component,
+				 struct snd_soc_dai_driver *dai_drv,
+				 size_t count)
+{
+	struct device *dev = component->dev;
+	struct snd_soc_dai *dai;
+	unsigned int i;
+	int ret;
+
+	dev_dbg(dev, "ASoC: dai register %s #%zu\n", dev_name(dev), count);
+
+	for (i = 0; i < count; i++) {
+
+		dai = soc_add_dai(component, dai_drv + i, count == 1 &&
+				  !component->driver->non_legacy_dai_naming);
+		if (dai == NULL) {
+			ret = -ENOMEM;
+			goto err;
+		}
+	}
+
+	return 0;
+
+err:
+	snd_soc_unregister_dais(component);
+
+	return ret;
+}
+
 static int snd_soc_component_initialize(struct snd_soc_component *component,
 	const struct snd_soc_component_driver *driver, struct device *dev)
 {
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 12/18] ASoC: soc-core: move snd_soc_unregister_dais()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (10 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 11/18] ASoC: soc-core: move snd_soc_register_dai() Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 13/18] ASoC: soc-core: add snd_soc_unregister_dai() Kuninori Morimoto
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch moves snd_soc_unregister_dais() next to
snd_soc_register_dais().
This is prepare for snd_soc_register_dais() cleanup

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2de9848..9595406 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2535,22 +2535,6 @@ static inline char *fmt_multiple_name(struct device *dev,
 	return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL);
 }
 
-/**
- * snd_soc_unregister_dai - Unregister DAIs from the ASoC core
- *
- * @component: The component for which the DAIs should be unregistered
- */
-static void snd_soc_unregister_dais(struct snd_soc_component *component)
-{
-	struct snd_soc_dai *dai, *_dai;
-
-	for_each_component_dais_safe(component, dai, _dai) {
-		dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n",
-			dai->name);
-		list_del(&dai->list);
-	}
-}
-
 /* Create a DAI and add it to the component's DAI list */
 static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
 	struct snd_soc_dai_driver *dai_drv,
@@ -2644,6 +2628,22 @@ int snd_soc_register_dai(struct snd_soc_component *component,
 EXPORT_SYMBOL_GPL(snd_soc_register_dai);
 
 /**
+ * snd_soc_unregister_dai - Unregister DAIs from the ASoC core
+ *
+ * @component: The component for which the DAIs should be unregistered
+ */
+static void snd_soc_unregister_dais(struct snd_soc_component *component)
+{
+	struct snd_soc_dai *dai, *_dai;
+
+	for_each_component_dais_safe(component, dai, _dai) {
+		dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n",
+			dai->name);
+		list_del(&dai->list);
+	}
+}
+
+/**
  * snd_soc_register_dais - Register a DAI with the ASoC core
  *
  * @component: The component the DAIs are registered for
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 13/18] ASoC: soc-core: add snd_soc_unregister_dai()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (11 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 12/18] ASoC: soc-core: move snd_soc_unregister_dais() Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 14/18] ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai() Kuninori Morimoto
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and is difficult to debug.

This patch adds missing soc_del_dai() and snd_soc_unregister_dai().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  1 +
 sound/soc/soc-core.c | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 320dcd4..daa0e10 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1328,6 +1328,7 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
 
 int snd_soc_register_dai(struct snd_soc_component *component,
 	struct snd_soc_dai_driver *dai_drv);
+void snd_soc_unregister_dai(struct snd_soc_dai *dai);
 
 struct snd_soc_dai *snd_soc_find_dai(
 	const struct snd_soc_dai_link_component *dlc);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9595406..2b9dc11 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2535,6 +2535,12 @@ static inline char *fmt_multiple_name(struct device *dev,
 	return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL);
 }
 
+static void soc_del_dai(struct snd_soc_dai *dai)
+{
+	dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name);
+	list_del(&dai->list);
+}
+
 /* Create a DAI and add it to the component's DAI list */
 static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
 	struct snd_soc_dai_driver *dai_drv,
@@ -2584,6 +2590,12 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
 	return dai;
 }
 
+void snd_soc_unregister_dai(struct snd_soc_dai *dai)
+{
+	soc_del_dai(dai);
+}
+EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
+
 /**
  * snd_soc_register_dai - Register a DAI dynamically & create its widgets
  *
@@ -2636,11 +2648,8 @@ static void snd_soc_unregister_dais(struct snd_soc_component *component)
 {
 	struct snd_soc_dai *dai, *_dai;
 
-	for_each_component_dais_safe(component, dai, _dai) {
-		dev_dbg(component->dev, "ASoC: Unregistered DAI '%s'\n",
-			dai->name);
-		list_del(&dai->list);
-	}
+	for_each_component_dais_safe(component, dai, _dai)
+		snd_soc_unregister_dai(dai);
 }
 
 /**
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 14/18] ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (12 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 13/18] ASoC: soc-core: add snd_soc_unregister_dai() Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() " Kuninori Morimoto
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC has 2 functions.
snd_soc_register_dai()  is used from topology
snd_soc_register_dais() is used from snd_soc_add_component()

In general, people think like _dai() is called from _dais()
with for loop. But in reality, these are very similar
but different implementation.
We shouldn't have duplicated and confusing implementation.

snd_soc_register_dai() is now used from topology.
But to reduce duplicated code, it should be used from _dais(), too.
To prepare it, this patch adds missing parameter legacy_dai_naming
to snd_soc_register_dai().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h      | 3 ++-
 sound/soc/soc-core.c     | 5 +++--
 sound/soc/soc-topology.c | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index daa0e10..766fa81 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1327,7 +1327,8 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
 					       const char *stream_name);
 
 int snd_soc_register_dai(struct snd_soc_component *component,
-	struct snd_soc_dai_driver *dai_drv);
+			 struct snd_soc_dai_driver *dai_drv,
+			 bool legacy_dai_naming);
 void snd_soc_unregister_dai(struct snd_soc_dai *dai);
 
 struct snd_soc_dai *snd_soc_find_dai(
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2b9dc11..7bd38fb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2607,7 +2607,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
  * will be freed in the component cleanup.
  */
 int snd_soc_register_dai(struct snd_soc_component *component,
-	struct snd_soc_dai_driver *dai_drv)
+			 struct snd_soc_dai_driver *dai_drv,
+			 bool legacy_dai_naming)
 {
 	struct snd_soc_dapm_context *dapm =
 		snd_soc_component_get_dapm(component);
@@ -2621,7 +2622,7 @@ int snd_soc_register_dai(struct snd_soc_component *component,
 	}
 
 	lockdep_assert_held(&client_mutex);
-	dai = soc_add_dai(component, dai_drv, false);
+	dai = soc_add_dai(component, dai_drv, legacy_dai_naming);
 	if (!dai)
 		return -ENOMEM;
 
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 0fd0329..b6e1456 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1842,7 +1842,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
 	list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);
 
 	/* register the DAI to the component */
-	return snd_soc_register_dai(tplg->comp, dai_drv);
+	return snd_soc_register_dai(tplg->comp, dai_drv, false);
 }
 
 static void set_link_flags(struct snd_soc_dai_link *link,
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (13 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 14/18] ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai() Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-11-05  3:20   ` Ranjani Sridharan
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 16/18] ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais() Kuninori Morimoto
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC has 2 functions.
snd_soc_register_dai()  is used from topology
snd_soc_register_dais() is used from snd_soc_add_component()

In general, people think like _dai() is called from _dais()
with for loop. But in reality, these are very similar
but different implementation.
We shouldn't have duplicated and confusing implementation.

snd_soc_register_dai() is now used from topology.
But to reduce duplicated code, it should be used from _dais(), too.

Because of topology side specific reason,
it is calling snd_soc_dapm_new_dai_widgets(),
but it is not needed _dais() side.

This patch factorizes snd_soc_register_dai() to
topology / _dais() common part, and topology specific part.
And do topology specific part at soc-topology.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h      |  6 +++---
 sound/soc/soc-core.c     | 25 ++++++-------------------
 sound/soc/soc-topology.c | 17 ++++++++++++++++-
 3 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 766fa81..4e38ee6 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1326,9 +1326,9 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
 					       int id, const char *name,
 					       const char *stream_name);
 
-int snd_soc_register_dai(struct snd_soc_component *component,
-			 struct snd_soc_dai_driver *dai_drv,
-			 bool legacy_dai_naming);
+struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
+					 struct snd_soc_dai_driver *dai_drv,
+					 bool legacy_dai_naming);
 void snd_soc_unregister_dai(struct snd_soc_dai *dai);
 
 struct snd_soc_dai *snd_soc_find_dai(
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7bd38fb..8045f4f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2606,37 +2606,24 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
  * These DAIs's widgets will be freed in the card cleanup and the DAIs
  * will be freed in the component cleanup.
  */
-int snd_soc_register_dai(struct snd_soc_component *component,
-			 struct snd_soc_dai_driver *dai_drv,
-			 bool legacy_dai_naming)
+struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
+					 struct snd_soc_dai_driver *dai_drv,
+					 bool legacy_dai_naming)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
 	struct snd_soc_dai *dai;
-	int ret;
 
 	if (dai_drv->dobj.type != SND_SOC_DOBJ_PCM) {
 		dev_err(component->dev, "Invalid dai type %d\n",
 			dai_drv->dobj.type);
-		return -EINVAL;
+		return NULL;
 	}
 
 	lockdep_assert_held(&client_mutex);
 	dai = soc_add_dai(component, dai_drv, legacy_dai_naming);
 	if (!dai)
-		return -ENOMEM;
-
-	/*
-	 * Create the DAI widgets here. After adding DAIs, topology may
-	 * also add routes that need these widgets as source or sink.
-	 */
-	ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
-	if (ret != 0) {
-		dev_err(component->dev,
-			"Failed to create DAI widgets %d\n", ret);
-	}
+		return NULL;
 
-	return ret;
+	return dai;
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_dai);
 
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index b6e1456..81d2af0 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1800,6 +1800,9 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
 	struct snd_soc_dai_driver *dai_drv;
 	struct snd_soc_pcm_stream *stream;
 	struct snd_soc_tplg_stream_caps *caps;
+	struct snd_soc_dai *dai;
+	struct snd_soc_dapm_context *dapm =
+		snd_soc_component_get_dapm(tplg->comp);
 	int ret;
 
 	dai_drv = kzalloc(sizeof(struct snd_soc_dai_driver), GFP_KERNEL);
@@ -1842,7 +1845,19 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
 	list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);
 
 	/* register the DAI to the component */
-	return snd_soc_register_dai(tplg->comp, dai_drv, false);
+	dai = snd_soc_register_dai(tplg->comp, dai_drv, false);
+	if (!dai)
+		return -ENOMEM;
+
+	/* Create the DAI widgets here */
+	ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
+	if (ret != 0) {
+		dev_err(dai->dev, "Failed to create DAI widgets %d\n", ret);
+		snd_soc_unregister_dai(dai);
+		return ret;
+	}
+
+	return ret;
 }
 
 static void set_link_flags(struct snd_soc_dai_link *link,
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 16/18] ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais()
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (14 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() " Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 17/18] ASoC: soc-core: remove topology specific operation Kuninori Morimoto
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC has 2 functions.
snd_soc_register_dai()  is used from topology
snd_soc_register_dais() is used from snd_soc_add_component()

In general, people think like _dai() is called from _dais()
with for loop. But in reality, these are very similar
but different implementation.
We shouldn't have duplicated and confusing implementation.

This patch calls snd_soc_register_dai() from snd_soc_register_dais()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8045f4f..8be78d5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2610,14 +2610,17 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 					 struct snd_soc_dai_driver *dai_drv,
 					 bool legacy_dai_naming)
 {
+	struct device *dev = component->dev;
 	struct snd_soc_dai *dai;
 
-	if (dai_drv->dobj.type != SND_SOC_DOBJ_PCM) {
-		dev_err(component->dev, "Invalid dai type %d\n",
-			dai_drv->dobj.type);
+	if (dai_drv->dobj.type &&
+	    dai_drv->dobj.type != SND_SOC_DOBJ_PCM) {
+		dev_err(dev, "Invalid dai type %d\n", dai_drv->dobj.type);
 		return NULL;
 	}
 
+	dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name);
+
 	lockdep_assert_held(&client_mutex);
 	dai = soc_add_dai(component, dai_drv, legacy_dai_naming);
 	if (!dai)
@@ -2651,16 +2654,12 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
 				 struct snd_soc_dai_driver *dai_drv,
 				 size_t count)
 {
-	struct device *dev = component->dev;
 	struct snd_soc_dai *dai;
 	unsigned int i;
 	int ret;
 
-	dev_dbg(dev, "ASoC: dai register %s #%zu\n", dev_name(dev), count);
-
 	for (i = 0; i < count; i++) {
-
-		dai = soc_add_dai(component, dai_drv + i, count == 1 &&
+		dai = snd_soc_register_dai(component, dai_drv + i, count == 1 &&
 				  !component->driver->non_legacy_dai_naming);
 		if (dai == NULL) {
 			ret = -ENOMEM;
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 17/18] ASoC: soc-core: remove topology specific operation
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (15 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 16/18] ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais() Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 18/18] ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY Kuninori Morimoto
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc-core has some API which is used from topology, but it is doing
topology specific operation at soc-core.
soc-core should care about core things, and topology should care
about topology things, otherwise, it is very confusable.

For example topology type is not related to soc-core,
it is topology side issue.

This patch removes meaningless check from soc-core.

This patch keeps extra initialization/destruction at
snd_soc_add_dai_link() / snd_soc_remove_dai_link()
which were for topology.
From this patch, non-topology card can use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8be78d5..1cf8d09 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1439,19 +1439,12 @@ int snd_soc_add_dai_link(struct snd_soc_card *card,
 {
 	int ret;
 
-	if (dai_link->dobj.type
-	    && dai_link->dobj.type != SND_SOC_DOBJ_DAI_LINK) {
-		dev_err(card->dev, "Invalid dai link type %d\n",
-			dai_link->dobj.type);
-		return -EINVAL;
-	}
-
 	lockdep_assert_held(&client_mutex);
+
 	/*
 	 * Notify the machine driver for extra initialization
-	 * on the link created by topology.
 	 */
-	if (dai_link->dobj.type && card->add_dai_link)
+	if (card->add_dai_link)
 		card->add_dai_link(card, dai_link);
 
 	ret = soc_bind_dai_link(card, dai_link);
@@ -1478,19 +1471,12 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_link);
 void snd_soc_remove_dai_link(struct snd_soc_card *card,
 			     struct snd_soc_dai_link *dai_link)
 {
-	if (dai_link->dobj.type
-	    && dai_link->dobj.type != SND_SOC_DOBJ_DAI_LINK) {
-		dev_err(card->dev, "Invalid dai link type %d\n",
-			dai_link->dobj.type);
-		return;
-	}
-
 	lockdep_assert_held(&client_mutex);
+
 	/*
 	 * Notify the machine driver for extra destruction
-	 * on the link created by topology.
 	 */
-	if (dai_link->dobj.type && card->remove_dai_link)
+	if (card->remove_dai_link)
 		card->remove_dai_link(card, dai_link);
 
 	list_del(&dai_link->list);
@@ -2613,12 +2599,6 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 	struct device *dev = component->dev;
 	struct snd_soc_dai *dai;
 
-	if (dai_drv->dobj.type &&
-	    dai_drv->dobj.type != SND_SOC_DOBJ_PCM) {
-		dev_err(dev, "Invalid dai type %d\n", dai_drv->dobj.type);
-		return NULL;
-	}
-
 	dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name);
 
 	lockdep_assert_held(&client_mutex);
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [alsa-devel] [PATCH v2 resend 18/18] ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (16 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 17/18] ASoC: soc-core: remove topology specific operation Kuninori Morimoto
@ 2019-10-30  1:27 ` Kuninori Morimoto
  2019-10-30 11:34 ` [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Mark Brown
  2019-11-05  2:38 ` Pierre-Louis Bossart
  19 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-30  1:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_dobj is used only when SND_SOC_TOPOLOGY was selected.
Let's enable it under SND_SOC_TOPOLOGY.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 4e38ee6..e0855dc 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -847,7 +847,9 @@ struct snd_soc_dai_link {
 	unsigned int ignore:1;
 
 	struct list_head list; /* DAI link list of the soc card */
+#ifdef CONFIG_SND_SOC_TOPOLOGY
 	struct snd_soc_dobj dobj; /* For topology */
+#endif
 };
 #define for_each_link_codecs(link, i, codec)				\
 	for ((i) = 0;							\
@@ -1169,7 +1171,9 @@ struct soc_mixer_control {
 	unsigned int sign_bit;
 	unsigned int invert:1;
 	unsigned int autodisable:1;
+#ifdef CONFIG_SND_SOC_TOPOLOGY
 	struct snd_soc_dobj dobj;
+#endif
 };
 
 struct soc_bytes {
@@ -1180,8 +1184,9 @@ struct soc_bytes {
 
 struct soc_bytes_ext {
 	int max;
+#ifdef CONFIG_SND_SOC_TOPOLOGY
 	struct snd_soc_dobj dobj;
-
+#endif
 	/* used for TLV byte control */
 	int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
 			unsigned int size);
@@ -1205,7 +1210,9 @@ struct soc_enum {
 	const char * const *texts;
 	const unsigned int *values;
 	unsigned int autodisable:1;
+#ifdef CONFIG_SND_SOC_TOPOLOGY
 	struct snd_soc_dobj dobj;
+#endif
 };
 
 /* device driver data */
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (17 preceding siblings ...)
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 18/18] ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY Kuninori Morimoto
@ 2019-10-30 11:34 ` Mark Brown
  2019-10-31  0:46   ` Kuninori Morimoto
  2019-11-05  2:38 ` Pierre-Louis Bossart
  19 siblings, 1 reply; 36+ messages in thread
From: Mark Brown @ 2019-10-30 11:34 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA


[-- Attachment #1.1: Type: text/plain, Size: 336 bytes --]

On Wed, Oct 30, 2019 at 10:23:06AM +0900, Kuninori Morimoto wrote:

> These are resend of soc-core cleanup step4.
> These are based on mark/for-5.5 branch.
> I already got report from Intel that these had no issue on Intel CI machine.

OK, that's not very visible :(  I'd been waiting for the review from
them that you said was needed.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [alsa-devel] Applied "ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()" to the asoc tree
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Kuninori Morimoto
@ 2019-10-30 12:57   ` Mark Brown
  2019-11-05  2:55   ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Sridharan, Ranjani
  1 sibling, 0 replies; 36+ messages in thread
From: Mark Brown @ 2019-10-30 12:57 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

The patch

   ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From e9904ed5e73af4fd00cf4fcf705420a385af45da Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Wed, 30 Oct 2019 10:26:10 +0900
Subject: [PATCH] ASoC: soc-core: remove unneeded
 snd_soc_tplg_component_remove()

snd_soc_tplg_component_remove() is pair of snd_soc_tplg_component_load(),
and it is topology related cleanup function.

The driver which called _load() needs to call _remove() by its responsibility.
Today, skl-pcm and topology are the user, and these are calling both
_load() and _remove().

soc-core doesn't need to call it.
This patch remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8736fbdnwt.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f1b41b0391ed..b07ecfac39d7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2890,8 +2890,6 @@ static int __snd_soc_unregister_component(struct device *dev)
 		if (dev != component->dev)
 			continue;
 
-		snd_soc_tplg_component_remove(component,
-					      SND_SOC_TPLG_INDEX_ALL);
 		snd_soc_component_del_unlocked(component);
 		found = 1;
 		break;
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4
  2019-10-30 11:34 ` [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Mark Brown
@ 2019-10-31  0:46   ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-10-31  0:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark
Cc: Pierre-Louis

> > These are resend of soc-core cleanup step4.
> > These are based on mark/for-5.5 branch.
> > I already got report from Intel that these had no issue on Intel CI machine.
> 
> OK, that's not very visible :(  I'd been waiting for the review from
> them that you said was needed.

I think it is [05/18] this time.

As I told before, the topology might get damage if this patch was wrong.
But, Intel CI works correctly, thus, it has no issue, I guess.

Reviewing from Intel is for double check purpose.
I have updated easier to read its log.
So I guess reviewing became more easier (?).

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link()
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link() Kuninori Morimoto
@ 2019-11-05  2:02   ` Pierre-Louis Bossart
  2019-11-05  4:09     ` Kuninori Morimoto
  0 siblings, 1 reply; 36+ messages in thread
From: Pierre-Louis Bossart @ 2019-11-05  2:02 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA


> +
> +	/*
> +	 * Defer card registartion if cpu dai component is not added to

typo: registration.

This was in the original code but we might as well make the code cleaner...

> +	 * component list.
> +	 */
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component()
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component() Kuninori Morimoto
@ 2019-11-05  2:22   ` Pierre-Louis Bossart
  2019-11-05  4:10     ` Kuninori Morimoto
  0 siblings, 1 reply; 36+ messages in thread
From: Pierre-Louis Bossart @ 2019-11-05  2:22 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA


> +struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
> +						   const char *driver_name)
> +{
> +	struct snd_soc_component *component;
> +	struct snd_soc_component *ret;
> +
> +	ret = NULL;
> +	mutex_lock(&client_mutex);
> +	for_each_component(component) {
> +		if (dev != component->dev)
> +			continue;
> +
> +		if (driver_name &&
> +		    (driver_name != component->driver->name) &&
> +		    (strcmp(component->driver->name, driver_name) != 0))
> +			continue;
> +
> +		ret = component;
> +		break;

The mix of continue and break in the same loop is odd.

can this be done with break only, e.g. (check the logic)

for_each_component(component) {
	if (dev == component->dev &&
	   (!driver_name ||
	    (driver_name == component->driver->name) ||
	    (strcmp(component->driver->name, driver_name) == 0))
		ret = component;
		break;
}

> +	mutex_unlock(&client_mutex);
> +
> +	return ret;

usually 'return ret' is for an error code. It's odd to use it for a pointer.

> +}
> +EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
> +
>   struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
>   		const char *dai_link, int stream)
>   {
> @@ -2889,32 +2915,6 @@ void snd_soc_unregister_component(struct device *dev)
>   }
>   EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
>   
> -struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
> -						   const char *driver_name)
> -{
> -	struct snd_soc_component *component;
> -	struct snd_soc_component *ret;
> -
> -	ret = NULL;
> -	mutex_lock(&client_mutex);
> -	for_each_component(component) {
> -		if (dev != component->dev)
> -			continue;
> -
> -		if (driver_name &&
> -		    (driver_name != component->driver->name) &&
> -		    (strcmp(component->driver->name, driver_name) != 0))
> -			continue;
> -
> -		ret = component;
> -		break;
> -	}
> -	mutex_unlock(&client_mutex);
> -
> -	return ret;
> -}
> -EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
> -
>   /* Retrieve a card's name from device tree */
>   int snd_soc_of_parse_card_name(struct snd_soc_card *card,
>   			       const char *propname)
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4
  2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
                   ` (18 preceding siblings ...)
  2019-10-30 11:34 ` [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Mark Brown
@ 2019-11-05  2:38 ` Pierre-Louis Bossart
  2019-11-05  4:08   ` Kuninori Morimoto
  19 siblings, 1 reply; 36+ messages in thread
From: Pierre-Louis Bossart @ 2019-11-05  2:38 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA, Ranjani Sridharan, Kai Vehmanen



On 10/29/19 8:23 PM, Kuninori Morimoto wrote:
> 
> Hi Mark
> 
> These are resend of soc-core cleanup step4.
> These are based on mark/for-5.5 branch.
> I already got report from Intel that these had no issue on Intel CI machine.

In addition to the first pass of automatic testing on SOF-enabled 
devices, I double-checked the v2 code once more and didn't see any 
issues with the changes. Copying Ranjani and Kai in case they have spare 
cycles to have additional eyes on this large change.

The comments I have are on existing code that was moved, and the 
improvements could be handled as a follow-up patch. So for the series

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Thanks Morimoto-san, this is a major clean-up. Nice work!

> 
> Kuninori Morimoto (18):
>    ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()
>    ASoC: soc-core: move soc_init_dai_link()
>    ASoC: soc-core: tidyup soc_init_dai_link()
>    ASoC: soc-core: remove duplicated soc_is_dai_link_bound()
>    ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link()
>    ASoC: soc-core: add soc_unbind_dai_link()
>    ASoC: soc-core: move snd_soc_lookup_component()
>    ASoC: soc-core: add snd_soc_del_component_unlocked()
>    ASoC: soc-core: remove snd_soc_component_add/del()
>    ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()
>    ASoC: soc-core: move snd_soc_register_dai()
>    ASoC: soc-core: move snd_soc_unregister_dais()
>    ASoC: soc-core: add snd_soc_unregister_dai()
>    ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai()
>    ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()
>    ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais()
>    ASoC: soc-core: remove topology specific operation
>    ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY
> 
>   include/sound/soc.h      |  15 +-
>   sound/soc/soc-core.c     | 536 +++++++++++++++++++++--------------------------
>   sound/soc/soc-topology.c |  17 +-
>   3 files changed, 263 insertions(+), 305 deletions(-)
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Kuninori Morimoto
  2019-10-30 12:57   ` [alsa-devel] Applied "ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()" to the asoc tree Mark Brown
@ 2019-11-05  2:55   ` Sridharan, Ranjani
  2019-11-05  4:02     ` Kuninori Morimoto
  1 sibling, 1 reply; 36+ messages in thread
From: Sridharan, Ranjani @ 2019-11-05  2:55 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

On Tue, Oct 29, 2019 at 6:28 PM Kuninori Morimoto <
kuninori.morimoto.gx@renesas.com> wrote:

> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> snd_soc_tplg_component_remove() is pair of snd_soc_tplg_component_load(),
> and it is topology related cleanup function.
>
> The driver which called _load() needs to call _remove() by its
> responsibility.
> Today, skl-pcm and topology are the user, and these are calling both
> _load() and _remove().
>
> soc-core doesn't need to call it.
> This patch remove it.
>
Morimoto-san,

When I submitted changes for fixing module load/unload errors with SOF, I
had a patch that added this change. At that time, Mark commented that this
can be left as is to make the unregister_component() robust.

Mark, do you still think it should be left as is or are you OK to remove
this?

Thanks,
Ranjani

>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  sound/soc/soc-core.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index f1b41b0..b07ecfa 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2890,8 +2890,6 @@ static int __snd_soc_unregister_component(struct
> device *dev)
>                 if (dev != component->dev)
>                         continue;
>
> -               snd_soc_tplg_component_remove(component,
> -                                             SND_SOC_TPLG_INDEX_ALL);
>                 snd_soc_component_del_unlocked(component);
>                 found = 1;
>                 break;
> --
> 2.7.4
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link()
  2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link() Kuninori Morimoto
@ 2019-11-05  3:02   ` Ranjani Sridharan
  2019-11-05  4:19     ` Kuninori Morimoto
  0 siblings, 1 reply; 36+ messages in thread
From: Ranjani Sridharan @ 2019-11-05  3:02 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Wed, 2019-10-30 at 10:26 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> soc_init_dai_link() is needed to be called before
> soc_bind_dai_link().
> 
> 	int snd_soc_instantiate_card()
> 	{
> 		for_each_card_prelinks(...) {
> (1)			ret = soc_init_dai_link(...);
> 			...
> 		}
> 		...
> 		for_each_card_prelinks(...) {
> (2)			ret = soc_bind_dai_link(...);
> 			...
> 		}
> 		...
> 		for_each_card_links(...) {
> 			...
> (A)			ret = soc_init_dai_link(...);
> 			...
> (B)			ret = soc_bind_dai_link(...);
> 		}
> 		...
> 
> (1) is for (2), and (A) is for (B)
> (1) and (2) are for card prelink   dai_link.
> (A) and (B) are for topology added dai_link.
> 
> soc_init_dai_link() is sanity check for dai_link, not initializing
> today.
> Therefore, it is confusable naming. We can rename it as sanity_check.
> 
> And this check is for soc_bind_dai_link().
> It can be more simple code if we can call it from
> soc_bind_dai_link().
> 
> This patch renames it to soc_dai_link_sanity_check(), and
> call it from soc_bind_dai_link().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  sound/soc/soc-core.c | 22 +++++++---------------
>  1 file changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index a141828..94763fc9c 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -941,8 +941,8 @@ static bool soc_is_dai_link_bound(struct
> snd_soc_card *card,
>  	return false;
>  }
>  
> -static int soc_init_dai_link(struct snd_soc_card *card,
> -			     struct snd_soc_dai_link *link)
> +static int soc_dai_link_sanity_check(struct snd_soc_card *card,
> +				     struct snd_soc_dai_link *link)
>  {
>  	int i;
>  	struct snd_soc_dai_link_component *codec, *platform;
> @@ -1043,11 +1043,15 @@ static int soc_bind_dai_link(struct
> snd_soc_card *card,
>  	struct snd_soc_pcm_runtime *rtd;
>  	struct snd_soc_dai_link_component *codec, *platform;
>  	struct snd_soc_component *component;
> -	int i;
> +	int i, ret;
>  
>  	if (dai_link->ignore)
>  		return 0;
>  
> +	ret = soc_dai_link_sanity_check(card, dai_link);
> +	if (ret < 0)
> +		return ret;
Morimoto-san,

Should this be done after checking if soc_is_dai_link_bound() maybe?

Thanks,
Ranjani
> +
>  	dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
>  
>  	if (soc_is_dai_link_bound(card, dai_link)) {
> @@ -1985,15 +1989,6 @@ static int snd_soc_instantiate_card(struct
> snd_soc_card *card)
>  	int ret, i;
>  
>  	mutex_lock(&client_mutex);
> -	for_each_card_prelinks(card, i, dai_link) {
> -		ret = soc_init_dai_link(card, dai_link);
> -		if (ret) {
> -			dev_err(card->dev, "ASoC: failed to init link
> %s: %d\n",
> -				dai_link->name, ret);
> -			mutex_unlock(&client_mutex);
> -			return ret;
> -		}
> -	}
>  	mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
>  
>  	snd_soc_dapm_init(&card->dapm, card, NULL);
> @@ -2073,9 +2068,6 @@ static int snd_soc_instantiate_card(struct
> snd_soc_card *card)
>  		if (soc_is_dai_link_bound(card, dai_link))
>  			continue;
>  
> -		ret = soc_init_dai_link(card, dai_link);
> -		if (ret)
> -			goto probe_end;
>  		ret = soc_bind_dai_link(card, dai_link);
>  		if (ret)
>  			goto probe_end;

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()
  2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() " Kuninori Morimoto
@ 2019-11-05  3:20   ` Ranjani Sridharan
  2019-11-05  4:20     ` Kuninori Morimoto
  0 siblings, 1 reply; 36+ messages in thread
From: Ranjani Sridharan @ 2019-11-05  3:20 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Wed, 2019-10-30 at 10:27 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> ALSA SoC has 2 functions.
> snd_soc_register_dai()  is used from topology
> snd_soc_register_dais() is used from snd_soc_add_component()
> 
> In general, people think like _dai() is called from _dais()
> with for loop. But in reality, these are very similar
> but different implementation.
> We shouldn't have duplicated and confusing implementation.
> 
> snd_soc_register_dai() is now used from topology.
> But to reduce duplicated code, it should be used from _dais(), too.
> 
> Because of topology side specific reason,
> it is calling snd_soc_dapm_new_dai_widgets(),
> but it is not needed _dais() side.
> 
> This patch factorizes snd_soc_register_dai() to
> topology / _dais() common part, and topology specific part.
> And do topology specific part at soc-topology.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc.h      |  6 +++---
>  sound/soc/soc-core.c     | 25 ++++++-------------------
>  sound/soc/soc-topology.c | 17 ++++++++++++++++-
>  3 files changed, 25 insertions(+), 23 deletions(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 766fa81..4e38ee6 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -1326,9 +1326,9 @@ struct snd_soc_dai_link
> *snd_soc_find_dai_link(struct snd_soc_card *card,
>  					       int id, const char
> *name,
>  					       const char
> *stream_name);
>  
> -int snd_soc_register_dai(struct snd_soc_component *component,
> -			 struct snd_soc_dai_driver *dai_drv,
> -			 bool legacy_dai_naming);
> +struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component
> *component,
> +					 struct snd_soc_dai_driver
> *dai_drv,
> +					 bool legacy_dai_naming);
>  void snd_soc_unregister_dai(struct snd_soc_dai *dai);
>  
>  struct snd_soc_dai *snd_soc_find_dai(
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 7bd38fb..8045f4f 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2606,37 +2606,24 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
>   * These DAIs's widgets will be freed in the card cleanup and the
> DAIs
>   * will be freed in the component cleanup.
>   */
> -int snd_soc_register_dai(struct snd_soc_component *component,
> -			 struct snd_soc_dai_driver *dai_drv,
> -			 bool legacy_dai_naming)
> +struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component
> *component,
> +					 struct snd_soc_dai_driver
> *dai_drv,
> +					 bool legacy_dai_naming)
>  {
> -	struct snd_soc_dapm_context *dapm =
> -		snd_soc_component_get_dapm(component);
>  	struct snd_soc_dai *dai;
> -	int ret;
>  
>  	if (dai_drv->dobj.type != SND_SOC_DOBJ_PCM) {
>  		dev_err(component->dev, "Invalid dai type %d\n",
>  			dai_drv->dobj.type);
> -		return -EINVAL;
> +		return NULL;
>  	}
>  
>  	lockdep_assert_held(&client_mutex);
>  	dai = soc_add_dai(component, dai_drv, legacy_dai_naming);
Maybe you could just say "return soc_add_dai(component, dai_drv,
legacy_dai_naming);" here?
>  	if (!dai)
> -		return -ENOMEM;
> -
> -	/*
> -	 * Create the DAI widgets here. After adding DAIs, topology may
> -	 * also add routes that need these widgets as source or sink.
> -	 */
> -	ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
> -	if (ret != 0) {
> -		dev_err(component->dev,
> -			"Failed to create DAI widgets %d\n", ret);
> -	}
> +		return NULL;
>  
> -	return ret;
> +	return dai;
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_register_dai);
>  
> diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
> index b6e1456..81d2af0 100644
> --- a/sound/soc/soc-topology.c
> +++ b/sound/soc/soc-topology.c
> @@ -1800,6 +1800,9 @@ static int soc_tplg_dai_create(struct soc_tplg
> *tplg,
>  	struct snd_soc_dai_driver *dai_drv;
>  	struct snd_soc_pcm_stream *stream;
>  	struct snd_soc_tplg_stream_caps *caps;
> +	struct snd_soc_dai *dai;
> +	struct snd_soc_dapm_context *dapm =
> +		snd_soc_component_get_dapm(tplg->comp);
>  	int ret;
>  
>  	dai_drv = kzalloc(sizeof(struct snd_soc_dai_driver),
> GFP_KERNEL);
> @@ -1842,7 +1845,19 @@ static int soc_tplg_dai_create(struct soc_tplg
> *tplg,
>  	list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);
>  
>  	/* register the DAI to the component */
> -	return snd_soc_register_dai(tplg->comp, dai_drv, false);
> +	dai = snd_soc_register_dai(tplg->comp, dai_drv, false);
> +	if (!dai)
> +		return -ENOMEM;
> +
> +	/* Create the DAI widgets here */
> +	ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
> +	if (ret != 0) {
> +		dev_err(dai->dev, "Failed to create DAI widgets %d\n",
> ret);
> +		snd_soc_unregister_dai(dai);
> +		return ret;
> +	}
> +
> +	return ret;
>  }
>  
>  static void set_link_flags(struct snd_soc_dai_link *link,

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()
  2019-11-05  2:55   ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Sridharan, Ranjani
@ 2019-11-05  4:02     ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  4:02 UTC (permalink / raw)
  To: Sridharan, Ranjani; +Cc: Linux-ALSA, Mark Brown


Hi Sridharan

Thank you for your feedback

>     From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>    
>     snd_soc_tplg_component_remove() is pair of snd_soc_tplg_component_load(),
>     and it is topology related cleanup function.
>    
>     The driver which called _load() needs to call _remove() by its responsibility.
>     Today, skl-pcm and topology are the user, and these are calling both
>     _load() and _remove().
>    
>     soc-core doesn't need to call it.
>     This patch remove it.
(snip)
> When I submitted changes for fixing module load/unload errors with SOF, I had a patch that added this change. At that time,
> Mark commented that this can be left as is to make the unregister_component() robust.
> 
> Mark, do you still think it should be left as is or are you OK to remove this?

This is already accepted by

	e9904ed5e73af4fd00cf4fcf705420a385af45da
	("ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()")

But, I'm OK to keep/reborn it as "robust".
Then, I want to have comment, like below.
Otherwise, it is confusable for non-topology user.

	/* For framework level robustness */
	snd_soc_tplg_component_remove(...)


Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4
  2019-11-05  2:38 ` Pierre-Louis Bossart
@ 2019-11-05  4:08   ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  4:08 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Linux-ALSA, Mark Brown, Ranjani Sridharan, Kai Vehmanen


Hi Pierre-Louis
Cc Mark

> > These are resend of soc-core cleanup step4.
> > These are based on mark/for-5.5 branch.
> > I already got report from Intel that these had no issue on Intel CI machine.
> 
> In addition to the first pass of automatic testing on SOF-enabled
> devices, I double-checked the v2 code once more and didn't see any
> issues with the changes. Copying Ranjani and Kai in case they have
> spare cycles to have additional eyes on this large change.
> 
> The comments I have are on existing code that was moved, and the
> improvements could be handled as a follow-up patch. So for the series
> 
> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> 
> Thanks Morimoto-san, this is a major clean-up. Nice work!

Great thanks for reviewing, Pierre-Louis.

Indeed, your pointed code should be cleaned.
As you said, I will post follow-up patch
if Mark accepted these patch-set.

Again, thank you for your reviewing !!

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link()
  2019-11-05  2:02   ` Pierre-Louis Bossart
@ 2019-11-05  4:09     ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  4:09 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: Linux-ALSA, Mark Brown


Hi Pierre-Louis

> > +
> > +	/*
> > +	 * Defer card registartion if cpu dai component is not added to
> 
> typo: registration.
> 
> This was in the original code but we might as well make the code cleaner...

Indeed :)
I will post follow-up fixup patch

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component()
  2019-11-05  2:22   ` Pierre-Louis Bossart
@ 2019-11-05  4:10     ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  4:10 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: Linux-ALSA, Mark Brown


Hi Pierre-Louis

> > +struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
> > +						   const char *driver_name)
> > +{
> > +	struct snd_soc_component *component;
> > +	struct snd_soc_component *ret;
> > +
> > +	ret = NULL;
> > +	mutex_lock(&client_mutex);
> > +	for_each_component(component) {
> > +		if (dev != component->dev)
> > +			continue;
> > +
> > +		if (driver_name &&
> > +		    (driver_name != component->driver->name) &&
> > +		    (strcmp(component->driver->name, driver_name) != 0))
> > +			continue;
> > +
> > +		ret = component;
> > +		break;
> 
> The mix of continue and break in the same loop is odd.
> 
> can this be done with break only, e.g. (check the logic)
> 
> for_each_component(component) {
> 	if (dev == component->dev &&
> 	   (!driver_name ||
> 	    (driver_name == component->driver->name) ||
> 	    (strcmp(component->driver->name, driver_name) == 0))
> 		ret = component;
> 		break;
> }

Indeed !!
Will post follow-up patch

> > +	mutex_unlock(&client_mutex);
> > +
> > +	return ret;
> 
> usually 'return ret' is for an error code. It's odd to use it for a pointer.

Will fix.

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link()
  2019-11-05  3:02   ` Ranjani Sridharan
@ 2019-11-05  4:19     ` Kuninori Morimoto
  2019-11-05  5:22       ` Sridharan, Ranjani
  0 siblings, 1 reply; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  4:19 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani

Thank you for your review.

> > +static int soc_dai_link_sanity_check(struct snd_soc_card *card,
> > +				     struct snd_soc_dai_link *link)
> >  {
> >  	int i;
> >  	struct snd_soc_dai_link_component *codec, *platform;
> > @@ -1043,11 +1043,15 @@ static int soc_bind_dai_link(struct
> > snd_soc_card *card,
> >  	struct snd_soc_pcm_runtime *rtd;
> >  	struct snd_soc_dai_link_component *codec, *platform;
> >  	struct snd_soc_component *component;
> > -	int i;
> > +	int i, ret;
> >  
> >  	if (dai_link->ignore)
> >  		return 0;
> >  
> > +	ret = soc_dai_link_sanity_check(card, dai_link);
> > +	if (ret < 0)
> > +		return ret;
> Morimoto-san,
> 
> Should this be done after checking if soc_is_dai_link_bound() maybe?

Hmm... maybe
Thanks. I will fixit in v3

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()
  2019-11-05  3:20   ` Ranjani Sridharan
@ 2019-11-05  4:20     ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  4:20 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani

Thank you for your review

> > +struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component
> > *component,
> > +					 struct snd_soc_dai_driver
> > *dai_drv,
> > +					 bool legacy_dai_naming)
(snip)
> >  	lockdep_assert_held(&client_mutex);
> >  	dai = soc_add_dai(component, dai_drv, legacy_dai_naming);
> >  	if (!dai)
> > -		return -ENOMEM;
> > -
> > -	/*
> > -	 * Create the DAI widgets here. After adding DAIs, topology may
> > -	 * also add routes that need these widgets as source or sink.
> > -	 */
> > -	ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
> > -	if (ret != 0) {
> > -		dev_err(component->dev,
> > -			"Failed to create DAI widgets %d\n", ret);
> > -	}
> > +		return NULL;
> >  
> > -	return ret;
> > +	return dai;
(snip)
> Maybe you could just say "return soc_add_dai(component, dai_drv,
> legacy_dai_naming);" here?

Yeah indeed :)
Thank you for pointing it.
Will fix in v3

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link()
  2019-11-05  4:19     ` Kuninori Morimoto
@ 2019-11-05  5:22       ` Sridharan, Ranjani
  2019-11-05  5:35         ` Kuninori Morimoto
  0 siblings, 1 reply; 36+ messages in thread
From: Sridharan, Ranjani @ 2019-11-05  5:22 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown, Ranjani Sridharan

On Mon, Nov 4, 2019 at 8:21 PM Kuninori Morimoto <
kuninori.morimoto.gx@renesas.com> wrote:

>
> Hi Ranjani
>
> Thank you for your review.
>
> > > +static int soc_dai_link_sanity_check(struct snd_soc_card *card,
> > > +                                struct snd_soc_dai_link *link)
> > >  {
> > >     int i;
> > >     struct snd_soc_dai_link_component *codec, *platform;
> > > @@ -1043,11 +1043,15 @@ static int soc_bind_dai_link(struct
> > > snd_soc_card *card,
> > >     struct snd_soc_pcm_runtime *rtd;
> > >     struct snd_soc_dai_link_component *codec, *platform;
> > >     struct snd_soc_component *component;
> > > -   int i;
> > > +   int i, ret;
> > >
> > >     if (dai_link->ignore)
> > >             return 0;
> > >
> > > +   ret = soc_dai_link_sanity_check(card, dai_link);
> > > +   if (ret < 0)
> > > +           return ret;
> > Morimoto-san,
> >
> > Should this be done after checking if soc_is_dai_link_bound() maybe?
>
Morimoto-san,

I thought about this a bit more. With you changes in the series to move
bind_dai_link() to snd_soc_add_dai(), is the check
for soc_is_dai_link_bound() needed at all?

Thanks,
Ranjani

>
> Hmm... maybe
> Thanks. I will fixit in v3
>
> Thank you for your help !!
> Best regards
> ---
> Kuninori Morimoto
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link()
  2019-11-05  5:22       ` Sridharan, Ranjani
@ 2019-11-05  5:35         ` Kuninori Morimoto
  0 siblings, 0 replies; 36+ messages in thread
From: Kuninori Morimoto @ 2019-11-05  5:35 UTC (permalink / raw)
  To: Sridharan, Ranjani; +Cc: Linux-ALSA, Mark Brown, Ranjani Sridharan


Hi Sridharan

Thank you for your review

>     > > +static int soc_dai_link_sanity_check(struct snd_soc_card *card,
>     > > +                                struct snd_soc_dai_link *link)
>     > >  {
>     > >     int i;
>     > >     struct snd_soc_dai_link_component *codec, *platform;
>     > > @@ -1043,11 +1043,15 @@ static int soc_bind_dai_link(struct
>     > > snd_soc_card *card,
>     > >     struct snd_soc_pcm_runtime *rtd;
>     > >     struct snd_soc_dai_link_component *codec, *platform;
>     > >     struct snd_soc_component *component;
>     > > -   int i;
>     > > +   int i, ret;
>     > > 
>     > >     if (dai_link->ignore)
>     > >             return 0;
>     > > 
>     > > +   ret = soc_dai_link_sanity_check(card, dai_link);
>     > > +   if (ret < 0)
>     > > +           return ret;
>     > Morimoto-san,
>     >
>     > Should this be done after checking if soc_is_dai_link_bound() maybe?
> 
> Morimoto-san,
> 
> I thought about this a bit more. With you changes in the series to move bind_dai_link() to snd_soc_add_dai(), is the check
> for soc_is_dai_link_bound() needed at all?

soc_is_dai_link_bound() is no longer needed.
It will be removed in my *next* patch-set.
Is this clear answer for you ?

Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2019-11-05  5:36 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30  1:23 [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Kuninori Morimoto
2019-10-30 12:57   ` [alsa-devel] Applied "ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()" to the asoc tree Mark Brown
2019-11-05  2:55   ` [alsa-devel] [PATCH v2 resend 01/18] ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove() Sridharan, Ranjani
2019-11-05  4:02     ` Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 02/18] ASoC: soc-core: move soc_init_dai_link() Kuninori Morimoto
2019-11-05  2:02   ` Pierre-Louis Bossart
2019-11-05  4:09     ` Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 03/18] ASoC: soc-core: tidyup soc_init_dai_link() Kuninori Morimoto
2019-11-05  3:02   ` Ranjani Sridharan
2019-11-05  4:19     ` Kuninori Morimoto
2019-11-05  5:22       ` Sridharan, Ranjani
2019-11-05  5:35         ` Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 04/18] ASoC: soc-core: remove duplicated soc_is_dai_link_bound() Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 05/18] ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link() Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 06/18] ASoC: soc-core: add soc_unbind_dai_link() Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 07/18] ASoC: soc-core: move snd_soc_lookup_component() Kuninori Morimoto
2019-11-05  2:22   ` Pierre-Louis Bossart
2019-11-05  4:10     ` Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 08/18] ASoC: soc-core: add snd_soc_del_component_unlocked() Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 09/18] ASoC: soc-core: remove snd_soc_component_add/del() Kuninori Morimoto
2019-10-30  1:26 ` [alsa-devel] [PATCH v2 resend 10/18] ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component() Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 11/18] ASoC: soc-core: move snd_soc_register_dai() Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 12/18] ASoC: soc-core: move snd_soc_unregister_dais() Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 13/18] ASoC: soc-core: add snd_soc_unregister_dai() Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 14/18] ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai() Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 15/18] ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() " Kuninori Morimoto
2019-11-05  3:20   ` Ranjani Sridharan
2019-11-05  4:20     ` Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 16/18] ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais() Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 17/18] ASoC: soc-core: remove topology specific operation Kuninori Morimoto
2019-10-30  1:27 ` [alsa-devel] [PATCH v2 resend 18/18] ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY Kuninori Morimoto
2019-10-30 11:34 ` [alsa-devel] [PATCH v2 resend 00/18] ASoC: soc-core cleanup - step 4 Mark Brown
2019-10-31  0:46   ` Kuninori Morimoto
2019-11-05  2:38 ` Pierre-Louis Bossart
2019-11-05  4:08   ` Kuninori Morimoto

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).