diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2013-10-16 22:05:26 -0700 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-18 00:43:32 +0100 |
commit | 6833c452c2fb47353566aa705d68541c6045c796 (patch) | |
tree | e729fe7bf43a71b506b8545370682871f9ac06d4 /sound/soc/soc-core.c | |
parent | 7cc302d231aae87a08909ae40cdf36dfe7bb5102 (diff) | |
download | op-kernel-dev-6833c452c2fb47353566aa705d68541c6045c796.zip op-kernel-dev-6833c452c2fb47353566aa705d68541c6045c796.tar.gz |
ASoC: add snd_soc_of_get_dai_name() default of_xlate
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 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>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 67cfb5f..0860a7f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4023,6 +4023,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; /* @@ -4548,12 +4549,31 @@ 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 = -1; + + switch (args.args_count) { + case 0: + id = 0; /* same as dai_drv[0] */ + break; + case 1: + id = args.args[0]; + break; + default: + /* not supported */ + break; + } + + 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); |