aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-03-09 12:41:46 -0400
committerMark Brown <broonie@linaro.org>2014-03-10 08:17:54 -0400
commit6cc240f39d393c5878bc6cf053aa0fe8e3fe4260 (patch)
treefe7fc6e546906ffe2a67f62276f9b1beba848813
parent32c9ba544b65991b14ede102928c552ed24d4827 (diff)
ASoC: Pass CODEC to snd_soc_register_dais()
snd_soc_register_dais() looks up the CODEC that is registering the DAIs by looping over all registered CODECs. This patch updates the code to simply pass the CODEC that registers the DAIs to snd_soc_register_dais() thus avoiding the lookup. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/soc-core.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c365be98b0c3..cc522418e9c4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3933,17 +3933,18 @@ static void snd_soc_unregister_dais(struct snd_soc_component *component)
3933 * snd_soc_register_dais - Register a DAI with the ASoC core 3933 * snd_soc_register_dais - Register a DAI with the ASoC core
3934 * 3934 *
3935 * @component: The component the DAIs are registered for 3935 * @component: The component the DAIs are registered for
3936 * @codec: The CODEC that the DAIs are registered for, NULL if the component is
3937 * not a CODEC.
3936 * @dai_drv: DAI driver to use for the DAIs 3938 * @dai_drv: DAI driver to use for the DAIs
3937 * @count: Number of DAIs 3939 * @count: Number of DAIs
3938 * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the 3940 * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the
3939 * parent's name. 3941 * parent's name.
3940 */ 3942 */
3941static int snd_soc_register_dais(struct snd_soc_component *component, 3943static int snd_soc_register_dais(struct snd_soc_component *component,
3942 struct snd_soc_dai_driver *dai_drv, size_t count, 3944 struct snd_soc_codec *codec, struct snd_soc_dai_driver *dai_drv,
3943 bool legacy_dai_naming) 3945 size_t count, bool legacy_dai_naming)
3944{ 3946{
3945 struct device *dev = component->dev; 3947 struct device *dev = component->dev;
3946 struct snd_soc_codec *codec;
3947 struct snd_soc_dai *dai; 3948 struct snd_soc_dai *dai;
3948 unsigned int i; 3949 unsigned int i;
3949 int ret; 3950 int ret;
@@ -3982,28 +3983,19 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
3982 } 3983 }
3983 3984
3984 dai->component = component; 3985 dai->component = component;
3986 dai->codec = codec;
3985 dai->dev = dev; 3987 dai->dev = dev;
3986 dai->driver = &dai_drv[i]; 3988 dai->driver = &dai_drv[i];
3987 dai->dapm.dev = dev; 3989 dai->dapm.dev = dev;
3988 if (!dai->driver->ops) 3990 if (!dai->driver->ops)
3989 dai->driver->ops = &null_dai_ops; 3991 dai->driver->ops = &null_dai_ops;
3990 3992
3991 mutex_lock(&client_mutex);
3992
3993 list_for_each_entry(codec, &codec_list, list) {
3994 if (codec->dev == dev) {
3995 dev_dbg(dev, "ASoC: Mapped DAI %s to CODEC %s\n",
3996 dai->name, codec->name);
3997 dai->codec = codec;
3998 break;
3999 }
4000 }
4001 3993
4002 if (!dai->codec) 3994 if (!dai->codec)
4003 dai->dapm.idle_bias_off = 1; 3995 dai->dapm.idle_bias_off = 1;
4004 3996
3997 mutex_lock(&client_mutex);
4005 list_add(&dai->list, &dai_list); 3998 list_add(&dai->list, &dai_list);
4006
4007 mutex_unlock(&client_mutex); 3999 mutex_unlock(&client_mutex);
4008 4000
4009 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); 4001 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
@@ -4025,6 +4017,7 @@ static int
4025__snd_soc_register_component(struct device *dev, 4017__snd_soc_register_component(struct device *dev,
4026 struct snd_soc_component *cmpnt, 4018 struct snd_soc_component *cmpnt,
4027 const struct snd_soc_component_driver *cmpnt_drv, 4019 const struct snd_soc_component_driver *cmpnt_drv,
4020 struct snd_soc_codec *codec,
4028 struct snd_soc_dai_driver *dai_drv, 4021 struct snd_soc_dai_driver *dai_drv,
4029 int num_dai, bool allow_single_dai) 4022 int num_dai, bool allow_single_dai)
4030{ 4023{
@@ -4048,7 +4041,8 @@ __snd_soc_register_component(struct device *dev,
4048 cmpnt->dai_drv = dai_drv; 4041 cmpnt->dai_drv = dai_drv;
4049 cmpnt->num_dai = num_dai; 4042 cmpnt->num_dai = num_dai;
4050 4043
4051 ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, allow_single_dai); 4044 ret = snd_soc_register_dais(cmpnt, codec, dai_drv, num_dai,
4045 allow_single_dai);
4052 if (ret < 0) { 4046 if (ret < 0) {
4053 dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); 4047 dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
4054 goto error_component_name; 4048 goto error_component_name;
@@ -4083,7 +4077,7 @@ int snd_soc_register_component(struct device *dev,
4083 4077
4084 cmpnt->ignore_pmdown_time = true; 4078 cmpnt->ignore_pmdown_time = true;
4085 4079
4086 return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, 4080 return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL,
4087 dai_drv, num_dai, true); 4081 dai_drv, num_dai, true);
4088} 4082}
4089EXPORT_SYMBOL_GPL(snd_soc_register_component); 4083EXPORT_SYMBOL_GPL(snd_soc_register_component);
@@ -4304,7 +4298,7 @@ int snd_soc_register_codec(struct device *dev,
4304 /* register component */ 4298 /* register component */
4305 ret = __snd_soc_register_component(dev, &codec->component, 4299 ret = __snd_soc_register_component(dev, &codec->component,
4306 &codec_drv->component_driver, 4300 &codec_drv->component_driver,
4307 dai_drv, num_dai, false); 4301 codec, dai_drv, num_dai, false);
4308 if (ret < 0) { 4302 if (ret < 0) {
4309 dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret); 4303 dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret);
4310 goto fail_codec_name; 4304 goto fail_codec_name;