ASoC: core: Don't set platform name when of_node is set
PATCH 1/1 ASoC: core: Don't set platform name when of_node is set
From: Daniel Baluta <[email protected]>
Platform may be specified by either name or OF node but not both.
For OF node platforms (e.g i.MX) we end up with both platform name and of_node set and sound card registration will fail with the error:
asoc-simple-card sof-sound-wm8960: ASoC: Neither/both platform name/of_node are set for sai1-wm8960-hifi
--- sound/soc/soc-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/soc-core.c +3 -1
@@ -1660,7 +1660,9 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)dev_err (card->dev,"init platform error" );continue ; } - dai_link->platforms->name = component->name; + +if (!dai_link->platforms->of_node) + dai_link->platforms->name = component->name;/* convert non BE into BE */ if (!dai_link->no_pcm) {
Signature · 1 line
2.27.0
Mark Brown
maintainerQuoted 10 lines · Daniel Baluta
From: Daniel Baluta <[email protected]>
Platform may be specified by either name or OF node but not both.
For OF node platforms (e.g i.MX) we end up with both platform name and
of_nodeset and sound card registration will fail with the error:asoc-simple-card sof-sound-wm8960: ASoC: Neither/both platform name/of_node are set for sai1-wm8960-hifi
This doesn't actually say what the change does.
sound/soc/soc-core.c static void soc_check_tplg_fes(struct snd_soc_card *card) · line 1665
Quoted 4 lines
sound/soc/soc-core.c +3
-1- dai_link->platforms->name = component->name; + +if (!dai_link->platforms->of_node) + dai_link->platforms->name = component->name;
Why would we prefer the node name over something explicitly configured?
Quoted 7 lines · Mark Brown
Quoted 5 lines · Daniel Baluta
From: Daniel Baluta <[email protected]>
Platform may be specified by either name or OF node but not both.
Quoted 7 lines
Quoted 5 lines
For OF node platforms (e.g i.MX) we end up with both platform name and
of_nodeset and sound card registration will fail with the error:asoc-simple-card sof-sound-wm8960: ASoC: Neither/both platform name/of_node are set for sai1-wm8960-hifi
This doesn't actually say what the change does.
Will send v2 with a better explanation.
Quoted 7 lines
sound/soc/soc-core.c static void soc_check_tplg_fes(struct snd_soc_card *card) · line 1665
Quoted 5 lines
sound/soc/soc-core.c +3
-1- dai_link->platforms->name = component->name; + +if (!dai_link->platforms->of_node) + dai_link->platforms->name = component->name;Why would we prefer the node name over something explicitly configured?
Not sure I follow your question. I think the difference stands in the way we treat OF vs non-OF platforms.
With OF-platforms, dai_link->platforms->of_node is always set! So we no longer need
to set dai->platforms->name.
Actually setting both of_node and name will make sound card registration fail! In this is the case I'm trying to fix here.
Mark Brown
maintainerQuoted 9 lines · Daniel Baluta
Quoted 4 lines · Mark Brown
sound/soc/soc-core.c static void soc_check_tplg_fes(struct snd_soc_card *card) · line 1665
Quoted 2 lines
sound/soc/soc-core.c +2
-0+if (!dai_link->platforms->of_node) + dai_link->platforms->name = component->name;Why would we prefer the node name over something explicitly configured?
Not sure I follow your question. I think the difference stands in the way we treat OF vs non-OF platforms.
If an explicit name has been provided why would we override it with an autogenerated one?
Quoted 7 lines · Mark Brown
Quoted 4 lines · Daniel Baluta
Quoted 2 lines · Mark Brown
Quoted 2 lines
sound/soc/soc-core.c +2
-0+if (!dai_link->platforms->of_node) + dai_link->platforms->name = component->name;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Why would we prefer the node name over something explicitly configured?
Not sure I follow your question. I think the difference stands in the way we treat OF vs non-OF platforms.
If an explicit name has been provided why would we override it with an autogenerated one?
Wait, are you asking why the initial code:
dai_link->platforms->name = component->name;
is there in the initial code?
Mark Brown
maintainerQuoted 10 lines · Daniel Baluta
Quoted 2 lines · Mark Brown
If an explicit name has been provided why would we override it with an autogenerated one?
Wait, are you asking why the initial code:
dai_link->platforms->name = component->name;is there in the initial code?
No, just the opposite! If there's an explict name configured why do you want to ignore it?
Quoted 7 lines · Mark Brown
Quoted 4 lines · Daniel Baluta
Quoted 2 lines · Mark Brown
If an explicit name has been provided why would we override it with an autogenerated one?
Quoted 8 lines
Quoted 5 lines
Wait, are you asking why the initial code:
dai_link->platforms->name = component->name;is there in the initial code?
No, just the opposite! If there's an explict name configured why do you want to ignore it?
Because the initial assignment:
dai_link->platforms->name = component->name;
doesn't take into consideration that dai_link->platform->of_node is also explicitly configured.
So, my change only configures the name (dai_link->platform->name) if the dai->platform->of_node wasn't previously explicitly configured.
Otherwise, we end up with both dai_link->platforms->name and dai->link->platforms->of_node
configured and we hit this error:
soc_dai_link_sanity_check:
/*
* Platform may be specified by either name or OF node, but it
* can be left unspecified, then no components will be inserted
* in the rtdcom list
*/
if (!!platform->name == !!platform->of_node) {
dev_err(card->dev,
"ASoC: Neither/both platform name/of_node are set for %s\n", link->name);
return -EINVAL;
}I start with a simple-audio-card node:
sof-sound-wm8960 {
compatible = "simple-audio-card";
simple-audio-card,dai-link {
format = "i2s";
cpu {
sound-dai = <&dsp 1>;
};
sndcodec: codec {
sound-dai = <&wm8960>;
};
}Notice that doesn't have any platform field.
But then in sound/soc/generic/simple-card-utils.c:asoc_simple_canonicalize_platform explicitly sets dai_link->platforms->of_node like this:
» if (!dai_link->platforms->of_node)
» » dai_link->platforms->of_node = dai_link->cpus->of_node;
I hope this is more clear.
Mark Brown
maintainerQuoted 11 lines · Daniel Baluta
Quoted 2 lines · Mark Brown
No, just the opposite! If there's an explict name configured why do you want to ignore it?
Because the initial assignment:
dai_link->platforms->name=component->name;doesn't take into consideration that
dai_link->platform->of_nodeis also explicitly configured.
But why should we take that into consideration here?
Quoted 9 lines
dai->link->platforms->of_node
configured and we hit this error:
soc_dai_link_sanity_check:
/*
* Platform may be specified by either name or OF node, but it
* can be left unspecified, then no components will be inserted
* in the rtdcom list
*/
Quoted 5 lines
if (!!platform->name == !!platform->of_node) {
dev_err(card->dev,
"ASoC: Neither/both platform name/of_node are set for %s\n", link->name);
return -EINVAL;
}OK, but then does this check actually make sense? The code has been that way since the initial DT introduction since we disallow matching by both name and OF node in order to avoid confusion when building the card so I think it does but it's only with this mail that I get the information to figure out that this is something we actually check for then go find the reason why we check.
Quoted 31 lines · Mark Brown
Quoted 11 lines · Daniel Baluta
Quoted 2 lines · Mark Brown
No, just the opposite! If there's an explict name configured why do you want to ignore it?
Because the initial assignment:
dai_link->platforms->name=component->name;doesn't take into consideration that
dai_link->platform->of_nodeis also explicitly configured.But why should we take that into consideration here?
Quoted 9 lines
dai->link->platforms->of_node
configured and we hit this error:
soc_dai_link_sanity_check:
/*
* Platform may be specified by either name or OF node, but it
* can be left unspecified, then no components will be inserted
* in the rtdcom list
*/Quoted 5 lines
if (!!platform->name == !!platform->of_node) { dev_err(card->dev, "ASoC: Neither/both platform name/of_node are set for %s\n", link->name); return -EINVAL; }
Quoted 6 lines
OK, but then does this check actually make sense? The code has been that way since the initial DT introduction since we disallow matching by both name and OF node in order to avoid confusion when building the card so I think it does but it's only with this mail that I get the information to figure out that this is something we actually check for then go find the reason why we check.
I will enhance the commit message and send v2. Hope to catch all the inner details.