ASoC: Factor out snd_soc_init_card()
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 3 Nov 2009 22:13:13 +0000 (22:13 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 3 Nov 2009 22:14:43 +0000 (22:14 +0000)
snd_soc_init_card() is always called as the last part of the CODEC probe
function so we can factor it out into the core card setup rather than
have each CODEC replicate the code to do the initialiastation. This will
be required to support multiple CODECs per card.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
49 files changed:
include/sound/soc.h
sound/soc/codecs/ac97.c
sound/soc/codecs/ad1836.c
sound/soc/codecs/ad1938.c
sound/soc/codecs/ad1980.c
sound/soc/codecs/ad73311.c
sound/soc/codecs/ak4104.c
sound/soc/codecs/ak4535.c
sound/soc/codecs/ak4642.c
sound/soc/codecs/ak4671.c
sound/soc/codecs/cs4270.c
sound/soc/codecs/cx20442.c
sound/soc/codecs/pcm3008.c
sound/soc/codecs/ssm2602.c
sound/soc/codecs/stac9766.c
sound/soc/codecs/tlv320aic23.c
sound/soc/codecs/tlv320aic26.c
sound/soc/codecs/tlv320aic3x.c
sound/soc/codecs/tlv320dac33.c
sound/soc/codecs/twl4030.c
sound/soc/codecs/uda134x.c
sound/soc/codecs/uda1380.c
sound/soc/codecs/wm8350.c
sound/soc/codecs/wm8400.c
sound/soc/codecs/wm8510.c
sound/soc/codecs/wm8523.c
sound/soc/codecs/wm8580.c
sound/soc/codecs/wm8711.c
sound/soc/codecs/wm8727.c
sound/soc/codecs/wm8728.c
sound/soc/codecs/wm8731.c
sound/soc/codecs/wm8750.c
sound/soc/codecs/wm8753.c
sound/soc/codecs/wm8776.c
sound/soc/codecs/wm8900.c
sound/soc/codecs/wm8903.c
sound/soc/codecs/wm8940.c
sound/soc/codecs/wm8960.c
sound/soc/codecs/wm8961.c
sound/soc/codecs/wm8971.c
sound/soc/codecs/wm8974.c
sound/soc/codecs/wm8988.c
sound/soc/codecs/wm8990.c
sound/soc/codecs/wm8993.c
sound/soc/codecs/wm9081.c
sound/soc/codecs/wm9705.c
sound/soc/codecs/wm9712.c
sound/soc/codecs/wm9713.c
sound/soc/soc-core.c

index b1245e3acdfcc121bd9047dd2659a084a8e1b6fd..7f3a4c5028daf9b89f5942f1a2506ef8f0455aa6 100644 (file)
@@ -226,7 +226,6 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
 /* pcm <-> DAI connect */
 void snd_soc_free_pcms(struct snd_soc_device *socdev);
 int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
-int snd_soc_init_card(struct snd_soc_device *socdev);
 
 /* set runtime hw params */
 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
index 932299bb5d1e006a7f0108bd7d7ab0000b3969bc..69bd0acc81c8c45a26adc0cc99d2c32f2289e21a 100644 (file)
@@ -117,9 +117,6 @@ static int ac97_soc_probe(struct platform_device *pdev)
        if (ret < 0)
                goto bus_err;
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0)
-               goto bus_err;
        return 0;
 
 bus_err:
index c48485f2c55db3632f2ae18f412a7ab341b13316..2e360c2430759a476ba0b5e1e6b0848665742952 100644 (file)
@@ -387,12 +387,6 @@ static int ad1836_probe(struct platform_device *pdev)
        snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
        snd_soc_dapm_new_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        return ret;
 
 card_err:
index 34b30efc3cb009977ff7cb30ab413412eda275e0..09c008ad147603c02c0d70e0cdba1868bb0a78c4 100644 (file)
@@ -596,12 +596,6 @@ static int ad1938_probe(struct platform_device *pdev)
 
        ad1938_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        return ret;
 
 card_err:
index d7440a982d22794928940c3590cde1765fe56d9a..39c0f7584e656ab78f71d6d70e28abac9ec6d131 100644 (file)
@@ -257,11 +257,6 @@ static int ad1980_soc_probe(struct platform_device *pdev)
 
        snd_soc_add_controls(codec, ad1980_snd_ac97_controls,
                                ARRAY_SIZE(ad1980_snd_ac97_controls));
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "ad1980: failed to register card\n");
-               goto reset_err;
-       }
 
        return 0;
 
