All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH v2 02/12] ASoC: simple-card-utils: remove li->dais/li->conf
Date: 12 Apr 2021 08:52:04 +0900	[thread overview]
Message-ID: <87sg3wwfa3.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87v98swfar.wl-kuninori.morimoto.gx@renesas.com>


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

li->dais is same as number of CPU + Codec,
li->conf is same as number of Codec when dummy-Codec.

li->dais/li->conf are no longer needed.
This patch removes these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     |  2 --
 sound/soc/generic/audio-graph-card.c  | 10 +---------
 sound/soc/generic/simple-card-utils.c | 14 ++++++++++----
 sound/soc/generic/simple-card.c       | 11 +----------
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 6635283a8160..da9d7e3665a8 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -75,9 +75,7 @@ struct asoc_simple_priv {
 #define simple_priv_to_link(priv, i)	(simple_priv_to_card(priv)->dai_link + (i))
 
 struct link_info {
-	int dais; /* number of dai  */
 	int link; /* number of link */
-	int conf; /* number of codec_conf */
 	int cpu;  /* turn for CPU / Codec */
 	struct prop_nums num[SNDRV_MINOR_DEVICES];
 };
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 5ce5b7d62ee0..3a5bef2a91d3 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -552,7 +552,7 @@ int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
 
 	memset(&li, 0, sizeof(li));
 	graph_get_dais_count(priv, &li);
-	if (!li.link || !li.dais)
+	if (!li.link)
 		return -EINVAL;
 
 	ret = asoc_simple_init_priv(priv, &li);
@@ -622,7 +622,6 @@ static int graph_count_noml(struct asoc_simple_priv *priv,
 	li->num[li->link].platforms	= 1;
 
 	li->link += 1; /* 1xCPU-Codec */
-	li->dais += 2; /* 1xCPU + 1xCodec */
 
 	dev_dbg(dev, "Count As Normal\n");
 
@@ -646,13 +645,10 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,
 		li->num[li->link].platforms	= 1;
 
 		li->link++; /* 1xCPU-dummy */
-		li->dais++; /* 1xCPU */
 	} else {
 		li->num[li->link].codecs	= 1;
 
 		li->link++; /* 1xdummy-Codec */
-		li->conf++; /* 1xdummy-Codec */
-		li->dais++; /* 1xCodec */
 	}
 
 	dev_dbg(dev, "Count As DPCM\n");
@@ -663,8 +659,6 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,
 static void graph_get_dais_count(struct asoc_simple_priv *priv,
 				 struct link_info *li)
 {
-	struct device *dev = simple_priv_to_dev(priv);
-
 	/*
 	 * link_num :	number of links.
 	 *		CPU-Codec / CPU-dummy / dummy-Codec
@@ -714,8 +708,6 @@ static void graph_get_dais_count(struct asoc_simple_priv *priv,
 	graph_for_each_link(priv, li,
 			    graph_count_noml,
 			    graph_count_dpcm);
-	dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
-		li->link, li->dais, li->conf);
 }
 
 int audio_graph_card_probe(struct snd_soc_card *card)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index ca74dfa58458..59b4fb2bd586 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -597,7 +597,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 	struct asoc_simple_dai *dais;
 	struct snd_soc_dai_link_component *dlcs;
 	struct snd_soc_codec_conf *cconf = NULL;
-	int i, dai_num = 0, dlc_num = 0;
+	int i, dai_num = 0, dlc_num = 0, cnf_num = 0;
 
 	dai_props = devm_kcalloc(dev, li->link, sizeof(*dai_props), GFP_KERNEL);
 	dai_link  = devm_kcalloc(dev, li->link, sizeof(*dai_link),  GFP_KERNEL);
@@ -613,6 +613,9 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 
 		dai_num += cc;
 		dlc_num += cc + li->num[i].platforms;
+
+		if (!li->num[i].cpus)
+			cnf_num += li->num[i].codecs;
 	}
 
 	dais = devm_kcalloc(dev, dai_num, sizeof(*dais),      GFP_KERNEL);
@@ -620,12 +623,15 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 	if (!dais || !dlcs)
 		return -ENOMEM;
 
-	if (li->conf) {
-		cconf = devm_kcalloc(dev, li->conf, sizeof(*cconf), GFP_KERNEL);
+	if (cnf_num) {
+		cconf = devm_kcalloc(dev, cnf_num, sizeof(*cconf), GFP_KERNEL);
 		if (!cconf)
 			return -ENOMEM;
 	}
 
+	dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
+		li->link, dai_num, cnf_num);
+
 	/* dummy CPU/Codec */
 	priv->dummy.of_node	= NULL;
 	priv->dummy.dai_name	= "snd-soc-dummy-dai";
@@ -640,7 +646,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 	card->dai_link		= priv->dai_link;
 	card->num_links		= li->link;
 	card->codec_conf	= cconf;
-	card->num_configs	= li->conf;
+	card->num_configs	= cnf_num;
 
 	for (i = 0; i < li->link; i++) {
 		if (li->num[i].cpus) {
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 30da8272fbc0..7665bbf2a6c0 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -495,7 +495,6 @@ static int simple_count_noml(struct asoc_simple_priv *priv,
 	li->num[li->link].platforms	= 1;
 
 	li->link += 1;
-	li->dais += 2;
 
 	return 0;
 }
@@ -517,13 +516,10 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv,
 		li->num[li->link].platforms	= 1;
 
 		li->link++; /* CPU-dummy */
-		li->dais++;
 	} else {
 		li->num[li->link].codecs	= 1;
 
 		li->link++; /* dummy-Codec */
-		li->dais++;
-		li->conf++;
 	}
 
 	return 0;
@@ -587,17 +583,12 @@ static void simple_get_dais_count(struct asoc_simple_priv *priv,
 		li->num[0].platforms	= 1;
 
 		li->link = 1;
-		li->dais = 2;
-		li->conf = 0;
 		return;
 	}
 
 	simple_for_each_link(priv, li,
 			     simple_count_noml,
 			     simple_count_dpcm);
-
-	dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
-		li->link, li->dais, li->conf);
 }
 
 static int simple_soc_probe(struct snd_soc_card *card)
@@ -637,7 +628,7 @@ static int asoc_simple_probe(struct platform_device *pdev)
 
 	memset(&li, 0, sizeof(li));
 	simple_get_dais_count(priv, &li);
-	if (!li.link || !li.dais)
+	if (!li.link)
 		return -EINVAL;
 
 	ret = asoc_simple_init_priv(priv, &li);
-- 
2.25.1


  parent reply	other threads:[~2021-04-11 23:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11 23:51 [PATCH v2 00/12] ASoC: simple-card-utils: prepare for multi support Kuninori Morimoto
2021-04-11 23:51 ` [PATCH v2 01/12] ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing Kuninori Morimoto
2021-04-11 23:52 ` Kuninori Morimoto [this message]
2021-04-11 23:52 ` [PATCH v2 03/12] ASoC: simple-card-utils: use for_each_prop_xxx() Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 04/12] ASoC: simple-card-utils: remove asoc_simple_parse_xxx() Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 05/12] ASoC: simple-card-utils: care multi DAI at asoc_simple_clean_reference() Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 06/12] ASoC: simple-card-utils: indicate dai_fmt if exist Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 07/12] ASoC: simple-card-utils: indicate missing CPU/Codec numbers for debug Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 08/12] ASoC: simple-card-utils: add simple_props_to_xxx() macro Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 09/12] ASoC: simple-card-utils: multi support at asoc_simple_canonicalize_cpu/platform() Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 10/12] ASoC: simple-card-utils: tidyup debug info for clock Kuninori Morimoto
2021-04-11 23:52 ` [PATCH v2 11/12] ASoC: simple-card-utils: tidyup dev_dbg() to use 1 line Kuninori Morimoto
2021-04-11 23:53 ` [PATCH v2 12/12] ASoC: simple-card-utils: tidyup asoc_simple_parse_convert() Kuninori Morimoto
2021-04-13 15:08 ` [PATCH v2 00/12] ASoC: simple-card-utils: prepare for multi support Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sg3wwfa3.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.