All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/9] add snd_soc_{of_}get_dlc()
@ 2023-06-20  0:03 Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 1/9] ASoC: soc-core.c: " Kuninori Morimoto
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:03 UTC (permalink / raw)
  To: Banajit Goswami, Jaroslav Kysela, Jerome Brunet, Kevin Hilman,
	Liam Girdwood, Mark Brown, Matthias Brugger, Neil Armstrong,
	Sascha Hauer, Shawn Guo, Shengjiu Wang, Srinivas Kandagatla,
	Stephan Gerhold, Sylwester Nawrocki, Takashi Iwai, Xiubo Li,
	Yingkun Meng
  Cc: AngeloGioacchino Del Regno, Fabio Estevam, Martin Blumenstingl,
	Nicolin Chen, Shengjiu Wang, alsa-devel


Hi Mark

Current soc-core.c has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component). It gets .dai_name, but we need
.of_node too. Therefor user need to arrange.

It will be more useful if it gets both .dai_name and .of_node.
This patch adds snd_soc_{of_}get_dlc() for it, and convert to use it.

v1 -> v2

	- care loongson

Link: https://lore.kernel.org/r/87mt12hp75.wl-kuninori.morimoto.gx@renesas.com

Kuninori Morimoto (9):
  ASoC: soc-core.c: add snd_soc_{of_}get_dlc()
  ASoC: soc-core.c: add index on snd_soc_of_get_dai_name()
  ASoC: fsl: use snd_soc_{of_}get_dlc()
  ASoC: qcom: use snd_soc_{of_}get_dlc()
  ASoC: meson: use snd_soc_{of_}get_dlc()
  ASoC: samsung: use snd_soc_{of_}get_dlc()
  ASoC: loongson: use snd_soc_{of_}get_dlc()
  ASoC: soc-core.c: use snd_soc_{of_}get_dlc()
  ASoC: simple-card.c: use snd_soc_{of_}get_dlc()

 include/sound/soc.h                       |  8 ++-
 sound/soc/fsl/imx-card.c                  | 14 +----
 sound/soc/fsl/imx-rpmsg.c                 |  3 +-
 sound/soc/generic/simple-card-utils.c     |  4 +-
 sound/soc/generic/simple-card.c           |  4 +-
 sound/soc/loongson/loongson_card.c        | 34 ++++------
 sound/soc/mediatek/mt8173/mt8173-rt5650.c |  2 +-
 sound/soc/meson/axg-card.c                |  3 +-
 sound/soc/meson/gx-card.c                 |  3 +-
 sound/soc/meson/meson-card-utils.c        | 16 ++---
 sound/soc/meson/meson-card.h              |  3 +-
 sound/soc/qcom/common.c                   | 13 +---
 sound/soc/samsung/odroid.c                | 16 +----
 sound/soc/soc-core.c                      | 77 ++++++++++++-----------
 14 files changed, 79 insertions(+), 121 deletions(-)

-- 
2.25.1


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