index e61dac5e7b8fadac8b04c1e554af3fbd1f793e64..d2fcc601722c17b23d24d144a502009063d7d728 100644 (file)
@@ -64,16 +64,8 @@ static int ad73311_soc_probe(struct platform_device *pdev)
                goto pcm_err;
        }
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "ad73311: failed to register card\n");
-               goto register_err;
-       }
-
        return ret;
 
-register_err:
-       snd_soc_free_pcms(socdev);
 pcm_err:
        kfree(socdev->card->codec);
        socdev->card->codec = NULL;
index 4d47bc4f74284764ec24434167371d3245009df8..3a14c6fc4f5ee45ece90bbf092bf4ba9e30cfc09 100644 (file)
@@ -313,14 +313,6 @@ static int ak4104_probe(struct platform_device *pdev)
                return ret;
        }
 
-       /* Register the socdev */
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card\n");
-               snd_soc_free_pcms(socdev);
-               return ret;
-       }
-
        return 0;
 }
 
index 0abec0d29a964ec457e65e7f618feb4dd6bacd72..57a6846a9a1f724cfd18bc567b1704c49a173277 100644 (file)
@@ -485,17 +485,9 @@ static int ak4535_init(struct snd_soc_device *socdev)
        snd_soc_add_controls(codec, ak4535_snd_controls,
                                ARRAY_SIZE(ak4535_snd_controls));
        ak4535_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "ak4535: failed to register card\n");
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        kfree(codec->reg_cache);
 
index e057c7b578df980067e129827da14011551f8fe0..b69861d521610d9c4ba16ec7e4d8542202e798fc 100644 (file)
@@ -442,18 +442,9 @@ static int ak4642_probe(struct platform_device *pdev)
                goto pcm_err;
        }
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "ak4642: failed to register card\n");
-               goto card_err;
-       }
-
        dev_info(&pdev->dev, "AK4642 Audio Codec %s", AK4642_VERSION);
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 
index b61214d1c5de9a63ab3f5efcff318e68f4cf3e52..364832ccd7483705414494530736d9faa6bd08d8 100644 (file)
@@ -662,19 +662,10 @@ static int ak4671_probe(struct platform_device *pdev)
                             ARRAY_SIZE(ak4671_snd_controls));
        ak4671_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        ak4671_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index 565842dcfc652774d970e6eb78bd3d2e90d52b1f..ffe122d1cd76af149d510fe3c80fff4380922bbd 100644 (file)
@@ -599,13 +599,6 @@ static int cs4270_probe(struct platform_device *pdev)
                goto error_free_pcms;
        }
 
-       /* And finally, register the socdev */
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card\n");
-               goto error_free_pcms;
-       }
-
        return 0;
 
 error_free_pcms:
index 38eac9c866e1627a60350d9e9e3a0cc78d28a664..d7f9bf18b72eab6cac1702c99dcc04b8d8c7183f 100644 (file)
@@ -355,12 +355,6 @@ static int cx20442_codec_probe(struct platform_device *pdev)
 
        cx20442_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "failed to register card\n");
-               goto card_err;
-       }
-
        return ret;
 
 card_err:
index 5cda9e6b5a74ae5a468f7a8e2eb9ccac6274fb13..2afcd0a8669d308a1ab658cbbfa7f823961fdf8a 100644 (file)
@@ -90,13 +90,6 @@ static int pcm3008_soc_probe(struct platform_device *pdev)
                goto pcm_err;
        }
 
