[PATCH 0/5] ASoC: simple-card/audio-graph: cleanups
Hi Mark
These patches cleanups simple-card / audio-graph. This is part of prepare for new audio-graph-card2.
Kuninori Morimoto (5): ASoC: audio-graph: add graph_parse_node() ASoC: audio-graph: add graph_link_init() ASoC: simple-card: add simple_parse_node() ASoC: simple-card: add simple_link_init() ASoC: audio-graph: tidyup graph_dai_link_of_dpcm()
sound/soc/generic/audio-graph-card.c | 204 ++++++++++++--------------- sound/soc/generic/simple-card.c | 178 ++++++++++++----------- 2 files changed, 182 insertions(+), 200 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Parse mclk_fs/dai/tdm/clk are common for both CPU/Codec node. This patch creates graph_parse_node() for it and share the code.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/audio-graph-card.c | 108 ++++++++++++--------------- 1 file changed, 49 insertions(+), 59 deletions(-)
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 44714a12fcd8..bfaeb208db46 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -206,6 +206,47 @@ static void graph_parse_mclk_fs(struct device_node *top, of_node_put(ports); }
+static int graph_parse_node(struct asoc_simple_priv *priv, + struct device_node *ep, + struct link_info *li, + int is_cpu) +{ + struct device *dev = simple_priv_to_dev(priv); + struct device_node *top = dev->of_node; + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); + struct snd_soc_dai_link_component *dlc; + struct asoc_simple_dai *dai; + int ret, single = 0; + + if (is_cpu) { + dlc = asoc_link_to_cpu(dai_link, 0); + dai = simple_props_to_dai_cpu(dai_props, 0); + } else { + dlc = asoc_link_to_codec(dai_link, 0); + dai = simple_props_to_dai_codec(dai_props, 0); + } + + graph_parse_mclk_fs(top, ep, dai_props); + + ret = asoc_simple_parse_dai(ep, dlc, &single); + if (ret < 0) + return ret; + + ret = asoc_simple_parse_tdm(ep, dai); + if (ret < 0) + return ret; + + ret = asoc_simple_parse_clk(dev, ep, dai, dlc); + if (ret < 0) + return ret; + + if (is_cpu) + asoc_simple_canonicalize_cpu(dlc, single); + + return 0; +} + static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, @@ -219,39 +260,26 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *ep = li->cpu ? cpu_ep : codec_ep; struct device_node *port; struct device_node *ports; - struct device_node *node; - struct asoc_simple_dai *dai; struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); int ret;
port = of_get_parent(ep); ports = of_get_parent(port); - node = of_graph_get_port_parent(ep); - - li->link++;
dev_dbg(dev, "link_of DPCM (%pOF)\n", ep);
if (li->cpu) { - int is_single_links = 0; - /* Codec is dummy */
/* FE settings */ dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1;
- dai = simple_props_to_dai_cpu(dai_props, 0); - - ret = asoc_simple_parse_dai(ep, cpus, &is_single_links); + ret = graph_parse_node(priv, cpu_ep, li, 1); if (ret) goto out_put_node;
- ret = asoc_simple_parse_clk(dev, ep, dai, cpus); - if (ret < 0) - goto out_put_node; - ret = asoc_simple_set_dailink_name(dev, dai_link, "fe.%pOFP.%s", cpus->of_node, @@ -271,9 +299,6 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, */ if (card->component_chaining && !soc_component_is_pcm(cpus)) dai_link->no_pcm = 1; - - /* card->num_links includes Codec */ - asoc_simple_canonicalize_cpu(cpus, is_single_links); } else { struct snd_soc_codec_conf *cconf;
@@ -283,14 +308,9 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup;
- dai = simple_props_to_dai_codec(dai_props, 0); cconf = simple_props_to_codec_conf(dai_props, 0);
- ret = asoc_simple_parse_dai(ep, codecs, NULL); - if (ret < 0) - goto out_put_node; - - ret = asoc_simple_parse_clk(dev, ep, dai, codecs); + ret = graph_parse_node(priv, codec_ep, li, 0); if (ret < 0) goto out_put_node;
@@ -311,11 +331,6 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, }
graph_parse_convert(dev, ep, &dai_props->adata); - graph_parse_mclk_fs(top, ep, dai_props); - - ret = asoc_simple_parse_tdm(ep, dai); - if (ret) - goto out_put_node;
ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, NULL, &dai_link->dai_fmt); @@ -333,9 +348,10 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->init = asoc_simple_dai_init;
out_put_node: + li->link++; + of_node_put(ports); of_node_put(port); - of_node_put(node); return ret; }
@@ -346,48 +362,22 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, { struct device *dev = simple_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); - struct device_node *top = dev->of_node; - struct asoc_simple_dai *cpu_dai = simple_props_to_dai_cpu(dai_props, 0); - struct asoc_simple_dai *codec_dai = simple_props_to_dai_codec(dai_props, 0); struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); - int ret, single_cpu = 0; + int ret;
dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
- li->link++; - - /* Factor to mclk, used in hw_params() */ - graph_parse_mclk_fs(top, cpu_ep, dai_props); - graph_parse_mclk_fs(top, codec_ep, dai_props); - ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, NULL, &dai_link->dai_fmt); if (ret < 0) return ret;
- ret = asoc_simple_parse_dai(cpu_ep, cpus, &single_cpu); - if (ret < 0) - return ret; - - ret = asoc_simple_parse_dai(codec_ep, codecs, NULL); - if (ret < 0) - return ret; - - ret = asoc_simple_parse_tdm(cpu_ep, cpu_dai); - if (ret < 0) - return ret; - - ret = asoc_simple_parse_tdm(codec_ep, codec_dai); + ret = graph_parse_node(priv, cpu_ep, li, 1); if (ret < 0) return ret;
- ret = asoc_simple_parse_clk(dev, cpu_ep, cpu_dai, cpus); - if (ret < 0) - return ret; - - ret = asoc_simple_parse_clk(dev, codec_ep, codec_dai, codecs); + ret = graph_parse_node(priv, codec_ep, li, 0); if (ret < 0) return ret;
@@ -401,7 +391,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, dai_link->ops = &graph_ops; dai_link->init = asoc_simple_dai_init;
- asoc_simple_canonicalize_cpu(cpus, single_cpu); + li->link++;
return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
This patch adds graph_link_init() and share dai_link setting code.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/audio-graph-card.c | 70 +++++++++++++--------------- 1 file changed, 33 insertions(+), 37 deletions(-)
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index bfaeb208db46..2c8a2fcb7922 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -247,6 +247,29 @@ static int graph_parse_node(struct asoc_simple_priv *priv, return 0; }
+static int graph_link_init(struct asoc_simple_priv *priv, + struct device_node *cpu_ep, + struct device_node *codec_ep, + struct link_info *li, + char *name) +{ + struct device *dev = simple_priv_to_dev(priv); + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); + int ret; + + ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, + NULL, &dai_link->dai_fmt); + if (ret < 0) + return ret; + + dai_link->init = asoc_simple_dai_init; + dai_link->ops = &graph_ops; + if (priv->ops) + dai_link->ops = priv->ops; + + return asoc_simple_set_dailink_name(dev, dai_link, name); +} + static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *cpu_ep, struct device_node *codec_ep, @@ -262,6 +285,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *ports; struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); + char dai_name[64]; int ret;
port = of_get_parent(ep); @@ -280,13 +304,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret) goto out_put_node;
- ret = asoc_simple_set_dailink_name(dev, dai_link, - "fe.%pOFP.%s", - cpus->of_node, - cpus->dai_name); - if (ret < 0) - goto out_put_node; - + snprintf(dai_name, sizeof(dai_name), + "fe.%pOFP.%s", cpus->of_node, cpus->dai_name); /* * In BE<->BE connections it is not required to create * PCM devices at CPU end of the dai link and thus 'no_pcm' @@ -314,12 +333,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret < 0) goto out_put_node;
- ret = asoc_simple_set_dailink_name(dev, dai_link, - "be.%pOFP.%s", - codecs->of_node, - codecs->dai_name); - if (ret < 0) - goto out_put_node; + snprintf(dai_name, sizeof(dai_name), + "be.%pOFP.%s", codecs->of_node, codecs->dai_name);
/* check "prefix" from top node */ snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, @@ -332,20 +347,9 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
graph_parse_convert(dev, ep, &dai_props->adata);
- ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, - NULL, &dai_link->dai_fmt); - if (ret < 0) - goto out_put_node; - snd_soc_dai_link_set_capabilities(dai_link);
- dai_link->ops = &graph_ops; - - /* Use custom snd_soc_ops callbacks if available */ - if (priv->ops) - dai_link->ops = priv->ops; - - dai_link->init = asoc_simple_dai_init; + ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
out_put_node: li->link++; @@ -364,15 +368,11 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); + char dai_name[64]; int ret;
dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
- ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep, - NULL, &dai_link->dai_fmt); - if (ret < 0) - return ret; - ret = graph_parse_node(priv, cpu_ep, li, 1); if (ret < 0) return ret; @@ -381,16 +381,12 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, if (ret < 0) return ret;
- ret = asoc_simple_set_dailink_name(dev, dai_link, - "%s-%s", - cpus->dai_name, - codecs->dai_name); + snprintf(dai_name, sizeof(dai_name), + "%s-%s", cpus->dai_name, codecs->dai_name); + ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name); if (ret < 0) return ret;
- dai_link->ops = &graph_ops; - dai_link->init = asoc_simple_dai_init; - li->link++;
return 0;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Parse dai/tdm/clk are common for both CPU/Codec node. This patch creates simple_parse_node() for it and share the code.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 119 ++++++++++++++++---------------- 1 file changed, 58 insertions(+), 61 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index a1373be4558f..91af4eca9c86 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -93,12 +93,11 @@ static void simple_parse_convert(struct device *dev, }
static void simple_parse_mclk_fs(struct device_node *top, - struct device_node *cpu, - struct device_node *codec, + struct device_node *np, struct simple_dai_props *props, char *prefix) { - struct device_node *node = of_get_parent(cpu); + struct device_node *node = of_get_parent(np); char prop[128];
snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX); @@ -106,12 +105,57 @@ static void simple_parse_mclk_fs(struct device_node *top,
snprintf(prop, sizeof(prop), "%smclk-fs", prefix); of_property_read_u32(node, prop, &props->mclk_fs); - of_property_read_u32(cpu, prop, &props->mclk_fs); - of_property_read_u32(codec, prop, &props->mclk_fs); + of_property_read_u32(np, prop, &props->mclk_fs);
of_node_put(node); }
+static int simple_parse_node(struct asoc_simple_priv *priv, + struct device_node *np, + struct link_info *li, + char *prefix, + int is_cpu) +{ + struct device *dev = simple_priv_to_dev(priv); + struct device_node *top = dev->of_node; + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); + struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); + struct snd_soc_dai_link_component *dlc; + struct asoc_simple_dai *dai; + int ret, single = 0; + + if (is_cpu) { + dlc = asoc_link_to_cpu(dai_link, 0); + dai = simple_props_to_dai_cpu(dai_props, 0); + } else { + dlc = asoc_link_to_codec(dai_link, 0); + dai = simple_props_to_dai_codec(dai_props, 0); + } + + simple_parse_mclk_fs(top, np, dai_props, prefix); + + ret = asoc_simple_parse_dai(np, dlc, &single); + if (ret) + return ret; + + ret = asoc_simple_parse_clk(dev, np, dai, dlc); + if (ret) + return ret; + + ret = asoc_simple_parse_tdm(np, dai); + if (ret) + return ret; + + if (is_cpu) { + struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0); + + asoc_simple_canonicalize_cpu(dlc, single); + asoc_simple_canonicalize_platform(platforms, dlc); + } + + return 0; +} + static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, @@ -121,10 +165,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device *dev = simple_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); - struct asoc_simple_dai *dai; struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); - struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0); struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); char *prefix = ""; @@ -132,28 +174,18 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
dev_dbg(dev, "link_of DPCM (%pOF)\n", np);
- li->link++; - /* For single DAI link & old style of DT node */ if (is_top) prefix = PREFIX;
if (li->cpu) { - int is_single_links = 0; - /* Codec is dummy */
/* FE settings */ dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1;
- dai = simple_props_to_dai_cpu(dai_props, 0); - - ret = asoc_simple_parse_dai(np, cpus, &is_single_links); - if (ret) - goto out_put_node; - - ret = asoc_simple_parse_clk(dev, np, dai, cpus); + ret = simple_parse_node(priv, np, li, prefix, 1); if (ret < 0) goto out_put_node;
@@ -162,9 +194,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, cpus->dai_name); if (ret < 0) goto out_put_node; - - asoc_simple_canonicalize_cpu(cpus, is_single_links); - asoc_simple_canonicalize_platform(platforms, cpus); } else { struct snd_soc_codec_conf *cconf;
@@ -174,14 +203,9 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup;
- dai = simple_props_to_dai_codec(dai_props, 0); cconf = simple_props_to_codec_conf(dai_props, 0);
- ret = asoc_simple_parse_dai(np, codecs, NULL); - if (ret < 0) - goto out_put_node; - - ret = asoc_simple_parse_clk(dev, np, dai, codecs); + ret = simple_parse_node(priv, np, li, prefix, 0); if (ret < 0) goto out_put_node;
@@ -201,11 +225,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, }
simple_parse_convert(dev, np, &dai_props->adata); - simple_parse_mclk_fs(top, np, codec, dai_props, prefix); - - ret = asoc_simple_parse_tdm(np, dai); - if (ret) - goto out_put_node;
ret = asoc_simple_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); @@ -218,6 +237,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->init = asoc_simple_dai_init;
out_put_node: + li->link++; + of_node_put(node); return ret; } @@ -230,23 +251,18 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, { struct device *dev = simple_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); - struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); - struct asoc_simple_dai *cpu_dai = simple_props_to_dai_cpu(dai_props, 0); - struct asoc_simple_dai *codec_dai = simple_props_to_dai_codec(dai_props, 0); struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0); - struct device_node *top = dev->of_node; struct device_node *cpu = NULL; struct device_node *node = NULL; struct device_node *plat = NULL; char prop[128]; char *prefix = ""; - int ret, single_cpu = 0; + int ret;
cpu = np; node = of_get_parent(np); - li->link++;
dev_dbg(dev, "link_of (%pOF)\n", node);
@@ -262,13 +278,11 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, if (ret < 0) goto dai_link_of_err;
- simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix); - - ret = asoc_simple_parse_dai(cpu, cpus, &single_cpu); + ret = simple_parse_node(priv, cpu, li, prefix, 1); if (ret < 0) goto dai_link_of_err;
- ret = asoc_simple_parse_dai(codec, codecs, NULL); + ret = simple_parse_node(priv, codec, li, prefix, 0); if (ret < 0) goto dai_link_of_err;
@@ -276,22 +290,6 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, if (ret < 0) goto dai_link_of_err;
- ret = asoc_simple_parse_tdm(cpu, cpu_dai); - if (ret < 0) - goto dai_link_of_err; - - ret = asoc_simple_parse_tdm(codec, codec_dai); - if (ret < 0) - goto dai_link_of_err; - - ret = asoc_simple_parse_clk(dev, cpu, cpu_dai, cpus); - if (ret < 0) - goto dai_link_of_err; - - ret = asoc_simple_parse_clk(dev, codec, codec_dai, codecs); - if (ret < 0) - goto dai_link_of_err; - ret = asoc_simple_set_dailink_name(dev, dai_link, "%s-%s", cpus->dai_name, @@ -302,13 +300,12 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, dai_link->ops = &simple_ops; dai_link->init = asoc_simple_dai_init;
- asoc_simple_canonicalize_cpu(cpus, single_cpu); - asoc_simple_canonicalize_platform(platforms, cpus); - dai_link_of_err: of_node_put(plat); of_node_put(node);
+ li->link++; + return ret; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
This patch adds simple_link_init() and share dai_link setting code.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 59 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 91af4eca9c86..6a04632944b8 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -156,6 +156,28 @@ static int simple_parse_node(struct asoc_simple_priv *priv, return 0; }
+static int simple_link_init(struct asoc_simple_priv *priv, + struct device_node *node, + struct device_node *codec, + struct link_info *li, + char *prefix, + char *name) +{ + struct device *dev = simple_priv_to_dev(priv); + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); + int ret; + + ret = asoc_simple_parse_daifmt(dev, node, codec, + prefix, &dai_link->dai_fmt); + if (ret < 0) + return 0; + + dai_link->init = asoc_simple_dai_init; + dai_link->ops = &simple_ops; + + return asoc_simple_set_dailink_name(dev, dai_link, name); +} + static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *np, struct device_node *codec, @@ -170,6 +192,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); char *prefix = ""; + char dai_name[64]; int ret;
dev_dbg(dev, "link_of DPCM (%pOF)\n", np); @@ -189,11 +212,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret < 0) goto out_put_node;
- ret = asoc_simple_set_dailink_name(dev, dai_link, - "fe.%s", - cpus->dai_name); - if (ret < 0) - goto out_put_node; + snprintf(dai_name, sizeof(dai_name), "fe.%s", cpus->dai_name); } else { struct snd_soc_codec_conf *cconf;
@@ -209,11 +228,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret < 0) goto out_put_node;
- ret = asoc_simple_set_dailink_name(dev, dai_link, - "be.%s", - codecs->dai_name); - if (ret < 0) - goto out_put_node; + snprintf(dai_name, sizeof(dai_name), "be.%s", codecs->dai_name);
/* check "prefix" from top node */ snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, @@ -226,15 +241,9 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
simple_parse_convert(dev, np, &dai_props->adata);
- ret = asoc_simple_parse_daifmt(dev, node, codec, - prefix, &dai_link->dai_fmt); - if (ret < 0) - goto out_put_node; - snd_soc_dai_link_set_capabilities(dai_link);
- dai_link->ops = &simple_ops; - dai_link->init = asoc_simple_dai_init; + ret = simple_link_init(priv, node, codec, li, prefix, dai_name);
out_put_node: li->link++; @@ -257,6 +266,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, struct device_node *cpu = NULL; struct device_node *node = NULL; struct device_node *plat = NULL; + char dai_name[64]; char prop[128]; char *prefix = ""; int ret; @@ -273,11 +283,6 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, snprintf(prop, sizeof(prop), "%splat", prefix); plat = of_get_child_by_name(node, prop);
- ret = asoc_simple_parse_daifmt(dev, node, codec, - prefix, &dai_link->dai_fmt); - if (ret < 0) - goto dai_link_of_err; - ret = simple_parse_node(priv, cpu, li, prefix, 1); if (ret < 0) goto dai_link_of_err; @@ -290,16 +295,12 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, if (ret < 0) goto dai_link_of_err;
- ret = asoc_simple_set_dailink_name(dev, dai_link, - "%s-%s", - cpus->dai_name, - codecs->dai_name); + snprintf(dai_name, sizeof(dai_name), + "%s-%s", cpus->dai_name, codecs->dai_name); + ret = simple_link_init(priv, node, codec, li, prefix, dai_name); if (ret < 0) goto dai_link_of_err;
- dai_link->ops = &simple_ops; - dai_link->init = asoc_simple_dai_init; - dai_link_of_err: of_node_put(plat); of_node_put(node);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Use local variable at local area only.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/audio-graph-card.c | 30 +++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 2c8a2fcb7922..0159a4576e9c 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -276,24 +276,19 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct link_info *li) { struct device *dev = simple_priv_to_dev(priv); - struct snd_soc_card *card = simple_priv_to_card(priv); struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct device_node *top = dev->of_node; struct device_node *ep = li->cpu ? cpu_ep : codec_ep; - struct device_node *port; - struct device_node *ports; - struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); - struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); char dai_name[64]; int ret;
- port = of_get_parent(ep); - ports = of_get_parent(port); - dev_dbg(dev, "link_of DPCM (%pOF)\n", ep);
if (li->cpu) { + struct snd_soc_card *card = simple_priv_to_card(priv); + struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0); + /* Codec is dummy */
/* FE settings */ @@ -302,7 +297,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
ret = graph_parse_node(priv, cpu_ep, li, 1); if (ret) - goto out_put_node; + return ret;
snprintf(dai_name, sizeof(dai_name), "fe.%pOFP.%s", cpus->of_node, cpus->dai_name); @@ -319,7 +314,10 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (card->component_chaining && !soc_component_is_pcm(cpus)) dai_link->no_pcm = 1; } else { - struct snd_soc_codec_conf *cconf; + struct snd_soc_codec_conf *cconf = simple_props_to_codec_conf(dai_props, 0); + struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0); + struct device_node *port; + struct device_node *ports;
/* CPU is dummy */
@@ -327,22 +325,25 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup;
- cconf = simple_props_to_codec_conf(dai_props, 0); - ret = graph_parse_node(priv, codec_ep, li, 0); if (ret < 0) - goto out_put_node; + return ret;
snprintf(dai_name, sizeof(dai_name), "be.%pOFP.%s", codecs->of_node, codecs->dai_name);
/* check "prefix" from top node */ + port = of_get_parent(ep); + ports = of_get_parent(port); snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, "prefix"); if (of_node_name_eq(ports, "ports")) snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, "prefix"); snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, "prefix"); + + of_node_put(ports); + of_node_put(port); }
graph_parse_convert(dev, ep, &dai_props->adata); @@ -351,11 +352,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
-out_put_node: li->link++;
- of_node_put(ports); - of_node_put(port); return ret; }
On 21 Apr 2021 14:44:44 +0900, Kuninori Morimoto wrote:
These patches cleanups simple-card / audio-graph. This is part of prepare for new audio-graph-card2.
Kuninori Morimoto (5): ASoC: audio-graph: add graph_parse_node() ASoC: audio-graph: add graph_link_init() ASoC: simple-card: add simple_parse_node() ASoC: simple-card: add simple_link_init() ASoC: audio-graph: tidyup graph_dai_link_of_dpcm()
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] ASoC: audio-graph: add graph_parse_node() commit: 8859f809c7d5813c28ab90f5335f182e634d77af [2/5] ASoC: audio-graph: add graph_link_init() commit: e51237b8d3052251421770468903fa6e4446d158 [3/5] ASoC: simple-card: add simple_parse_node() commit: 59c35c44a9cf89a83a92a8d26749e59497d0317d [4/5] ASoC: simple-card: add simple_link_init() commit: 434392271afcff350fe11730f12b831fffaf33eb [5/5] ASoC: audio-graph: tidyup graph_dai_link_of_dpcm() commit: 73371bacf0475a20ab6f3e7b6310e378ec5b3023
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
participants (2)
-
Kuninori Morimoto
-
Mark Brown