* [PATCH v2 1/9] ASoC: soc-core.c: add snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
@ 2023-06-20  0:04 ` Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 2/9] ASoC: soc-core.c: add index on snd_soc_of_get_dai_name() Kuninori Morimoto
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:04 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Takashi Iwai; +Cc: alsa-devel

Current soc-core.c has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component). It gets .dai_name, but we need
.of_node too. Therefor user need to arrange.

It will be more useful if it gets both .dai_name and .of_node.
This patch adds snd_soc_{of_}get_dlc() for it, and existing functions
uses it.

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

diff --git a/include/sound/soc.h b/include/sound/soc.h
index a7ae8b26737e..943f0a1b2d27 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1309,6 +1309,12 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
 		snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
 
 int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream);
+int snd_soc_get_dlc(const struct of_phandle_args *args,
+		    struct snd_soc_dai_link_component *dlc);
+int snd_soc_of_get_dlc(struct device_node *of_node,
+		       struct of_phandle_args *args,
+		       struct snd_soc_dai_link_component *dlc,
+		       int index);
 int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(const struct of_phandle_args *args,
 			 const char **dai_name);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e8308926bd98..8dba5bb26ffe 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3257,8 +3257,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
 }
 EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
 
-int snd_soc_get_dai_name(const struct of_phandle_args *args,
-				const char **dai_name)
+int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_component *dlc)
 {
 	struct snd_soc_component *pos;
 	int ret = -EPROBE_DEFER;
@@ -3270,7 +3269,7 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
 		if (component_of_node != args->np || !pos->num_dai)
 			continue;
 
-		ret = snd_soc_component_of_xlate_dai_name(pos, args, dai_name);
+		ret = snd_soc_component_of_xlate_dai_name(pos, args, &dlc->dai_name);
 		if (ret == -ENOTSUPP) {
 			struct snd_soc_dai *dai;
 			int id = -1;
@@ -3301,9 +3300,10 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
 				id--;
 			}
 
-			*dai_name = dai->driver->name;
-			if (!*dai_name)
-				*dai_name = pos->name;
+			dlc->of_node	= args->np;
+			dlc->dai_name	= dai->driver->name;
+			if (!dlc->dai_name)
+				dlc->dai_name = pos->name;
 		} else if (ret) {
 			/*
 			 * if another error than ENOTSUPP is returned go on and
@@ -3319,22 +3319,49 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
 	mutex_unlock(&client_mutex);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
+EXPORT_SYMBOL_GPL(snd_soc_get_dlc);
 
-int snd_soc_of_get_dai_name(struct device_node *of_node,
-			    const char **dai_name)
+int snd_soc_of_get_dlc(struct device_node *of_node,
+		       struct of_phandle_args *args,
+		       struct snd_soc_dai_link_component *dlc,
+		       int index)
 {
-	struct of_phandle_args args;
+	struct of_phandle_args __args;
 	int ret;
 
+	if (!args)
+		args = &__args;
+
 	ret = of_parse_phandle_with_args(of_node, "sound-dai",
-					 "#sound-dai-cells", 0, &args);
+					 "#sound-dai-cells", index, args);
 	if (ret)
 		return ret;
 
-	ret = snd_soc_get_dai_name(&args, dai_name);
+	return snd_soc_get_dlc(args, dlc);
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_get_dlc);
+
+int snd_soc_get_dai_name(const struct of_phandle_args *args,
+			 const char **dai_name)
+{
+	struct snd_soc_dai_link_component dlc;
+	int ret = snd_soc_get_dlc(args, &dlc);
 
-	of_node_put(args.np);
+	if (ret == 0)
+		*dai_name = dlc.dai_name;
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
+
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+			    const char **dai_name)
+{
+	struct snd_soc_dai_link_component dlc;
+	int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, 0);
+
+	if (ret == 0)
+		*dai_name = dlc.dai_name;
 
 	return ret;
 }
-- 
2.25.1


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

* [PATCH v2 2/9] ASoC: soc-core.c: add index on snd_soc_of_get_dai_name()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 1/9] ASoC: soc-core.c: " Kuninori Morimoto
@ 2023-06-20  0:04 ` Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 3/9] ASoC: fsl: use snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:04 UTC (permalink / raw)
  To: Banajit Goswami, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Matthias Brugger, Sascha Hauer, Shawn Guo, Shengjiu Wang,
	Srinivas Kandagatla, Stephan Gerhold, Takashi Iwai, Xiubo Li
  Cc: AngeloGioacchino Del Regno, Fabio Estevam, Nicolin Chen,
	Shengjiu Wang, alsa-devel

Current snd_soc_of_get_dai_name() doesn't accept index
for #sound-dai-cells. It is not useful for user.
This patch adds it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h                       | 2 +-
 sound/soc/fsl/imx-card.c                  | 2 +-
 sound/soc/generic/simple-card.c           | 2 +-
 sound/soc/mediatek/mt8173/mt8173-rt5650.c | 2 +-
 sound/soc/qcom/common.c                   | 2 +-
 sound/soc/soc-core.c                      | 4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 943f0a1b2d27..b27f84580c5b 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1319,7 +1319,7 @@ int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(const struct of_phandle_args *args,
 			 const char **dai_name);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