-       /* Register Card. */
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "pcm3008: failed to register card\n");
-               goto card_err;
-       }
-
        /* DEM1  DEM0  DE-EMPHASIS_MODE
         * Low   Low   De-emphasis 44.1 kHz ON
         * Low   High  De-emphasis OFF
@@ -136,8 +129,6 @@ static int pcm3008_soc_probe(struct platform_device *pdev)
 
 gpio_err:
        pcm3008_gpio_free(setup);
-card_err:
-       snd_soc_free_pcms(socdev);
 pcm_err:
        kfree(socdev->card->codec);
 
index c550750c79c0654db16d480e4abee954cc71e09f..b3130339d29a64ad8ebc07006a10787b3d261fc5 100644 (file)
@@ -613,17 +613,9 @@ static int ssm2602_init(struct snd_soc_device *socdev)
        snd_soc_add_controls(codec, ssm2602_snd_controls,
                                ARRAY_SIZE(ssm2602_snd_controls));
        ssm2602_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               pr_err("ssm2602: failed to register card\n");
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        kfree(codec->reg_cache);
        return ret;
index befc6488c39a54f27cb9d9b27e7a4ca1b7451bd7..bbc72c2ddfca0292f536638cfd62dc278610b045 100644 (file)
@@ -418,9 +418,6 @@ static int stac9766_codec_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, stac9766_snd_ac97_controls,
                             ARRAY_SIZE(stac9766_snd_ac97_controls));
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0)
-               goto reset_err;
        return 0;
 
 reset_err:
index 0b8dcb5cd729281bfd80264acdb5a58b9025636e..ee8cb2c08b87c2911a82fca3cabccc149e103691 100644 (file)
@@ -707,17 +707,9 @@ static int tlv320aic23_init(struct snd_soc_device *socdev)
        snd_soc_add_controls(codec, tlv320aic23_snd_controls,
                                ARRAY_SIZE(tlv320aic23_snd_controls));
        tlv320aic23_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "tlv320aic23: failed to register card\n");
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        kfree(codec->reg_cache);
        return ret;
index 3387d9e736ea23e23e075e0e1a7409c8deebaeab..357b609196e35aecf223be365a383591bec5cd7a 100644 (file)
@@ -356,18 +356,7 @@ static int aic26_probe(struct platform_device *pdev)
                        ARRAY_SIZE(aic26_snd_controls));
        WARN_ON(err < 0);
 
-       /* CODEC is setup, we can register the card now */
-       dev_dbg(&pdev->dev, "Registering card\n");
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "aic26: failed to register card\n");
-               goto card_err;
-       }
        return 0;
-
- card_err:
-       snd_soc_free_pcms(socdev);
-       return ret;
 }
 
 static int aic26_remove(struct platform_device *pdev)
index 3395cf945d565b694dc1849a32027b48802c1e99..03cad250f58db3fc5e47342d3e30cb7a9645ea77 100644 (file)
@@ -1405,18 +1405,8 @@ static int aic3x_probe(struct platform_device *pdev)
 
        aic3x_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "aic3x: failed to register card\n");
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
-
 pcm_err:
        kfree(codec->reg_cache);
        return ret;
index 3ca8934fc26c81f872f409128c39e7651bdc8005..bff476d65d05da4c909d1bdbb6c352cb609cfe38 100644 (file)
@@ -960,16 +960,8 @@ static int dac33_soc_probe(struct platform_device *pdev)
        /* power on device */
        dac33_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card\n");
-               goto card_err;
-       }
-
        return 0;
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
+
 pcm_err:
        dac33_hard_power(codec, 0);
        return ret;
index c0b47dfc3328878a3563e5ddcebf3b7bb4fcd90a..928257b25111f2711adb4e997eb25be493359436 100644 (file)
@@ -2155,19 +2155,7 @@ static int twl4030_soc_probe(struct platform_device *pdev)
                                ARRAY_SIZE(twl4030_snd_controls));
        twl4030_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "failed to register card\n");
-               goto card_err;
-       }
-
        return 0;
-
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
-
-       return ret;
 }
 
 static int twl4030_soc_remove(struct platform_device *pdev)
index c33b92edbded03774fc1cc16bfb7f1bda82414dd..aa40d985138fafd4893fa09f47a003c7c975f393 100644 (file)
@@ -562,17 +562,8 @@ static int uda134x_soc_probe(struct platform_device *pdev)
                goto pcm_err;
        }
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "UDA134X: failed to register card\n");
-               goto card_err;
-       }
-
        return 0;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        kfree(codec->reg_cache);
 reg_err:
index 92ec034421543e06f494b7c5075cc3a8767f2a95..a42e47d94630370336d2639647169eb82a5ddac6 100644 (file)
@@ -713,17 +713,9 @@ static int uda1380_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, uda1380_snd_controls,
                                ARRAY_SIZE(uda1380_snd_controls));
        uda1380_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index 714114b50d1808107ceb6c17bd8f461df1e78e0c..2e35a354b166e870e799fd891f8ff4f7b6cbd523 100644 (file)
