[alsa-devel] [PATCH 19/21] ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais()

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Thu Oct 10 17:34:07 CEST 2019



On 10/8/19 11:31 PM, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx at 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 at 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;
> 


More information about the Alsa-devel mailing list