ASoC: phycore-ac97: fix resource leak
[pandora-kernel.git] / sound / soc / imx / phycore-ac97.c
index a8307d5..9eabc28 100644 (file)
@@ -20,9 +20,6 @@
 #include <sound/soc-dapm.h>
 #include <asm/mach-types.h>
 
-#include "../codecs/wm9712.h"
-#include "imx-ssi.h"
-
 static struct snd_soc_card imx_phycore;
 
 static struct snd_soc_ops imx_phycore_hifi_ops = {
@@ -32,23 +29,21 @@ static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
        {
                .name           = "HiFi",
                .stream_name    = "HiFi",
-               .codec_dai      = &wm9712_dai[WM9712_DAI_AC97_HIFI],
+               .codec_dai_name         = "wm9712-hifi",
+               .codec_name     = "wm9712-codec",
+               .cpu_dai_name   = "imx-ssi.0",
+               .platform_name  = "imx-fiq-pcm-audio.0",
                .ops            = &imx_phycore_hifi_ops,
        },
 };
 
 static struct snd_soc_card imx_phycore = {
-       .name           = "PhyCORE-audio",
-       .platform       = &imx_soc_platform,
+       .name           = "PhyCORE-ac97-audio",
        .dai_link       = imx_phycore_dai_ac97,
        .num_links      = ARRAY_SIZE(imx_phycore_dai_ac97),
 };
 
-static struct snd_soc_device imx_phycore_snd_devdata = {
-       .card           = &imx_phycore,
-       .codec_dev      = &soc_codec_dev_wm9712,
-};
-
+static struct platform_device *imx_phycore_snd_ac97_device;
 static struct platform_device *imx_phycore_snd_device;
 
 static int __init imx_phycore_init(void)
@@ -59,27 +54,42 @@ static int __init imx_phycore_init(void)
                /* return happy. We might run on a totally different machine */
                return 0;
 
-       imx_phycore_snd_device = platform_device_alloc("soc-audio", -1);
-       if (!imx_phycore_snd_device)
+       imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
+       if (!imx_phycore_snd_ac97_device)
                return -ENOMEM;
 
-       imx_phycore_dai_ac97[0].cpu_dai = &imx_ssi_pcm_dai[0];
+       platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
+       ret = platform_device_add(imx_phycore_snd_ac97_device);
+       if (ret)
+               goto fail1;
 
-       platform_set_drvdata(imx_phycore_snd_device, &imx_phycore_snd_devdata);
-       imx_phycore_snd_devdata.dev = &imx_phycore_snd_device->dev;
+       imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
+       if (!imx_phycore_snd_device) {
+               ret = -ENOMEM;
+               goto fail2;
+       }
        ret = platform_device_add(imx_phycore_snd_device);
 
        if (ret) {
                printk(KERN_ERR "ASoC: Platform device allocation failed\n");
-               platform_device_put(imx_phycore_snd_device);
+               goto fail3;
        }
 
+       return 0;
+
+fail3:
+       platform_device_put(imx_phycore_snd_device);
+fail2:
+       platform_device_del(imx_phycore_snd_ac97_device);
+fail1:
+       platform_device_put(imx_phycore_snd_ac97_device);
        return ret;
 }
 
 static void __exit imx_phycore_exit(void)
 {
        platform_device_unregister(imx_phycore_snd_device);
+       platform_device_unregister(imx_phycore_snd_ac97_device);
 }
 
 late_initcall(imx_phycore_init);