-			    const char **dai_name);
+			    const char **dai_name, int index);
 int snd_soc_of_get_dai_link_codecs(struct device *dev,
 				   struct device_node *of_node,
 				   struct snd_soc_dai_link *dai_link);
diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index 78e2e3932ba5..6f3b1428a5ba 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -586,7 +586,7 @@ static int imx_card_parse_of(struct imx_card_data *data)
 		link->platforms->of_node = link->cpus->of_node;
 		link->id = args.args[0];
 
-		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
+		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, 0);
 		if (ret) {
 			dev_err_probe(card->dev, ret,
 				      "%s: error getting cpu dai name\n", link->name);
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 5a5e4ecd0f61..5b59198a0384 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -89,7 +89,7 @@ static int asoc_simple_parse_dai(struct device_node *node,
 	 * 2) user need to rebind Sound Card everytime
 	 *    if he unbinded CPU or Codec.
 	 */
-	ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
+	ret = snd_soc_of_get_dai_name(node, &dlc->dai_name, 0);
 	if (ret < 0)
 		return ret;
 
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
index e05f2b0231fe..3ece4b5eaca2 100644
--- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c
+++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
@@ -288,7 +288,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
 
 	np = of_get_child_by_name(pdev->dev.of_node, "codec-capture");
 	if (np) {
-		ret = snd_soc_of_get_dai_name(np, &codec_capture_dai);
+		ret = snd_soc_of_get_dai_name(np, &codec_capture_dai, 0);
 		of_node_put(np);
 		if (ret < 0) {
 			dev_err(&pdev->dev,
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index cab5a7937a57..d9ebb883b999 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -105,7 +105,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 		link->cpus->of_node = args.np;
 		link->id = args.args[0];
 
-		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
+		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, 0);
 		if (ret) {
 			dev_err_probe(card->dev, ret,
 				      "%s: error getting cpu dai name\n", link->name);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8dba5bb26ffe..7b13b1b232ef 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3355,10 +3355,10 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
 EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
 
 int snd_soc_of_get_dai_name(struct device_node *of_node,
-			    const char **dai_name)
+			    const char **dai_name, int index)
 {
 	struct snd_soc_dai_link_component dlc;
-	int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, 0);
+	int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, index);
 
 	if (ret == 0)
 		*dai_name = dlc.dai_name;
-- 
2.25.1


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

* [PATCH v2 3/9] ASoC: fsl: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 1/9] ASoC: soc-core.c: " Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 2/9] ASoC: soc-core.c: add index on snd_soc_of_get_dai_name() Kuninori Morimoto
@ 2023-06-20  0:04 ` Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 4/9] ASoC: qcom: " Kuninori Morimoto
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:04 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Sascha Hauer,
	Shawn Guo, Shengjiu Wang, Takashi Iwai, Xiubo Li
  Cc: Fabio Estevam, Nicolin Chen, Shengjiu Wang, alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/fsl/imx-card.c  | 14 +++-----------
 sound/soc/fsl/imx-rpmsg.c |  3 +--
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index 6f3b1428a5ba..356a0bc3b126 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -551,10 +551,10 @@ static int imx_card_parse_of(struct imx_card_data *data)
 			goto err;
 		}
 
-		ret = of_parse_phandle_with_args(cpu, "sound-dai",
-						 "#sound-dai-cells", 0, &args);
+		ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
 		if (ret) {
-			dev_err(card->dev, "%s: error getting cpu phandle\n", link->name);
+			dev_err_probe(card->dev, ret,
+				      "%s: error getting cpu dai info\n", link->name);
 			goto err;
 		}
 
@@ -582,17 +582,9 @@ static int imx_card_parse_of(struct imx_card_data *data)
 			}
 		}
 
-		link->cpus->of_node = args.np;
 		link->platforms->of_node = link->cpus->of_node;
 		link->id = args.args[0];
 
-		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, 0);
-		if (ret) {
-			dev_err_probe(card->dev, ret,
-				      "%s: error getting cpu dai name\n", link->name);
-			goto err;
-		}
-
 		codec = of_get_child_by_name(np, "codec");
 		if (codec) {
 			ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 93fc976e98dc..3c7b95db2eac 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -96,8 +96,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 	} else {
 		struct clk *clk;
 
-		data->dai.codecs->of_node = args.np;
-		ret = snd_soc_get_dai_name(&args, &data->dai.codecs->dai_name);
+		ret = snd_soc_get_dlc(&args, data->dai.codecs);
 		if (ret) {
 			dev_err(&pdev->dev, "Unable to get codec_dai_name\n");
 			goto fail;
-- 
2.25.1


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

* [PATCH v2 4/9] ASoC: qcom: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2023-06-20  0:04 ` [PATCH v2 3/9] ASoC: fsl: use snd_soc_{of_}get_dlc() Kuninori Morimoto
@ 2023-06-20  0:04 ` Kuninori Morimoto
  2023-06-20  0:04 ` [PATCH v2 5/9] ASoC: meson: " Kuninori Morimoto
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:04 UTC (permalink / raw)
  To: Banajit Goswami, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Srinivas Kandagatla, Stephan Gerhold, Takashi Iwai
  Cc: alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

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

diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index d9ebb883b999..43b0a888f1e8 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -96,22 +96,15 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 			goto err;
 		}
 
