ASoC: Convert ak4104 to devm_kzalloc()
authorAxel Lin <axel.lin@gmail.com>
Tue, 20 Dec 2011 06:37:12 +0000 (14:37 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 20 Dec 2011 10:13:57 +0000 (10:13 +0000)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/ak4104.c

index 152420ca78b88310a19537a9ced6836181424629..d27b5e4cce99b58339300b860bc4bad1b924b87d 100644 (file)
@@ -261,7 +261,8 @@ static int ak4104_spi_probe(struct spi_device *spi)
        if (ret < 0)
                return ret;
 
-       ak4104 = kzalloc(sizeof(struct ak4104_private), GFP_KERNEL);
+       ak4104 = devm_kzalloc(&spi->dev, sizeof(struct ak4104_private),
+                             GFP_KERNEL);
        if (ak4104 == NULL)
                return -ENOMEM;
 
@@ -271,15 +272,12 @@ static int ak4104_spi_probe(struct spi_device *spi)
 
        ret = snd_soc_register_codec(&spi->dev,
                        &soc_codec_device_ak4104, &ak4104_dai, 1);
-       if (ret < 0)
-               kfree(ak4104);
        return ret;
 }
 
 static int __devexit ak4104_spi_remove(struct spi_device *spi)
 {
        snd_soc_unregister_codec(&spi->dev);
-       kfree(spi_get_drvdata(spi));
        return 0;
 }