Merge branch 'for-3.2' into for-3.3
[deliverable/linux.git] / sound / soc / codecs / uda1380.c
index c5ca8cfea60f80f8de27cc5d12ad55f69bd900f2..8f734d69f651a00eb78dcc1d2ab083d5314675cd 100644 (file)
@@ -373,7 +373,7 @@ static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
        SND_SOC_DAPM_PGA("HeadPhone Driver", UDA1380_PM, 13, 0, NULL, 0),
 };
 
-static const struct snd_soc_dapm_route audio_map[] = {
+static const struct snd_soc_dapm_route uda1380_dapm_routes[] = {
 
        /* output mux */
        {"HeadPhone Driver", NULL, "Output Mux"},
@@ -410,17 +410,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
        {"Right PGA", NULL, "VINR"},
 };
 
-static int uda1380_add_widgets(struct snd_soc_codec *codec)
-{
-       struct snd_soc_dapm_context *dapm = &codec->dapm;
-
-       snd_soc_dapm_new_controls(dapm, uda1380_dapm_widgets,
-                                 ARRAY_SIZE(uda1380_dapm_widgets));
-       snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
-
-       return 0;
-}
-
 static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai,
                unsigned int fmt)
 {
@@ -643,21 +632,21 @@ static int uda1380_set_bias_level(struct snd_soc_codec *codec,
                       SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
                       SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
 
-static struct snd_soc_dai_ops uda1380_dai_ops = {
+static const struct snd_soc_dai_ops uda1380_dai_ops = {
        .hw_params      = uda1380_pcm_hw_params,
        .shutdown       = uda1380_pcm_shutdown,
        .trigger        = uda1380_trigger,
        .set_fmt        = uda1380_set_dai_fmt_both,
 };
 
-static struct snd_soc_dai_ops uda1380_dai_ops_playback = {
+static const struct snd_soc_dai_ops uda1380_dai_ops_playback = {
        .hw_params      = uda1380_pcm_hw_params,
        .shutdown       = uda1380_pcm_shutdown,
        .trigger        = uda1380_trigger,
        .set_fmt        = uda1380_set_dai_fmt_playback,
 };
 
-static struct snd_soc_dai_ops uda1380_dai_ops_capture = {
+static const struct snd_soc_dai_ops uda1380_dai_ops_capture = {
        .hw_params      = uda1380_pcm_hw_params,
        .shutdown       = uda1380_pcm_shutdown,
        .trigger        = uda1380_trigger,
@@ -705,7 +694,7 @@ static struct snd_soc_dai_driver uda1380_dai[] = {
 },
 };
 
-static int uda1380_suspend(struct snd_soc_codec *codec, pm_message_t state)
+static int uda1380_suspend(struct snd_soc_codec *codec)
 {
        uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF);
        return 0;
@@ -732,27 +721,21 @@ static int uda1380_probe(struct snd_soc_codec *codec)
                return -EINVAL;
 
        if (gpio_is_valid(pdata->gpio_reset)) {
-               ret = gpio_request(pdata->gpio_reset, "uda1380 reset");
+               ret = gpio_request_one(pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
+                                      "uda1380 reset");
                if (ret)
                        goto err_out;
-               ret = gpio_direction_output(pdata->gpio_reset, 0);
-               if (ret)
-                       goto err_gpio_reset_conf;
        }
 
        if (gpio_is_valid(pdata->gpio_power)) {
-               ret = gpio_request(pdata->gpio_power, "uda1380 power");
-               if (ret)
-                       goto err_gpio;
-               ret = gpio_direction_output(pdata->gpio_power, 0);
+               ret = gpio_request_one(pdata->gpio_power, GPIOF_OUT_INIT_LOW,
+                                  "uda1380 power");
                if (ret)
-                       goto err_gpio_power_conf;
+                       goto err_free_gpio;
        } else {
                ret = uda1380_reset(codec);
-               if (ret) {
-                       dev_err(codec->dev, "Failed to issue reset\n");
-                       goto err_reset;
-               }
+               if (ret)
+                       goto err_free_gpio;
        }
 
        INIT_WORK(&uda1380->work, uda1380_flush_work);
@@ -770,19 +753,9 @@ static int uda1380_probe(struct snd_soc_codec *codec)
                break;
        }
 
-       snd_soc_add_controls(codec, uda1380_snd_controls,
-                               ARRAY_SIZE(uda1380_snd_controls));
-       uda1380_add_widgets(codec);
-
        return 0;
 
-err_reset:
-err_gpio_power_conf:
-       if (gpio_is_valid(pdata->gpio_power))
-               gpio_free(pdata->gpio_power);
-
-err_gpio_reset_conf:
-err_gpio:
+err_free_gpio:
        if (gpio_is_valid(pdata->gpio_reset))
                gpio_free(pdata->gpio_reset);
 err_out:
@@ -814,6 +787,13 @@ static struct snd_soc_codec_driver soc_codec_dev_uda1380 = {
        .reg_word_size = sizeof(u16),
        .reg_cache_default = uda1380_reg,
        .reg_cache_step = 1,
+
+       .controls = uda1380_snd_controls,
+       .num_controls = ARRAY_SIZE(uda1380_snd_controls),
+       .dapm_widgets = uda1380_dapm_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets),
+       .dapm_routes = uda1380_dapm_routes,
+       .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes),
 };
 
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
@@ -863,13 +843,13 @@ static struct i2c_driver uda1380_i2c_driver = {
 
 static int __init uda1380_modinit(void)
 {
-       int ret;
+       int ret = 0;
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        ret = i2c_add_driver(&uda1380_i2c_driver);
        if (ret != 0)
                pr_err("Failed to register UDA1380 I2C driver: %d\n", ret);
 #endif
-       return 0;
+       return ret;
 }
 module_init(uda1380_modinit);
 
This page took 0.028823 seconds and 5 git commands to generate.