Merge branch 'for-2.6.29' into for-2.6.30
[deliverable/linux.git] / sound / soc / codecs / twl4030.c
index fd0f338374a7cfbea4fffacf624c3c148c63c6c9..f530c1e6d9e814955cfd380d82b5f9c3c5a9ee93 100644 (file)
@@ -125,6 +125,9 @@ static inline unsigned int twl4030_read_reg_cache(struct snd_soc_codec *codec,
 {
        u8 *cache = codec->reg_cache;
 
+       if (reg >= TWL4030_CACHEREGNUM)
+               return -EIO;
+
        return cache[reg];
 }
 
@@ -197,7 +200,7 @@ static const char *twl4030_earpiece_texts[] =
 static const unsigned int twl4030_earpiece_values[] =
                {0x0, 0x1, 0x2, 0x4};
 
-static const struct soc_value_enum twl4030_earpiece_enum =
+static const struct soc_enum twl4030_earpiece_enum =
        SOC_VALUE_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 0x7,
                        ARRAY_SIZE(twl4030_earpiece_texts),
                        twl4030_earpiece_texts,
@@ -213,7 +216,7 @@ static const char *twl4030_predrivel_texts[] =
 static const unsigned int twl4030_predrivel_values[] =
                {0x0, 0x1, 0x2, 0x4};
 
-static const struct soc_value_enum twl4030_predrivel_enum =
+static const struct soc_enum twl4030_predrivel_enum =
        SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 0x7,
                        ARRAY_SIZE(twl4030_predrivel_texts),
                        twl4030_predrivel_texts,
@@ -229,7 +232,7 @@ static const char *twl4030_predriver_texts[] =
 static const unsigned int twl4030_predriver_values[] =
                {0x0, 0x1, 0x2, 0x4};
 
-static const struct soc_value_enum twl4030_predriver_enum =
+static const struct soc_enum twl4030_predriver_enum =
        SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7,
                        ARRAY_SIZE(twl4030_predriver_texts),
                        twl4030_predriver_texts,
@@ -317,7 +320,7 @@ static const char *twl4030_analoglmic_texts[] =
 static const unsigned int twl4030_analoglmic_values[] =
                {0x0, 0x1, 0x2, 0x4, 0x8};
 
-static const struct soc_value_enum twl4030_analoglmic_enum =
+static const struct soc_enum twl4030_analoglmic_enum =
        SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf,
                        ARRAY_SIZE(twl4030_analoglmic_texts),
                        twl4030_analoglmic_texts,
@@ -333,7 +336,7 @@ static const char *twl4030_analogrmic_texts[] =
 static const unsigned int twl4030_analogrmic_values[] =
                {0x0, 0x1, 0x4};
 
-static const struct soc_value_enum twl4030_analogrmic_enum =
+static const struct soc_enum twl4030_analogrmic_enum =
        SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5,
                        ARRAY_SIZE(twl4030_analogrmic_texts),
                        twl4030_analogrmic_texts,
@@ -670,22 +673,6 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = {
                0, 3, 5, 0, input_gain_tlv),
 };
 
-/* add non dapm controls */
-static int twl4030_add_controls(struct snd_soc_codec *codec)
-{
-       int err, i;
-
-       for (i = 0; i < ARRAY_SIZE(twl4030_snd_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                                 snd_soc_cnew(&twl4030_snd_controls[i],
-                                               codec, NULL));
-               if (err < 0)
-                       return err;
-       }
-
-       return 0;
-}
-
 static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
        /* Left channel inputs */
        SND_SOC_DAPM_INPUT("MAINMIC"),
@@ -1233,7 +1220,8 @@ static int twl4030_init(struct snd_soc_device *socdev)
        /* power on device */
        twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       twl4030_add_controls(codec);
+       snd_soc_add_controls(codec, twl4030_snd_controls,
+                               ARRAY_SIZE(twl4030_snd_controls));
        twl4030_add_widgets(codec);
 
        ret = snd_soc_init_card(socdev);
@@ -1280,6 +1268,8 @@ static int twl4030_remove(struct platform_device *pdev)
        struct snd_soc_codec *codec = socdev->codec;
 
        printk(KERN_INFO "TWL4030 Audio Codec remove\n");
+       snd_soc_free_pcms(socdev);
+       snd_soc_dapm_free(socdev);
        kfree(codec);
 
        return 0;
This page took 0.029554 seconds and 5 git commands to generate.