ASoC: ad193x: Use managed regmap init
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 13 Sep 2012 10:03:23 +0000 (12:03 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 13 Sep 2012 10:08:21 +0000 (18:08 +0800)
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/ad193x.c

index 13e62be4f9903eac8560819d751b0edbcf9e4555..2f752660f6789760381aaec5f0391aac94b33bde 100644 (file)
@@ -381,40 +381,25 @@ static const struct regmap_config ad193x_spi_regmap_config = {
 static int __devinit ad193x_spi_probe(struct spi_device *spi)
 {
        struct ad193x_priv *ad193x;
-       int ret;
 
        ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv),
                              GFP_KERNEL);
        if (ad193x == NULL)
                return -ENOMEM;
 
-       ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config);
-       if (IS_ERR(ad193x->regmap)) {
-               ret = PTR_ERR(ad193x->regmap);
-               goto err_out;
-       }
+       ad193x->regmap = devm_regmap_init_spi(spi, &ad193x_spi_regmap_config);
+       if (IS_ERR(ad193x->regmap))
+               return PTR_ERR(ad193x->regmap);
 
        spi_set_drvdata(spi, ad193x);
 
-       ret = snd_soc_register_codec(&spi->dev,
-                       &soc_codec_dev_ad193x, &ad193x_dai, 1);
-       if (ret < 0)
-               goto err_regmap_exit;
-
-       return 0;
-
-err_regmap_exit:
-       regmap_exit(ad193x->regmap);
-err_out:
-       return ret;
+       return snd_soc_register_codec(&spi->dev, &soc_codec_dev_ad193x,
+                       &ad193x_dai, 1);
 }
 
 static int __devexit ad193x_spi_remove(struct spi_device *spi)
 {
-       struct ad193x_priv *ad193x = spi_get_drvdata(spi);
-
        snd_soc_unregister_codec(&spi->dev);
-       regmap_exit(ad193x->regmap);
        return 0;
 }
 
@@ -449,40 +434,25 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client,
                const struct i2c_device_id *id)
 {
        struct ad193x_priv *ad193x;
-       int ret;
 
        ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv),
                              GFP_KERNEL);
        if (ad193x == NULL)
                return -ENOMEM;
 
-       ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config);
-       if (IS_ERR(ad193x->regmap)) {
-               ret = PTR_ERR(ad193x->regmap);
-               goto err_out;
-       }
+       ad193x->regmap = devm_regmap_init_i2c(client, &ad193x_i2c_regmap_config);
+       if (IS_ERR(ad193x->regmap))
+               return PTR_ERR(ad193x->regmap);
 
        i2c_set_clientdata(client, ad193x);
 
-       ret =  snd_soc_register_codec(&client->dev,
-                       &soc_codec_dev_ad193x, &ad193x_dai, 1);
-       if (ret < 0)
-               goto err_regmap_exit;
-
-       return 0;
-
-err_regmap_exit:
-       regmap_exit(ad193x->regmap);
-err_out:
-       return ret;
+       return snd_soc_register_codec(&client->dev, &soc_codec_dev_ad193x,
+                       &ad193x_dai, 1);
 }
 
 static int __devexit ad193x_i2c_remove(struct i2c_client *client)
 {
-       struct ad193x_priv *ad193x = i2c_get_clientdata(client);
-
        snd_soc_unregister_codec(&client->dev);
-       regmap_exit(ad193x->regmap);
        return 0;
 }