Message ID | 87o7nm2fvf.wl-kuninori.morimoto.gx@renesas.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | ASoC: add and use asoc_dummy_dlc | expand |
On 4/18/2023 2:28 AM, Kuninori Morimoto wrote: > Now we can share asoc_dummy_dlc. This patch use it. > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > sound/soc/soc-topology.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c > index d0aca6b9058b..873448c4a895 100644 > --- a/sound/soc/soc-topology.c > +++ b/sound/soc/soc-topology.c > @@ -1685,15 +1685,15 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, > struct snd_soc_dai_link_component *dlc; > int ret; > > - /* link + cpu + codec + platform */ > - link = devm_kzalloc(tplg->dev, sizeof(*link) + (3 * sizeof(*dlc)), GFP_KERNEL); > + /* link + cpu + platform */ > + link = devm_kzalloc(tplg->dev, sizeof(*link) + (2 * sizeof(*dlc)), GFP_KERNEL); > if (link == NULL) > return -ENOMEM; > > dlc = (struct snd_soc_dai_link_component *)(link + 1); > > link->cpus = &dlc[0]; > - link->codecs = &dlc[1]; > + link->codecs = &asoc_dummy_dlc; > > link->num_cpus = 1; > link->num_codecs = 1; > @@ -1721,14 +1721,12 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, > } > } > > - link->codecs->name = "snd-soc-dummy"; > - link->codecs->dai_name = "snd-soc-dummy-dai"; > - > /* > * Many topology is assuming link has Platform. > * This might be overwritten at soc_tplg_dai_link_load(). > + * Don't use &asoc_dummy_dlc here. > */ > - link->platforms = &dlc[2]; > + link->platforms = &dlc[1]; > link->platforms->name = "snd-soc-dummy"; > link->num_platforms = 1; > In case of topology I'm not convinced that it is a good idea. You set link->codecs to point at global object, but if any of link modifies its link->codecs, which for example can happen in soc_tplg_dai_link_load() then all other link objects will point at modified value.
Hi Amadeusz > In case of topology I'm not convinced that it is a good idea. You set > link->codecs to point at global object, but if any of link modifies its > link->codecs, which for example can happen in soc_tplg_dai_link_load() > then all other link objects will point at modified value. Thank you for pointing it. I see. Not only "platform" but "codecs" also might be modified on topology... I think we want to have such comment/note on the code. I will modify it on v2 patch. Thank you for your help !! Best regards --- Kuninori Morimoto
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index d0aca6b9058b..873448c4a895 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1685,15 +1685,15 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, struct snd_soc_dai_link_component *dlc; int ret; - /* link + cpu + codec + platform */ - link = devm_kzalloc(tplg->dev, sizeof(*link) + (3 * sizeof(*dlc)), GFP_KERNEL); + /* link + cpu + platform */ + link = devm_kzalloc(tplg->dev, sizeof(*link) + (2 * sizeof(*dlc)), GFP_KERNEL); if (link == NULL) return -ENOMEM; dlc = (struct snd_soc_dai_link_component *)(link + 1); link->cpus = &dlc[0]; - link->codecs = &dlc[1]; + link->codecs = &asoc_dummy_dlc; link->num_cpus = 1; link->num_codecs = 1; @@ -1721,14 +1721,12 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, } } - link->codecs->name = "snd-soc-dummy"; - link->codecs->dai_name = "snd-soc-dummy-dai"; - /* * Many topology is assuming link has Platform. * This might be overwritten at soc_tplg_dai_link_load(). + * Don't use &asoc_dummy_dlc here. */ - link->platforms = &dlc[2]; + link->platforms = &dlc[1]; link->platforms->name = "snd-soc-dummy"; link->num_platforms = 1;
Now we can share asoc_dummy_dlc. This patch use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> --- sound/soc/soc-topology.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)