@@ -1501,18 +1501,7 @@ static int wm8350_probe(struct platform_device *pdev)
 
        wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "failed to register card\n");
-               goto card_err;
-       }
-
        return 0;
-
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
-       return ret;
 }
 
 static int wm8350_remove(struct platform_device *pdev)
index bd7eecba20fe834542acbbddf3db54a648dd6e25..0e30997c8db06d3e295413a486dfbeb597abfcbe 100644 (file)
@@ -1400,12 +1400,6 @@ static int wm8400_probe(struct platform_device *pdev)
        wm8400_add_controls(codec);
        wm8400_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "failed to register card\n");
-               goto card_err;
-       }
-
        return ret;
 
 card_err:
index 5702435af81b41ce2169446bb4ccf1ad63591e83..e3c21ebcc08ea1bc66226312c75d7e95be6e3173 100644 (file)
@@ -604,16 +604,9 @@ static int wm8510_init(struct snd_soc_device *socdev,
        snd_soc_add_controls(codec, wm8510_snd_controls,
                                ARRAY_SIZE(wm8510_snd_controls));
        wm8510_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8510: failed to register card\n");
-               goto card_err;
-       }
+
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 err:
        kfree(codec->reg_cache);
        return ret;
index 268cab21c2cc493fd8feeaeb68def4c80f4e934a..2e2b01d6c82b65a786209a7b1dbb24e8ae3637d2 100644 (file)
@@ -448,17 +448,9 @@ static int wm8523_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8523_snd_controls,
                             ARRAY_SIZE(wm8523_snd_controls));
        wm8523_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index a09b23e03664d4425ce67a782568d18770ffdc8a..dde50d118181f47a79a400e5e96b2c4c58018f3d 100644 (file)
@@ -800,17 +800,9 @@ static int wm8580_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8580_snd_controls,
                             ARRAY_SIZE(wm8580_snd_controls));
        wm8580_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index 54189fbf9e935912411c804cb4af200743ac36f4..70e0675b5d4a073bda3f10621400d40376bfc0af 100644 (file)
@@ -404,17 +404,9 @@ static int wm8711_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8711_snd_controls,
                             ARRAY_SIZE(wm8711_snd_controls));
        wm8711_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index 7df5a17eb733ef009b9688882b22d3489a5aa11f..d8ffbd641d717d2e74ff38b134b5030338bd664f 100644 (file)
@@ -68,17 +68,9 @@ static int wm8727_soc_probe(struct platform_device *pdev)
                printk(KERN_ERR "wm8727: failed to create pcms\n");
                goto pcm_err;
        }
-       /* register card */
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8727: failed to register card\n");
-               goto register_err;
-       }
 
        return ret;
 
-register_err:
-       snd_soc_free_pcms(socdev);
 pcm_err:
        kfree(socdev->card->codec);
        socdev->card->codec = NULL;
index 16e969a762c3934bd9af11b5e240a0f5aa1f0b75..1252a8a486a6250a7949bec0165fc7d81cedb7be 100644 (file)
@@ -287,17 +287,9 @@ static int wm8728_init(struct snd_soc_device *socdev,
        snd_soc_add_controls(codec, wm8728_snd_controls,
                                ARRAY_SIZE(wm8728_snd_controls));
        wm8728_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8728: failed to register card\n");
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 err:
        kfree(codec->reg_cache);
        return ret;
index bb95af95097141c20705572e1e176117df10ccc3..e3675e7a9813707786563c956763ae78340c512d 100644 (file)
@@ -495,17 +495,9 @@ static int wm8731_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8731_snd_controls,
                             ARRAY_SIZE(wm8731_snd_controls));
        wm8731_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index 4ba1e7e93fb4dbfc99cb28e04e7baa82318102f3..50a3d6590588c32f64363893cd213a230d6f2441 100644 (file)
@@ -772,16 +772,8 @@ static int wm8750_init(struct snd_soc_device *socdev,
        snd_soc_add_controls(codec, wm8750_snd_controls,
                                ARRAY_SIZE(wm8750_snd_controls));
        wm8750_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8750: failed to register card\n");
-               goto card_err;
-       }
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 err:
        kfree(codec->reg_cache);
        return ret;
