From: Mark Brown Date: Mon, 9 Apr 2012 16:29:19 +0000 (+0100) Subject: ASoC: core: Bind DAIs to CODECs at registration time X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=054880febeb890b24d705240384856ea6b3ccf7b;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ASoC: core: Bind DAIs to CODECs at registration time We should always have a CODEC already there when registering a CODEC DAI and for CODEC<->CODEC links a dai_link will have two CODECs so it's much simpler to do things at registration time. This results in a slight change in the error handling for failed CODEC DAI registrations but practically speaking these are never supposed to fail so there shouldn't be much issue. The change is that we don't fail the overall CODEC registration if the DAI registration fails; this seems more robust anyway as we may not need to use a given DAI in a particular system. Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9eefe9072dfa..0caa8d9e685f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1196,7 +1196,6 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order) card->name, num, order); /* config components */ - codec_dai->codec = codec; cpu_dai->platform = platform; codec_dai->card = card; cpu_dai->card = card; @@ -3227,6 +3226,7 @@ static inline char *fmt_multiple_name(struct device *dev, int snd_soc_register_dai(struct device *dev, struct snd_soc_dai_driver *dai_drv) { + struct snd_soc_codec *codec; struct snd_soc_dai *dai; dev_dbg(dev, "dai register %s\n", dev_name(dev)); @@ -3249,7 +3249,18 @@ int snd_soc_register_dai(struct device *dev, dai->driver->ops = &null_dai_ops; mutex_lock(&client_mutex); + + list_for_each_entry(codec, &codec_list, list) { + if (codec->dev == dev) { + dev_dbg(dev, "Mapped DAI %s to CODEC %s\n", + dai->name, codec->name); + dai->codec = codec; + break; + } + } + list_add(&dai->list, &dai_list); + mutex_unlock(&client_mutex); pr_debug("Registered DAI '%s'\n", dai->name); @@ -3293,6 +3304,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai); int snd_soc_register_dais(struct device *dev, struct snd_soc_dai_driver *dai_drv, size_t count) { + struct snd_soc_codec *codec; struct snd_soc_dai *dai; int i, ret = 0; @@ -3325,7 +3337,18 @@ int snd_soc_register_dais(struct device *dev, dai->driver->ops = &null_dai_ops; mutex_lock(&client_mutex); + + list_for_each_entry(codec, &codec_list, list) { + if (codec->dev == dev) { + dev_dbg(dev, "Mapped DAI %s to CODEC %s\n", + dai->name, codec->name); + dai->codec = codec; + break; + } + } + list_add(&dai->list, &dai_list); + mutex_unlock(&client_mutex); pr_debug("Registered DAI '%s'\n", dai->name); @@ -3537,17 +3560,18 @@ int snd_soc_register_codec(struct device *dev, fixup_codec_formats(&dai_drv[i].capture); } + mutex_lock(&client_mutex); + list_add(&codec->list, &codec_list); + mutex_unlock(&client_mutex); + /* register any DAIs */ if (num_dai) { ret = snd_soc_register_dais(dev, dai_drv, num_dai); if (ret < 0) - goto fail; + dev_err(codec->dev, "Failed to regster DAIs: %d\n", + ret); } - mutex_lock(&client_mutex); - list_add(&codec->list, &codec_list); - mutex_unlock(&client_mutex); - pr_debug("Registered codec '%s'\n", codec->name); return 0;