]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ASoC: Replace remaining uses of snd_soc_cnew with snd_soc_add_controls.
authorPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 12 Mar 2009 10:07:54 +0000 (11:07 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 12 Mar 2009 15:43:30 +0000 (15:43 +0000)
The drivers are basically duplicating the same code over and over.
As snd_soc_cnew is going to be made static some time after the next
merge window, we might as well convert them now.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/cs4270.c
sound/soc/codecs/tlv320aic26.c
sound/soc/codecs/wm8400.c
sound/soc/omap/n810.c
sound/soc/pxa/corgi.c
sound/soc/pxa/palm27x.c
sound/soc/pxa/poodle.c
sound/soc/pxa/spitz.c
sound/soc/pxa/tosa.c
sound/soc/s3c24xx/neo1973_wm8753.c

index 2137670c9b789b076a6b4f6894d8fafcf93ad8bd..7fa09a387622cbff69b28b88e83819faa876d4e9 100644 (file)
@@ -540,7 +540,6 @@ static int cs4270_probe(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
        struct snd_soc_codec *codec = cs4270_codec;
-       unsigned int i;
        int ret;
 
        /* Connect the codec to the socdev.  snd_soc_new_pcms() needs this. */
@@ -554,23 +553,11 @@ static int cs4270_probe(struct platform_device *pdev)
        }
 
        /* Add the non-DAPM controls */
-       for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) {
-               struct snd_kcontrol *kctrl;
-
-               kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
-               if (!kctrl) {
-                       dev_err(codec->dev, "error creating control '%s'\n",
-                              cs4270_snd_controls[i].name);
-                       ret = -ENOMEM;
-                       goto error_free_pcms;
-               }
-
-               ret = snd_ctl_add(codec->card, kctrl);
-               if (ret < 0) {
-                       dev_err(codec->dev, "error adding control '%s'\n",
-                              cs4270_snd_controls[i].name);
-                       goto error_free_pcms;
-               }
+       ret = snd_soc_add_controls(codec, cs4270_snd_controls,
+                               ARRAY_SIZE(cs4270_snd_controls));
+       if (ret < 0) {
+               dev_err(codec->dev, "failed to add controls\n");
+               goto error_free_pcms;
        }
 
        /* And finally, register the socdev */
index a7f333fc579e3fb5325dafdf6f1511fe8cfff989..3387d9e736ea23e23e075e0e1a7409c8deebaeab 100644 (file)
@@ -324,9 +324,8 @@ static int aic26_probe(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
        struct snd_soc_codec *codec;
-       struct snd_kcontrol *kcontrol;
        struct aic26 *aic26;
-       int i, ret, err;
+       int ret, err;
 
        dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n");
        dev_dbg(&pdev->dev, "socdev=%p\n", socdev);
@@ -353,11 +352,9 @@ static int aic26_probe(struct platform_device *pdev)
 
        /* register controls */
        dev_dbg(&pdev->dev, "Registering controls\n");
-       for (i = 0; i < ARRAY_SIZE(aic26_snd_controls); i++) {
-               kcontrol = snd_soc_cnew(&aic26_snd_controls[i], codec, NULL);
-               err = snd_ctl_add(codec->card, kcontrol);
-               WARN_ON(err < 0);
-       }
+       err = snd_soc_add_controls(codec, aic26_snd_controls,
+                       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");
index 4e1cefff8483c27bc18ae08589c089975900f4df..744e0dc73be48d38fe660b05e9036f5b68b71a9b 100644 (file)
@@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME,
 /* add non dapm controls */
 static int wm8400_add_controls(struct snd_soc_codec *codec)
 {
-       int err, i;
-
-       for (i = 0; i < ARRAY_SIZE(wm8400_snd_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                               snd_soc_cnew(&wm8400_snd_controls[i],codec,
-                                       NULL));
-               if (err < 0)
-                       return err;
-       }
-       return 0;
+       return snd_soc_add_controls(codec, wm8400_snd_controls,
+                               ARRAY_SIZE(wm8400_snd_controls));
 }
 
 /*
index 9f037cd0191d5789c2613841992e6ee6613c73dd..86471fd6340f4615aa17c27300ae4ab4166c5092 100644 (file)
@@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = {
 
 static int n810_aic33_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        /* Not connected */
        snd_soc_dapm_nc_pin(codec, "MONO_LOUT");
@@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
        snd_soc_dapm_nc_pin(codec, "HPRCOM");
 
        /* Add N810 specific controls */
-       for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                       snd_soc_cnew(&aic33_n810_controls[i], codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, aic33_n810_controls,
+                               ARRAY_SIZE(aic33_n810_controls));
+       if (err < 0)
+               return err;
 
        /* Add N810 specific widgets */
        snd_soc_dapm_new_controls(codec, aic33_dapm_widgets,
index 146973ae0974d31ed46fd52d4174b93909196277..02263e5d8f039ba9879ffdb9c794840eeeb5899e 100644 (file)
@@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = {
  */
 static int corgi_wm8731_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        snd_soc_dapm_nc_pin(codec, "LLINEIN");
        snd_soc_dapm_nc_pin(codec, "RLINEIN");
 
        /* Add corgi specific controls */
-       for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                       snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, wm8731_corgi_controls,
+                               ARRAY_SIZE(wm8731_corgi_controls));
+       if (err < 0)
+               return err;
 
        /* Add corgi specific widgets */
        snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
index 29958cd9daec67274dbe0b11306231dd017c3e3a..48a73f64500bc6ce78e40b0de21e5ba0413ef521 100644 (file)
@@ -146,19 +146,16 @@ static const struct snd_kcontrol_new palm27x_controls[] = {
 
 static int palm27x_ac97_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        snd_soc_dapm_nc_pin(codec, "OUT3");
        snd_soc_dapm_nc_pin(codec, "MONOOUT");
 
        /* add palm27x specific controls */
-       for (i = 0; i < ARRAY_SIZE(palm27x_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                               snd_soc_cnew(&palm27x_controls[i],
-                                               codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, palm27x_controls,
+                               ARRAY_SIZE(palm27x_controls));
+       if (err < 0)
+               return err;
 
        /* add palm27x specific widgets */
        snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets,
index fb17a0a5a093c7d33a0b1c140d0214a574a598dc..ef7c6c8dc8f1995c47b9c7fffdb919703308bdb9 100644 (file)
@@ -241,19 +241,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = {
  */
 static int poodle_wm8731_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        snd_soc_dapm_nc_pin(codec, "LLINEIN");
        snd_soc_dapm_nc_pin(codec, "RLINEIN");
        snd_soc_dapm_enable_pin(codec, "MICIN");
 
        /* Add poodle specific controls */
-       for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                       snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, wm8731_poodle_controls,
+                               ARRAY_SIZE(wm8731_poodle_controls));
+       if (err < 0)
+               return err;
 
        /* Add poodle specific widgets */
        snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets,
index 1aafd8c645a1fdaf292c39c2585ec6405057fa3c..6ca9f53080c67862ef235e9171f28c004e94ef79 100644 (file)
@@ -278,7 +278,7 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = {
  */
 static int spitz_wm8750_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        /* NC codec pins */
        snd_soc_dapm_nc_pin(codec, "RINPUT1");
@@ -290,12 +290,10 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
        snd_soc_dapm_nc_pin(codec, "MONO1");
 
        /* Add spitz specific controls */
-       for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                       snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, wm8750_spitz_controls,
+                               ARRAY_SIZE(wm8750_spitz_controls));
+       if (err < 0)
+               return err;
 
        /* Add spitz specific widgets */
        snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets,
index 09b5bada03b907889a317a659a48ccbc694e28c1..fc781374b1bfa234cba453ed85459747e6d58be0 100644 (file)
@@ -188,18 +188,16 @@ static const struct snd_kcontrol_new tosa_controls[] = {
 
 static int tosa_ac97_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        snd_soc_dapm_nc_pin(codec, "OUT3");
        snd_soc_dapm_nc_pin(codec, "MONOOUT");
 
        /* add tosa specific controls */
-       for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                               snd_soc_cnew(&tosa_controls[i],codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, tosa_controls,
+                               ARRAY_SIZE(tosa_controls));
+       if (err < 0)
+               return err;
 
        /* add tosa specific widgets */
        snd_soc_dapm_new_controls(codec, tosa_dapm_widgets,
index 5f6aeec0437d7b05a5f2a4ee02aad333025cb826..289fadf60b1038a24585f3c4bf7e65f8046a8b46 100644 (file)
@@ -498,7 +498,7 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = {
  */
 static int neo1973_wm8753_init(struct snd_soc_codec *codec)
 {
-       int i, err;
+       int err;
 
        pr_debug("Entered %s\n", __func__);
 
@@ -518,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
        set_scenario_endpoints(codec, NEO_AUDIO_OFF);
 
        /* add neo1973 specific controls */
-       for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                               snd_soc_cnew(&wm8753_neo1973_controls[i],
-                               codec, NULL));
-               if (err < 0)
-                       return err;
-       }
+       err = snd_soc_add_controls(codec, wm8753_neo1973_controls,
+                               ARRAY_SIZE(8753_neo1973_controls));
+       if (err < 0)
+               return err;
 
        /* set up neo1973 specific audio routes */
        err = snd_soc_dapm_add_routes(codec, dapm_routes,