-		ret = of_parse_phandle_with_args(cpu, "sound-dai",
-					"#sound-dai-cells", 0, &args);
-		if (ret) {
-			dev_err(card->dev, "%s: error getting cpu phandle\n", link->name);
-			goto err;
-		}
-		link->cpus->of_node = args.np;
-		link->id = args.args[0];
-
-		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, 0);
+		ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
 		if (ret) {
 			dev_err_probe(card->dev, ret,
 				      "%s: error getting cpu dai name\n", link->name);
 			goto err;
 		}
 
+		link->id = args.args[0];
+
 		if (platform) {
 			link->platforms->of_node = of_parse_phandle(platform,
 					"sound-dai",
-- 
2.25.1


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

* [PATCH v2 5/9] ASoC: meson: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2023-06-20  0:04 ` [PATCH v2 4/9] ASoC: qcom: " Kuninori Morimoto
@ 2023-06-20  0:04 ` Kuninori Morimoto
  2023-06-20  0:05 ` [PATCH v2 6/9] ASoC: samsung: " Kuninori Morimoto
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:04 UTC (permalink / raw)
  To: Jaroslav Kysela, Jerome Brunet, Kevin Hilman, Liam Girdwood,
	Mark Brown, Neil Armstrong, Takashi Iwai
  Cc: Martin Blumenstingl, alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/meson/axg-card.c         |  3 +--
 sound/soc/meson/gx-card.c          |  3 +--
 sound/soc/meson/meson-card-utils.c | 16 +++++-----------
 sound/soc/meson/meson-card.h       |  3 +--
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index 74e7cf0ef8d5..f10c0c17863e 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -319,8 +319,7 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
 	dai_link->cpus = cpu;
 	dai_link->num_cpus = 1;
 
-	ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node,
-				   &dai_link->cpus->dai_name);
+	ret = meson_card_parse_dai(card, np, dai_link->cpus);
 	if (ret)
 		return ret;
 
diff --git a/sound/soc/meson/gx-card.c b/sound/soc/meson/gx-card.c
index 58c411d3c489..a26b620fc177 100644
--- a/sound/soc/meson/gx-card.c
+++ b/sound/soc/meson/gx-card.c
@@ -90,8 +90,7 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
 	dai_link->cpus = cpu;
 	dai_link->num_cpus = 1;
 
-	ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node,
-				   &dai_link->cpus->dai_name);
+	ret = meson_card_parse_dai(card, np, dai_link->cpus);
 	if (ret)
 		return ret;
 
diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index ffc5111f9e3c..f7fd9c013e19 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -74,23 +74,18 @@ EXPORT_SYMBOL_GPL(meson_card_reallocate_links);
 
 int meson_card_parse_dai(struct snd_soc_card *card,
 			 struct device_node *node,
-			 struct device_node **dai_of_node,
-			 const char **dai_name)
+			 struct snd_soc_dai_link_component *dlc)
 {
-	struct of_phandle_args args;
 	int ret;
 
-	if (!dai_name || !dai_of_node || !node)
+	if (!dlc || !node)
 		return -EINVAL;
 
-	ret = of_parse_phandle_with_args(node, "sound-dai",
-					 "#sound-dai-cells", 0, &args);
+	ret = snd_soc_of_get_dlc(node, NULL, dlc, 0);
 	if (ret)
 		return dev_err_probe(card->dev, ret, "can't parse dai\n");
 
-	*dai_of_node = args.np;
-
-	return snd_soc_get_dai_name(&args, dai_name);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(meson_card_parse_dai);
 
@@ -160,8 +155,7 @@ int meson_card_set_be_link(struct snd_soc_card *card,
 	link->num_codecs = num_codecs;
 
 	for_each_child_of_node(node, np) {
-		ret = meson_card_parse_dai(card, np, &codec->of_node,
-					   &codec->dai_name);
+		ret = meson_card_parse_dai(card, np, codec);
 		if (ret) {
 			of_node_put(np);
 			return ret;
diff --git a/sound/soc/meson/meson-card.h b/sound/soc/meson/meson-card.h
index 74314071c80d..a5374324a189 100644
--- a/sound/soc/meson/meson-card.h
+++ b/sound/soc/meson/meson-card.h
@@ -39,8 +39,7 @@ int meson_card_reallocate_links(struct snd_soc_card *card,
 				unsigned int num_links);
 int meson_card_parse_dai(struct snd_soc_card *card,
 			 struct device_node *node,
-			 struct device_node **dai_of_node,
-			 const char **dai_name);
+			 struct snd_soc_dai_link_component *dlc);
 int meson_card_set_be_link(struct snd_soc_card *card,
 			   struct snd_soc_dai_link *link,
 			   struct device_node *node);
-- 
2.25.1


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

* [PATCH v2 6/9] ASoC: samsung: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2023-06-20  0:04 ` [PATCH v2 5/9] ASoC: meson: " Kuninori Morimoto
@ 2023-06-20  0:05 ` Kuninori Morimoto
  2023-06-20  0:05 ` [PATCH v2 7/9] ASoC: loongson: " Kuninori Morimoto
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:05 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Sylwester Nawrocki,
	Takashi Iwai
  Cc: alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
note: need deep check


 sound/soc/samsung/odroid.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index fd95a79cc9fa..a5442592bde4 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -205,7 +205,6 @@ static int odroid_audio_probe(struct platform_device *pdev)
 	struct snd_soc_card *card;
 	struct snd_soc_dai_link *link, *codec_link;
 	int num_pcms, ret, i;
-	struct of_phandle_args args = {};
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -260,20 +259,7 @@ static int odroid_audio_probe(struct platform_device *pdev)
 	}
 
 	for (i = 0; i < num_pcms; i++, link += 2) {
-		ret = of_parse_phandle_with_args(cpu, "sound-dai",
-						 "#sound-dai-cells", i, &args);
-		if (ret < 0)
-			break;
-
-		if (!args.np) {
-			dev_err(dev, "sound-dai property parse error: %d\n", ret);
-			ret = -EINVAL;
-			break;
-		}
-
-		ret = snd_soc_get_dai_name(&args, &link->cpus->dai_name);
-		of_node_put(args.np);
-
+		ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, i);
 		if (ret < 0)
 			break;
 	}
