[PATCH] ASoC: core: Don't set platform name when of_node is set

Daniel Baluta daniel.baluta at gmail.com
Fri Mar 12 13:37:30 CET 2021


On Fri, Mar 12, 2021 at 1:59 PM Mark Brown <broonie at kernel.org> wrote:
>
> On Fri, Mar 12, 2021 at 12:59:29PM +0200, Daniel Baluta wrote:
> > On Fri, Mar 12, 2021 at 12:50 PM Mark Brown <broonie at kernel.org> wrote:
>
> > > 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?

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.


More information about the Alsa-devel mailing list