index 8f7305257d292c0d066c50ea0836bd3e70ac48dc..c652bc04cc8133fed3beed13ba5d880b670bb4bf 100644 (file)
@@ -1583,18 +1583,9 @@ static int wm8753_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8753_snd_controls,
                             ARRAY_SIZE(wm8753_snd_controls));
        wm8753_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8753: failed to register card\n");
-               goto card_err;
-       }
 
        return 0;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
-
 pcm_err:
        return ret;
 }
index a0bbb28eed75239841b0e3a0aef8cdb6934fb0d7..ab2c0da1809102396cc357ca78be1d3946a356a2 100644 (file)
@@ -447,17 +447,8 @@ static int wm8776_probe(struct platform_device *pdev)
                                  ARRAY_SIZE(wm8776_dapm_widgets));
        snd_soc_dapm_add_routes(codec, routes, ARRAY_SIZE(routes));
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index b48804b5cacd951214d538f982394a417f04f43d..0d185cb6418d8ed21b53892b3674c50d73d5c5d7 100644 (file)
@@ -1353,12 +1353,6 @@ static int wm8900_probe(struct platform_device *pdev)
                                ARRAY_SIZE(wm8900_snd_controls));
        wm8900_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "Failed to register card\n");
-               goto card_err;
-       }
-
        return ret;
 
 card_err:
index 94cdb813041513f8ddc61ba8da1e09854761fb8a..bfeff4ee5de9a70811e383598b409d3e087abc7c 100644 (file)
@@ -1695,17 +1695,8 @@ static int wm8903_probe(struct platform_device *pdev)
                                ARRAY_SIZE(wm8903_snd_controls));
        wm8903_add_widgets(socdev->card->codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "wm8903: failed to register card\n");
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 err:
        return ret;
 }
index 8d4fd3c08c09e83342c6773a18af767d4f93bbf6..fc80aa6c913c21e547cbaf817744ab11fec768f9 100644 (file)
@@ -731,12 +731,6 @@ static int wm8940_probe(struct platform_device *pdev)
        if (ret)
                goto error_free_pcms;
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto error_free_pcms;
-       }
-
        return ret;
 
 error_free_pcms:
index b9b096a85396e2acc943fa0a9b07f205572e91bf..40390afa75f3ee8ed24cadf5d0ed193bf3be750d 100644 (file)
@@ -713,17 +713,9 @@ static int wm8960_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8960_snd_controls,
                             ARRAY_SIZE(wm8960_snd_controls));
        wm8960_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index b5c6f2cd5ae214b12934c1e300debdd9117b1bdb..07e389574db18ebdba5c27e152032946082115a3 100644 (file)
@@ -988,17 +988,8 @@ static int wm8961_probe(struct platform_device *pdev)
        snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
        snd_soc_dapm_new_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index d66efb0546eadf3846aa81adaff2003bd8675dcf..56a66e89ab91e80738384031ae5e01ed7afc5561 100644 (file)
@@ -703,16 +703,9 @@ static int wm8971_init(struct snd_soc_device *socdev,
        snd_soc_add_controls(codec, wm8971_snd_controls,
                                ARRAY_SIZE(wm8971_snd_controls));
        wm8971_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8971: failed to register card\n");
-               goto card_err;
-       }
+
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 err:
        kfree(codec->reg_cache);
        return ret;
index eff29331235bb3b210f8249c76866e758690e962..c245f0ee0ec2d05f6709c18a5859d1d6513c281b 100644 (file)
@@ -641,17 +641,9 @@ static int wm8974_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm8974_snd_controls,
                             ARRAY_SIZE(wm8974_snd_controls));
        wm8974_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index d8d8f68b81eaa05676642ace1f8f88aeb46038e0..bee292e37d1b6cc4bf9d8bfbcad5219eb82b61e0 100644 (file)
@@ -792,17 +792,8 @@ static int wm8988_probe(struct platform_device *pdev)
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
        snd_soc_dapm_new_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index f657e9a5fe266f1e8166a12d6473f99a62a1d69f..e43cb2c8b915de4f2850d5356c5f38428b0ec181 100644 (file)
@@ -1409,16 +1409,9 @@ static int wm8990_init(struct snd_soc_device *socdev)
        snd_soc_add_controls(codec, wm8990_snd_controls,
                                ARRAY_SIZE(wm8990_snd_controls));
        wm8990_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm8990: failed to register card\n");