-- 
2.25.1


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

* [PATCH v2 7/9] ASoC: loongson: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2023-06-20  0:05 ` [PATCH v2 6/9] ASoC: samsung: " Kuninori Morimoto
@ 2023-06-20  0:05 ` Kuninori Morimoto
  2023-06-20  0:05 ` [PATCH v2 8/9] ASoC: soc-core.c: " Kuninori Morimoto
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:05 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Takashi Iwai, Yingkun Meng
  Cc: alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

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

diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
index 08df05cb4328..9ded16329747 100644
--- a/sound/soc/loongson/loongson_card.c
+++ b/sound/soc/loongson/loongson_card.c
@@ -114,11 +114,9 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
 
 static int loongson_card_parse_of(struct loongson_card_data *data)
 {
-	const char *cpu_dai_name, *codec_dai_name;
 	struct device_node *cpu, *codec;
 	struct snd_soc_card *card = &data->snd_card;
 	struct device *dev = card->dev;
-	struct of_phandle_args args;
 	int ret, i;
 
 	cpu = of_get_child_by_name(dev->of_node, "cpu");
@@ -133,30 +131,20 @@ static int loongson_card_parse_of(struct loongson_card_data *data)
 		goto err;
 	}
 
-	ret = of_parse_phandle_with_args(cpu, "sound-dai",
-					 "#sound-dai-cells", 0, &args);
-	if (ret) {
-		dev_err(dev, "codec node missing #sound-dai-cells\n");
-		goto err;
-	}
-	for (i = 0; i < card->num_links; i++)
-		loongson_dai_links[i].cpus->of_node = args.np;
+	for (i = 0; i < card->num_links; i++) {
+		ret = snd_soc_of_get_dlc(cpu, NULL, loongson_dai_links[i].cpus, 0);
+		if (ret < 0) {
+			dev_err(dev, "getting cpu dlc error (%d)\n", ret);
+			goto err;
+		}
 
-	ret = of_parse_phandle_with_args(codec, "sound-dai",
-					 "#sound-dai-cells", 0, &args);
-	if (ret) {
-		dev_err(dev, "codec node missing #sound-dai-cells\n");
-		goto err;
+		ret = snd_soc_of_get_dlc(codec, NULL, loongson_dai_links[i].codecs, 0);
+		if (ret < 0) {
+			dev_err(dev, "getting codec dlc error (%d)\n", ret);
+			goto err;
+		}
 	}
-	for (i = 0; i < card->num_links; i++)
-		loongson_dai_links[i].codecs->of_node = args.np;
 
-	snd_soc_of_get_dai_name(cpu, &cpu_dai_name);
-	snd_soc_of_get_dai_name(codec, &codec_dai_name);
-	for (i = 0; i < card->num_links; i++) {
-		loongson_dai_links[i].cpus->dai_name = cpu_dai_name;
-		loongson_dai_links[i].codecs->dai_name = codec_dai_name;
-	}
 	of_node_put(cpu);
 	of_node_put(codec);
 
-- 
2.25.1


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

* [PATCH v2 8/9] ASoC: soc-core.c: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2023-06-20  0:05 ` [PATCH v2 7/9] ASoC: loongson: " Kuninori Morimoto
@ 2023-06-20  0:05 ` Kuninori Morimoto
  2023-06-20  0:05 ` [PATCH v2 9/9] ASoC: simple-card.c: " Kuninori Morimoto
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:05 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Takashi Iwai; +Cc: alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

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

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7b13b1b232ef..f06a20773a34 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3402,26 +3402,6 @@ static int __snd_soc_of_get_dai_link_component_alloc(
 	return 0;
 }
 
