Skip to content

Commit dbd08fe

Browse files
morimotobroonie
authored andcommitted
ASoC: simple-scu-card: tidyup asoc_simple_card_parse_daifmt() timing
Current simple-scu-card driver is parsing codec position for DPCM and consider DAI format. But, current operation is doing totally pointless, because it should be called for each CPU/Codec pair. Let's tidyup asoc_simple_card_parse_daifmt() timing. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4fb7f4d commit dbd08fe

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

sound/soc/generic/simple-scu-card.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,24 @@ static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
9292
return 0;
9393
}
9494

95-
static int asoc_simple_card_dai_link_of(struct device_node *np,
95+
static int asoc_simple_card_dai_link_of(struct device_node *link,
96+
struct device_node *np,
97+
struct device_node *codec,
9698
struct simple_card_data *priv,
97-
unsigned int daifmt,
98-
int idx, bool is_fe)
99+
int idx, bool is_fe,
100+
bool is_top_level_node)
99101
{
100102
struct device *dev = simple_priv_to_dev(priv);
101103
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
102104
struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx);
103105
struct snd_soc_card *card = simple_priv_to_card(priv);
106+
char *prefix = "";
104107
int ret;
105108

109+
/* For single DAI link & old style of DT node */
110+
if (is_top_level_node)
111+
prefix = PREFIX;
112+
106113
if (is_fe) {
107114
int is_single_links = 0;
108115
struct snd_soc_dai_link_component *codecs;
@@ -178,7 +185,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *np,
178185
if (ret < 0)
179186
return ret;
180187

181-
dai_link->dai_fmt = daifmt;
188+
ret = asoc_simple_card_parse_daifmt(dev, link, codec,
189+
prefix, &dai_link->dai_fmt);
190+
if (ret < 0)
191+
return ret;
192+
182193
dai_link->dpcm_playback = 1;
183194
dai_link->dpcm_capture = 1;
184195
dai_link->ops = &asoc_simple_card_ops;
@@ -191,10 +202,10 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv)
191202

192203
{
193204
struct device *dev = simple_priv_to_dev(priv);
205+
struct device_node *node = dev->of_node;
194206
struct device_node *np;
207+
struct device_node *codec;
195208
struct snd_soc_card *card = simple_priv_to_card(priv);
196-
struct device_node *node = dev->of_node;
197-
unsigned int daifmt = 0;
198209
bool is_fe;
199210
int ret, i;
200211

@@ -211,22 +222,18 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv)
211222

212223
asoc_simple_card_parse_convert(dev, node, PREFIX, &priv->adata);
213224

214-
/* find 1st codec */
215-
np = of_get_child_by_name(node, PREFIX "codec");
216-
if (!np)
225+
i = 0;
226+
codec = of_get_child_by_name(node, PREFIX "codec");
227+
if (!codec)
217228
return -ENODEV;
218229

219-
ret = asoc_simple_card_parse_daifmt(dev, node, np, PREFIX, &daifmt);
220-
if (ret < 0)
221-
return ret;
222-
223-
i = 0;
224230
for_each_child_of_node(node, np) {
225231
is_fe = false;
226232
if (of_node_name_eq(np, PREFIX "cpu"))
227233
is_fe = true;
228234

229-
ret = asoc_simple_card_dai_link_of(np, priv, daifmt, i, is_fe);
235+
ret = asoc_simple_card_dai_link_of(node, np, codec, priv,
236+
i, is_fe, true);
230237
if (ret < 0)
231238
return ret;
232239
i++;

0 commit comments

Comments
 (0)