include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / sound / soc / codecs / ad1980.c
index 73fdbb4..0420727 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
@@ -93,20 +94,6 @@ SOC_ENUM("Capture Source", ad1980_cap_src),
 SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0),
 };
 
-/* add non dapm controls */
-static int ad1980_add_controls(struct snd_soc_codec *codec)
-{
-       int err, i;
-
-       for (i = 0; i < ARRAY_SIZE(ad1980_snd_ac97_controls); i++) {
-               err = snd_ctl_add(codec->card, snd_soc_cnew(
-                               &ad1980_snd_ac97_controls[i], codec, NULL));
-               if (err < 0)
-                       return err;
-       }
-       return 0;
-}
-
 static unsigned int ac97_read(struct snd_soc_codec *codec,
        unsigned int reg)
 {
@@ -123,7 +110,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec,
        default:
                reg = reg >> 1;
 
-               if (reg >= (ARRAY_SIZE(ad1980_reg)))
+               if (reg >= ARRAY_SIZE(ad1980_reg))
                        return -EINVAL;
 
                return cache[reg];
@@ -137,7 +124,7 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
 
        soc_ac97_ops.write(codec->ac97, reg, val);
        reg = reg >> 1;
-       if (reg < (ARRAY_SIZE(ad1980_reg)))
+       if (reg < ARRAY_SIZE(ad1980_reg))
                cache[reg] = val;
 
        return 0;
@@ -151,13 +138,13 @@ struct snd_soc_dai ad1980_dai = {
                .channels_min = 2,
                .channels_max = 6,
                .rates = SNDRV_PCM_RATE_48000,
-               .formats = SNDRV_PCM_FMTBIT_S16_LE, },
+               .formats = SND_SOC_STD_AC97_FMTS, },
        .capture = {
                .stream_name = "Capture",
                .channels_min = 2,
                .channels_max = 2,
                .rates = SNDRV_PCM_RATE_48000,
-               .formats = SNDRV_PCM_FMTBIT_S16_LE, },
+               .formats = SND_SOC_STD_AC97_FMTS, },
 };
 EXPORT_SYMBOL_GPL(ad1980_dai);
 
@@ -200,10 +187,10 @@ static int ad1980_soc_probe(struct platform_device *pdev)
 
        printk(KERN_INFO "AD1980 SoC Audio Codec\n");
 
-       socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
-       if (socdev->codec == NULL)
+       socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
+       if (socdev->card->codec == NULL)
                return -ENOMEM;
-       codec = socdev->codec;
+       codec = socdev->card->codec;
        mutex_init(&codec->mutex);
 
        codec->reg_cache =
@@ -269,12 +256,8 @@ static int ad1980_soc_probe(struct platform_device *pdev)
        ext_status = ac97_read(codec, AC97_EXTENDED_STATUS);
        ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800);
 
-       ad1980_add_controls(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "ad1980: failed to register card\n");
-               goto reset_err;
-       }
+       snd_soc_add_controls(codec, ad1980_snd_ac97_controls,
+                               ARRAY_SIZE(ad1980_snd_ac97_controls));
 
        return 0;
 
@@ -288,15 +271,15 @@ codec_err:
        kfree(codec->reg_cache);
 
 cache_err:
-       kfree(socdev->codec);
-       socdev->codec = NULL;
+       kfree(socdev->card->codec);
+       socdev->card->codec = NULL;
        return ret;
 }
 
 static int ad1980_soc_remove(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
 
        if (codec == NULL)
                return 0;