-               goto card_err;
-       }
+
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        kfree(codec->reg_cache);
        return ret;
index dac397712147c23bc1bcdf5464b72049b9942420..0d4d2be92b64ae17593155617e772f4c19776b90 100644 (file)
@@ -1466,17 +1466,8 @@ static int wm8993_probe(struct platform_device *pdev)
 
        snd_soc_dapm_new_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card\n");
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 err:
        return ret;
 }
index 4cb6b104b7296928b78d095dbb81406f076e83fd..3f1f84421312e5e029255917e795a0299fea3140 100644 (file)
@@ -1264,17 +1264,8 @@ static int wm9081_probe(struct platform_device *pdev)
        snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
        snd_soc_dapm_new_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
-
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
index e7d2840d9e59d22e344b6c9792fe1be6ec9b1fd9..0e817b8705cd5eaa134185629e44c4999491c1ba 100644 (file)
@@ -403,16 +403,8 @@ static int wm9705_soc_probe(struct platform_device *pdev)
                                ARRAY_SIZE(wm9705_snd_ac97_controls));
        wm9705_add_widgets(codec);
 
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm9705: failed to register card\n");
-               goto reset_err;
-       }
-
        return 0;
 
-reset_err:
-       snd_soc_free_pcms(socdev);
 pcm_err:
        snd_soc_free_ac97_codec(codec);
 codec_err:
index 1fd4e88f50cff74db693676172518601671532ab..155cacf124eae59833ed4470f2636ccff013d435 100644 (file)
@@ -695,17 +695,9 @@ static int wm9712_soc_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm9712_snd_ac97_controls,
                                ARRAY_SIZE(wm9712_snd_ac97_controls));
        wm9712_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               printk(KERN_ERR "wm9712: failed to register card\n");
-               goto reset_err;
-       }
 
        return 0;
 
-reset_err:
-       snd_soc_free_pcms(socdev);
-
 pcm_err:
        snd_soc_free_ac97_codec(codec);
 
index ca3d449ed89e4e1c8b7da0d111984dd7ded5ae19..5f81ecd20a81899efe7907c7d6dd24c066cfe09d 100644 (file)
@@ -1247,13 +1247,8 @@ static int wm9713_soc_probe(struct platform_device *pdev)
        snd_soc_add_controls(codec, wm9713_snd_ac97_controls,
                                ARRAY_SIZE(wm9713_snd_ac97_controls));
        wm9713_add_widgets(codec);
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0)
-               goto reset_err;
-       return 0;
 
-reset_err:
-       snd_soc_free_pcms(socdev);
+       return 0;
 
 pcm_err:
        snd_soc_free_ac97_codec(codec);
index d81a1618776927dbb00105a7c19cc5568774d3da..e2b6d75f16e3761f18fbbd9a975c42802f398d4b 100644 (file)
@@ -970,6 +970,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
                                                    struct platform_device,
                                                    dev);
        struct snd_soc_codec_device *codec_dev = card->socdev->codec_dev;
+       struct snd_soc_codec *codec;
        struct snd_soc_platform *platform;
        struct snd_soc_dai *dai;
        int i, found, ret, ac97;
@@ -1058,6 +1059,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
                if (ret < 0)
                        goto cpu_dai_err;
        }
