[PATCH 04/14] ASoC: simple-card-utils: remove li->dais/li->conf
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Thu Apr 1 06:15:52 CEST 2021
From: Kuninori Morimoto <kuninori.morimoto.gx at 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 at 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 75f18929f0e9..45c9656a1336 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 fc8b6facd473..61f08bb10ffb 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
More information about the Alsa-devel
mailing list