Message ID | 871rvmilpo.wl-kuninori.morimoto.gx@renesas.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: soc-core cleanup - step 4 | expand |
On 10/8/19 11:31 PM, Kuninori Morimoto wrote: > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > > ALSA SoC has 2 similar but diffarent implementation. > snd_soc_register_dai() is used from topology > snd_soc_register_dais() is used from snd_soc_add_component() > > Because of this kind of confusable naming, and duplicated > implementation, code is very unreadale. > We shouldn't have duplicated and confusable implementation. > This patch calls snd_soc_register_dai() from snd_soc_register_dais() > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > sound/soc/soc-core.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c > index d4f80c8..bbcaac5 100644 > --- a/sound/soc/soc-core.c > +++ b/sound/soc/soc-core.c > @@ -2610,14 +2610,17 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, > struct snd_soc_dai_driver *dai_drv, > bool legacy_dai_naming) > { > + struct device *dev = component->dev; > struct snd_soc_dai *dai; > > - if (dai_drv->dobj.type != SND_SOC_DOBJ_PCM) { > - dev_err(component->dev, "Invalid dai type %d\n", > - dai_drv->dobj.type); > + if (dai_drv->dobj.type && > + dai_drv->dobj.type != SND_SOC_DOBJ_PCM) { > + dev_err(dev, "Invalid dai type %d\n", dai_drv->dobj.type); > return NULL; > } this block of code is removed in patch 20, so do we need the modification here? > > + dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name); > + > lockdep_assert_held(&client_mutex); > dai = soc_add_dai(component, dai_drv, legacy_dai_naming); > if (!dai) > @@ -2651,16 +2654,12 @@ static int snd_soc_register_dais(struct snd_soc_component *component, > struct snd_soc_dai_driver *dai_drv, > size_t count) > { > - struct device *dev = component->dev; > struct snd_soc_dai *dai; > unsigned int i; > int ret; > > - dev_dbg(dev, "ASoC: dai register %s #%zu\n", dev_name(dev), count); > - > for (i = 0; i < count; i++) { > - > - dai = soc_add_dai(component, dai_drv + i, count == 1 && > + dai = snd_soc_register_dai(component, dai_drv + i, count == 1 && > !component->driver->non_legacy_dai_naming); > if (dai == NULL) { > ret = -ENOMEM; >
Hi Pierre-Louis > > @@ -2610,14 +2610,17 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, > > struct snd_soc_dai_driver *dai_drv, > > bool legacy_dai_naming) > > { > > + struct device *dev = component->dev; > > struct snd_soc_dai *dai; > > - if (dai_drv->dobj.type != SND_SOC_DOBJ_PCM) { > > - dev_err(component->dev, "Invalid dai type %d\n", > > - dai_drv->dobj.type); > > + if (dai_drv->dobj.type && > > + dai_drv->dobj.type != SND_SOC_DOBJ_PCM) { > > + dev_err(dev, "Invalid dai type %d\n", dai_drv->dobj.type); > > return NULL; > > } > > this block of code is removed in patch 20, so do we need the > modification here? Yes, it will be removed 20, but it is still exist until then. Because of this patch 19, snd_soc_register_dai() is called from soc-core which doesn't have dobj.type. Without this modification, *all* sound will get error, unfortunately. Or apply 20 first, 19 next can be more simple patch. Thank you for your help !! Best regards --- Kuninori Morimoto
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d4f80c8..bbcaac5 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2610,14 +2610,17 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, bool legacy_dai_naming) { + struct device *dev = component->dev; struct snd_soc_dai *dai; - if (dai_drv->dobj.type != SND_SOC_DOBJ_PCM) { - dev_err(component->dev, "Invalid dai type %d\n", - dai_drv->dobj.type); + if (dai_drv->dobj.type && + dai_drv->dobj.type != SND_SOC_DOBJ_PCM) { + dev_err(dev, "Invalid dai type %d\n", dai_drv->dobj.type); return NULL; } + dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name); + lockdep_assert_held(&client_mutex); dai = soc_add_dai(component, dai_drv, legacy_dai_naming); if (!dai) @@ -2651,16 +2654,12 @@ static int snd_soc_register_dais(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, size_t count) { - struct device *dev = component->dev; struct snd_soc_dai *dai; unsigned int i; int ret; - dev_dbg(dev, "ASoC: dai register %s #%zu\n", dev_name(dev), count); - for (i = 0; i < count; i++) { - - dai = soc_add_dai(component, dai_drv + i, count == 1 && + dai = snd_soc_register_dai(component, dai_drv + i, count == 1 && !component->driver->non_legacy_dai_naming); if (dai == NULL) { ret = -ENOMEM;