+       codec = card->codec;
 
        if (platform->probe) {
                ret = platform->probe(pdev);
@@ -1072,10 +1074,72 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
        INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
 #endif
 
+       for (i = 0; i < card->num_links; i++) {
+               if (card->dai_link[i].init) {
+                       ret = card->dai_link[i].init(codec);
+                       if (ret < 0) {
+                               printk(KERN_ERR "asoc: failed to init %s\n",
+                                       card->dai_link[i].stream_name);
+                               continue;
+                       }
+               }
+               if (card->dai_link[i].codec_dai->ac97_control) {
+                       ac97 = 1;
+                       snd_ac97_dev_add_pdata(codec->ac97,
+                               card->dai_link[i].cpu_dai->ac97_pdata);
+               }
+       }
+
+       snprintf(codec->card->shortname, sizeof(codec->card->shortname),
+                "%s",  card->name);
+       snprintf(codec->card->longname, sizeof(codec->card->longname),
+                "%s (%s)", card->name, codec->name);
+
+       /* Make sure all DAPM widgets are instantiated */
+       snd_soc_dapm_new_widgets(codec);
+
+       ret = snd_card_register(codec->card);
+       if (ret < 0) {
+               printk(KERN_ERR "asoc: failed to register soundcard for %s\n",
+                               codec->name);
+               goto card_err;
+       }
+
+       mutex_lock(&codec->mutex);
+#ifdef CONFIG_SND_SOC_AC97_BUS
+       /* Only instantiate AC97 if not already done by the adaptor
+        * for the generic AC97 subsystem.
+        */
+       if (ac97 && strcmp(codec->name, "AC97") != 0) {
+               ret = soc_ac97_dev_register(codec);
+               if (ret < 0) {
+                       printk(KERN_ERR "asoc: AC97 device register failed\n");
+                       snd_card_free(codec->card);
+                       mutex_unlock(&codec->mutex);
+                       goto card_err;
+               }
+       }
+#endif
+
+       ret = snd_soc_dapm_sys_add(card->socdev->dev);
+       if (ret < 0)
+               printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
+
+       ret = device_create_file(card->socdev->dev, &dev_attr_codec_reg);
+       if (ret < 0)
+               printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
+
+       soc_init_codec_debugfs(codec);
+       mutex_unlock(&codec->mutex);
+
        card->instantiated = 1;
 
        return;
 
+card_err:
+       if (platform->remove)
+               platform->remove(pdev);
+
 platform_err:
        if (codec_dev->remove)
                codec_dev->remove(pdev);
@@ -1453,83 +1517,6 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
 }
 EXPORT_SYMBOL_GPL(snd_soc_new_pcms);
 
-/**
- * snd_soc_init_card - register sound card
- * @socdev: the SoC audio device
- *
- * Register a SoC sound card. Also registers an AC97 device if the
- * codec is AC97 for ad hoc devices.
- *
- * Returns 0 for success, else error.
- */
-int snd_soc_init_card(struct snd_soc_device *socdev)
-{
-       struct snd_soc_card *card = socdev->card;
-       struct snd_soc_codec *codec = card->codec;
-       int ret = 0, i, ac97 = 0, err = 0;
-
-       for (i = 0; i < card->num_links; i++) {
-               if (card->dai_link[i].init) {
-                       err = card->dai_link[i].init(codec);
-                       if (err < 0) {
-                               printk(KERN_ERR "asoc: failed to init %s\n",
-                                       card->dai_link[i].stream_name);
-                               continue;
-                       }
-               }
-               if (card->dai_link[i].codec_dai->ac97_control) {
-                       ac97 = 1;
-                       snd_ac97_dev_add_pdata(codec->ac97,
-                               card->dai_link[i].cpu_dai->ac97_pdata);
-               }
-       }
-       snprintf(codec->card->shortname, sizeof(codec->card->shortname),
-                "%s",  card->name);
-       snprintf(codec->card->longname, sizeof(codec->card->longname),
-                "%s (%s)", card->name, codec->name);
-
-       /* Make sure all DAPM widgets are instantiated */
-       snd_soc_dapm_new_widgets(codec);
-
-       ret = snd_card_register(codec->card);
-       if (ret < 0) {
-               printk(KERN_ERR "asoc: failed to register soundcard for %s\n",
-                               codec->name);
-               goto out;
-       }
-
-       mutex_lock(&codec->mutex);
-#ifdef CONFIG_SND_SOC_AC97_BUS
-       /* Only instantiate AC97 if not already done by the adaptor
-        * for the generic AC97 subsystem.
-        */
-       if (ac97 && strcmp(codec->name, "AC97") != 0) {
-               ret = soc_ac97_dev_register(codec);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: AC97 device register failed\n");
-                       snd_card_free(codec->card);
-                       mutex_unlock(&codec->mutex);
-                       goto out;
-               }
-       }
-#endif
-
-       err = snd_soc_dapm_sys_add(socdev->dev);
-       if (err < 0)
-               printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n");
-
-       err = device_create_file(socdev->dev, &dev_attr_codec_reg);
-       if (err < 0)
-               printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
-
-       soc_init_codec_debugfs(codec);
-       mutex_unlock(&codec->mutex);
-
-out:
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_init_card);
-
 /**
  * snd_soc_free_pcms - free sound card and pcms
  * @socdev: the SoC audio device