summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-devres.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-11-28 08:50:32 +0100
committerMark Brown <broonie@linaro.org>2013-11-28 13:35:36 +0000
commit21585ee848078b12d0d1a513e93936bf96b444a0 (patch)
treeb4183e84d23c2ee820192d8183ed6716a7a87c33 /sound/soc/soc-devres.c
parent6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff)
downloadop-kernel-dev-21585ee848078b12d0d1a513e93936bf96b444a0.zip
op-kernel-dev-21585ee848078b12d0d1a513e93936bf96b444a0.tar.gz
ASoC: Add resource managed snd_dmaengine_pcm_register()
For many drivers using the generic dmaengine PCM driver one of the few (or the only) things left to do in the drivers remove function is to unregister the PCM device. This patch adds a resource managed version of snd_dmaengine_pcm_register() which makes it possible to simplify the remove function as well as the error path in the probe function for those drivers. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-devres.c')
-rw-r--r--sound/soc/soc-devres.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index b1d7322..9998619 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <sound/soc.h>
+#include <sound/dmaengine_pcm.h>
static void devm_component_release(struct device *dev, void *res)
{
@@ -84,3 +85,43 @@ int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
return ret;
}
EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
+
+#ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
+
+static void devm_dmaengine_pcm_release(struct device *dev, void *res)
+{
+ snd_dmaengine_pcm_unregister(*(struct device **)res);
+}
+
+/**
+ * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
+ * @dev: The parent device for the PCM device
+ * @config: Platform specific PCM configuration
+ * @flags: Platform specific quirks
+ *
+ * Register a dmaengine based PCM device with automatic unregistration when the
+ * device is unregistered.
+ */
+int devm_snd_dmaengine_pcm_register(struct device *dev,
+ const struct snd_dmaengine_pcm_config *config, unsigned int flags)
+{
+ struct device **ptr;
+ int ret;
+
+ ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return -ENOMEM;
+
+ ret = snd_dmaengine_pcm_register(dev, config, flags);
+ if (ret == 0) {
+ *ptr = dev;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register);
+
+#endif
OpenPOWER on IntegriCloud