summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-03-28 04:26:30 +0200
committerMark Brown <broonie@kernel.org>2018-03-28 04:26:30 +0200
commit848272e9a38e78bf0c746774a93ed2ab0a5b7f13 (patch)
tree0292196307646ce82d3f152a715aa7fb87d05387 /sound/soc/soc-core.c
parentMerge remote-tracking branch 'asoc/topic/rt5665' into asoc-next (diff)
parentASoC: samsung: Use snd_soc_of_put_dai_link_codecs() in odroid.c (diff)
downloadlinux-848272e9a38e78bf0c746774a93ed2ab0a5b7f13.tar.xz
linux-848272e9a38e78bf0c746774a93ed2ab0a5b7f13.zip
Merge remote-tracking branch 'asoc/topic/samsung' into asoc-next
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2c32061af154..bf7ca32ab31f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4357,6 +4357,26 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
/*
+ * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array
+ * @dai_link: DAI link
+ *
+ * Dereference device nodes acquired by snd_soc_of_get_dai_link_codecs().
+ */
+void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link)
+{
+ struct snd_soc_dai_link_component *component = dai_link->codecs;
+ int index;
+
+ for (index = 0; index < dai_link->num_codecs; index++, component++) {
+ if (!component->of_node)
+ break;
+ of_node_put(component->of_node);
+ component->of_node = NULL;
+ }
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_put_dai_link_codecs);
+
+/*
* snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree
* @dev: Card device
* @of_node: Device node
@@ -4365,7 +4385,8 @@ EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
* Builds an array of CODEC DAI components from the DAI link property
* 'sound-dai'.
* The array is set in the DAI link and the number of DAIs is set accordingly.
- * The device nodes in the array (of_node) must be dereferenced by the caller.
+ * The device nodes in the array (of_node) must be dereferenced by calling
+ * snd_soc_of_put_dai_link_codecs() on @dai_link.
*
* Returns 0 for success
*/
@@ -4413,14 +4434,7 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
}
return 0;
err:
- for (index = 0, component = dai_link->codecs;
- index < dai_link->num_codecs;
- index++, component++) {
- if (!component->of_node)
- break;
- of_node_put(component->of_node);
- component->of_node = NULL;
- }
+ snd_soc_of_put_dai_link_codecs(dai_link);
dai_link->codecs = NULL;
dai_link->num_codecs = 0;
return ret;