-static int __snd_soc_of_get_dai_link_component_parse(
-	struct device_node *of_node,
-	struct snd_soc_dai_link_component *component, int index)
-{
-	struct of_phandle_args args;
-	int ret;
-
-	ret = of_parse_phandle_with_args(of_node, "sound-dai", "#sound-dai-cells",
-					 index, &args);
-	if (ret)
-		return ret;
-
-	ret = snd_soc_get_dai_name(&args, &component->dai_name);
-	if (ret < 0)
-		return ret;
-
-	component->of_node = args.np;
-	return 0;
-}
-
 /*
  * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array
  * @dai_link: DAI link
@@ -3466,7 +3446,7 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
 
 	/* Parse the list */
 	for_each_link_codecs(dai_link, index, component) {
-		ret = __snd_soc_of_get_dai_link_component_parse(of_node, component, index);
+		ret = snd_soc_of_get_dlc(of_node, NULL, component, index);
 		if (ret)
 			goto err;
 	}
@@ -3521,7 +3501,7 @@ int snd_soc_of_get_dai_link_cpus(struct device *dev,
 
 	/* Parse the list */
 	for_each_link_cpus(dai_link, index, component) {
-		ret = __snd_soc_of_get_dai_link_component_parse(of_node, component, index);
+		ret = snd_soc_of_get_dlc(of_node, NULL, component, index);
 		if (ret)
 			goto err;
 	}
-- 
2.25.1


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

* [PATCH v2 9/9] ASoC: simple-card.c: use snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2023-06-20  0:05 ` [PATCH v2 8/9] ASoC: soc-core.c: " Kuninori Morimoto
@ 2023-06-20  0:05 ` Kuninori Morimoto
  2023-06-20  1:27 ` [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
  2023-06-21  0:34 ` Mark Brown
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  0:05 UTC (permalink / raw)
  To: Jaroslav Kysela, Liam Girdwood, Mark Brown, Takashi Iwai; +Cc: alsa-devel

Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card-utils.c | 4 +---
 sound/soc/generic/simple-card.c       | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 3af056026fa2..3019626b0592 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -1103,14 +1103,12 @@ int asoc_graph_parse_dai(struct device_node *ep,
 	 * 2) user need to rebind Sound Card everytime
 	 *    if he unbinded CPU or Codec.
 	 */
-	ret = snd_soc_get_dai_name(&args, &dlc->dai_name);
+	ret = snd_soc_get_dlc(&args, dlc);
 	if (ret < 0) {
 		of_node_put(node);
 		return ret;
 	}
 
-	dlc->of_node = node;
-
 	if (is_single_link)
 		*is_single_link = of_graph_get_endpoint_count(node) == 1;
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 5b59198a0384..0745bf6a09aa 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -89,12 +89,10 @@ static int asoc_simple_parse_dai(struct device_node *node,
 	 * 2) user need to rebind Sound Card everytime
 	 *    if he unbinded CPU or Codec.
 	 */
-	ret = snd_soc_of_get_dai_name(node, &dlc->dai_name, 0);
+	ret = snd_soc_get_dlc(&args, dlc);
 	if (ret < 0)
 		return ret;
 
-	dlc->of_node = args.np;
-
 	if (is_single_link)
 		*is_single_link = !args.args_count;
 
-- 
2.25.1


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

* Re: [PATCH v2 0/9] add snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2023-06-20  0:05 ` [PATCH v2 9/9] ASoC: simple-card.c: " Kuninori Morimoto
@ 2023-06-20  1:27 ` Kuninori Morimoto
  2023-06-21  0:34 ` Mark Brown
  10 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2023-06-20  1:27 UTC (permalink / raw)
  To: Banajit Goswami, Jaroslav Kysela, Jerome Brunet, Kevin Hilman,
	Liam Girdwood, Mark Brown, Matthias Brugger, Neil Armstrong,
	Sascha Hauer, Shawn Guo, Shengjiu Wang, Srinivas Kandagatla,
	Stephan Gerhold, Sylwester Nawrocki, Takashi Iwai, Xiubo Li,
	Yingkun Meng
  Cc: AngeloGioacchino Del Regno, Fabio Estevam, Martin Blumenstingl,
	Nicolin Chen, Shengjiu Wang, alsa-devel


Hi Mark

> Current soc-core.c has snd_soc_{of_}get_dai_name() to get DAI name
> for dlc (snd_soc_dai_link_component). It gets .dai_name, but we need
> .of_node too. Therefor user need to arrange.
> 
> It will be more useful if it gets both .dai_name and .of_node.
> This patch adds snd_soc_{of_}get_dlc() for it, and convert to use it.
> 
> v1 -> v2
> 
> 	- care loongson

Grr, I added new patch for loongson, but [2/9] patch didn't care it.
It breaks git-bisect. Please drop this patch-set,
will post v3 patch.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH v2 0/9] add snd_soc_{of_}get_dlc()
  2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2023-06-20  1:27 ` [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
@ 2023-06-21  0:34 ` Mark Brown
  10 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2023-06-21  0:34 UTC (permalink / raw)
  To: Banajit Goswami, Jaroslav Kysela, Jerome Brunet, Kevin Hilman,
	Liam Girdwood, Matthias Brugger, Neil Armstrong, Sascha Hauer,
	Shawn Guo, Shengjiu Wang, Srinivas Kandagatla, Stephan Gerhold,
	Sylwester Nawrocki, Takashi Iwai, Xiubo Li, Yingkun Meng,
	Kuninori Morimoto
  Cc: AngeloGioacchino Del Regno, Fabio Estevam, Martin Blumenstingl,
	Nicolin Chen, Shengjiu Wang, alsa-devel

On Tue, 20 Jun 2023 00:03:39 +0000, Kuninori Morimoto wrote:
> Current soc-core.c has snd_soc_{of_}get_dai_name() to get DAI name
> for dlc (snd_soc_dai_link_component). It gets .dai_name, but we need
> .of_node too. Therefor user need to arrange.
> 
> It will be more useful if it gets both .dai_name and .of_node.
> This patch adds snd_soc_{of_}get_dlc() for it, and convert to use it.
> 
> [...]

Applied to

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

Thanks!

[1/9] ASoC: soc-core.c: add snd_soc_{of_}get_dlc()
      commit: 05722a0ce6fbd1c603ec0f0ecb5ed839dd561ac7
[2/9] ASoC: soc-core.c: add index on snd_soc_of_get_dai_name()
      commit: 3c8b5861850c734add65233e538d4a8c2dff95d9
[3/9] ASoC: fsl: use snd_soc_{of_}get_dlc()
      commit: aa560f5e796ce63074942251197c7161db2392d3
[4/9] ASoC: qcom: use snd_soc_{of_}get_dlc()
      commit: 6cf881b7f1608fd5625d916380ed57d45c2879e9
[5/9] ASoC: meson: use snd_soc_{of_}get_dlc()
      commit: 2e1dbea1f8a3584399ff15b1f1773dbbb1f0d10f
[6/9] ASoC: samsung: use snd_soc_{of_}get_dlc()
      commit: 50233f28f9a2c06140a7bf539ef569ba1ad58ff6
[7/9] ASoC: loongson: use snd_soc_{of_}get_dlc()
      commit: db588ea1a352df9673464b1bc6d4acb83f5e8256
[8/9] ASoC: soc-core.c: use snd_soc_{of_}get_dlc()
      commit: 14c9b25f632b561be33af99942833a618811ac3d
[9/9] ASoC: simple-card.c: use snd_soc_{of_}get_dlc()
      commit: 0baa2c3abc525c79c21ce64a1722f4034d042ac9

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


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

end of thread, other threads:[~2023-06-21  0:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20  0:03 [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
2023-06-20  0:04 ` [PATCH v2 1/9] ASoC: soc-core.c: " Kuninori Morimoto
2023-06-20  0:04 ` [PATCH v2 2/9] ASoC: soc-core.c: add index on snd_soc_of_get_dai_name() Kuninori Morimoto
2023-06-20  0:04 ` [PATCH v2 3/9] ASoC: fsl: use snd_soc_{of_}get_dlc() Kuninori Morimoto
2023-06-20  0:04 ` [PATCH v2 4/9] ASoC: qcom: " Kuninori Morimoto
2023-06-20  0:04 ` [PATCH v2 5/9] ASoC: meson: " Kuninori Morimoto
2023-06-20  0:05 ` [PATCH v2 6/9] ASoC: samsung: " Kuninori Morimoto
2023-06-20  0:05 ` [PATCH v2 7/9] ASoC: loongson: " Kuninori Morimoto
2023-06-20  0:05 ` [PATCH v2 8/9] ASoC: soc-core.c: " Kuninori Morimoto
2023-06-20  0:05 ` [PATCH v2 9/9] ASoC: simple-card.c: " Kuninori Morimoto
2023-06-20  1:27 ` [PATCH v2 0/9] add snd_soc_{of_}get_dlc() Kuninori Morimoto
2023-06-21  0:34 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.