summaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/omap-mcbsp.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-02-14 14:52:42 +0200
committerLiam Girdwood <lrg@ti.com>2012-03-12 13:34:21 +0000
commit2ee6595069f29b918b957a013debfae83e68724d (patch)
treee3f32aa8b786fdb9c97a4cdf38b892ec021877ea /sound/soc/omap/omap-mcbsp.c
parentcb40b63a224b41325a8ecdbeed5290866864b9ae (diff)
downloadlinux-2ee6595069f29b918b957a013debfae83e68724d.tar.bz2
ASoC: omap-mcbsp: Cleanup of module probe/remove code
Use devm_* where it is possible to save on cleanup path. Start merging the two mcbsp file content. Move pm_runtime_enable/disable calls to ASoC probe, remove from module probe/remove time. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Grazvydas Ignotas <notasas@gmail.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Signed-off-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/omap/omap-mcbsp.c')
-rw-r--r--sound/soc/omap/omap-mcbsp.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 9c703f18714c..69a44aa4eeae 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -25,6 +25,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
+#include <linux/pm_runtime.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -603,7 +604,27 @@ static const struct snd_soc_dai_ops mcbsp_dai_ops = {
.set_sysclk = omap_mcbsp_dai_set_dai_sysclk,
};
+static int omap_mcbsp_probe(struct snd_soc_dai *dai)
+{
+ struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(dai);
+
+ pm_runtime_enable(mcbsp->dev);
+
+ return 0;
+}
+
+static int omap_mcbsp_remove(struct snd_soc_dai *dai)
+{
+ struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(dai);
+
+ pm_runtime_disable(mcbsp->dev);
+
+ return 0;
+}
+
static struct snd_soc_dai_driver omap_mcbsp_dai = {
+ .probe = omap_mcbsp_probe,
+ .remove = omap_mcbsp_remove,
.playback = {
.channels_min = 1,
.channels_max = 16,
@@ -756,9 +777,24 @@ EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
static __devinit int asoc_mcbsp_probe(struct platform_device *pdev)
{
+ struct omap_mcbsp_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ struct omap_mcbsp *mcbsp;
int ret;
- ret = omap_mcbsp_probe(pdev);
+ if (!pdata) {
+ dev_err(&pdev->dev, "missing platform data.\n");
+ return -EINVAL;
+ }
+ mcbsp = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcbsp), GFP_KERNEL);
+ if (!mcbsp)
+ return -ENOMEM;
+
+ mcbsp->id = pdev->id;
+ mcbsp->pdata = pdata;
+ mcbsp->dev = &pdev->dev;
+ platform_set_drvdata(pdev, mcbsp);
+
+ ret = omap_mcbsp_init(pdev);
if (!ret)
return snd_soc_register_dai(&pdev->dev, &omap_mcbsp_dai);
@@ -767,8 +803,19 @@ static __devinit int asoc_mcbsp_probe(struct platform_device *pdev)
static int __devexit asoc_mcbsp_remove(struct platform_device *pdev)
{
- omap_mcbsp_remove(pdev);
+ struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
+
snd_soc_unregister_dai(&pdev->dev);
+
+ if (mcbsp->pdata->ops && mcbsp->pdata->ops->free)
+ mcbsp->pdata->ops->free(mcbsp->id);
+
+ omap_mcbsp_sysfs_remove(mcbsp);
+
+ clk_put(mcbsp->fclk);
+
+ platform_set_drvdata(pdev, NULL);
+
return 0;
}