alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>, Simon <horms@verge.net.au>,
	Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>
Subject: Re: [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name()
Date: Wed, 16 Oct 2013 11:09:20 +0200	[thread overview]
Message-ID: <525E57C0.6000508@metafoo.de> (raw)
In-Reply-To: <87li1vdx9y.wl%kuninori.morimoto.gx@renesas.com>

On 10/15/2013 05:32 AM, Kuninori Morimoto wrote:
> Current snd_soc_of_get_dai_name() needs .of_xlate_dai_name()
> callback on each component drivers.
> But required behavior on almost all these drivers is
> just returns its indexed dai driver's name.
> 
> This patch adds this feature as default behavior.
> .of_xlate_dai_name() can overwrite it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

I'm not exactly sure if adding the dai_drv field to the component struct is
the right approach. But it doesn't look to intrusive and could be removed
again at some point, if it turns out there is a better way to do this.

[...]
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 711bd36..51ea2c3 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -4048,6 +4048,7 @@ __snd_soc_register_component(struct device *dev,
>  
>  	cmpnt->dev	= dev;
>  	cmpnt->driver	= cmpnt_drv;
> +	cmpnt->dai_drv	= dai_drv;
>  	cmpnt->num_dai	= num_dai;
>  
>  	/*
> @@ -4609,12 +4610,19 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
>  		if (pos->dev->of_node != args.np)
>  			continue;
>  
> -		if (!pos->driver->of_xlate_dai_name) {
> -			ret = -ENOSYS;
> -			break;
> +		if (pos->driver->of_xlate_dai_name) {
> +			ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
> +		} else {
> +			int id = args.args[0];

You should check that args.args_count is 1. And maybe also allow args_count
to be 0 if the number of DAIs is 1.

> +
> +			if (id < 0 || id >= pos->num_dai) {
> +				ret = -EINVAL;
> +			} else {
> +				*dai_name = pos->dai_drv[id].name;
> +				ret = 0;
> +			}
>  		}
>  
> -		ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
>  		break;
>  	}
>  	mutex_unlock(&client_mutex);
> 

  reply	other threads:[~2013-10-16  9:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15  3:32 [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name() Kuninori Morimoto
2013-10-16  9:09 ` Lars-Peter Clausen [this message]
2013-10-17  3:12   ` Kuninori Morimoto
2013-10-17  5:05     ` [PATCH v2] ASoC: add snd_soc_of_get_dai_name() default of_xlate Kuninori Morimoto
2013-10-17 23:43       ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=525E57C0.6000508@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=kuninori.morimoto.gx@gmail.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).