mfd: twl4030-audio: Convert to use devm_kzalloc
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Mon, 10 Sep 2012 10:46:20 +0000 (13:46 +0300)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 22 Sep 2012 15:14:40 +0000 (11:14 -0400)
To clean up the module probe and remove functions.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/mfd/twl4030-audio.c

index ac04b4f2a53a6af1844130ac95ea97c0ecf47a6e..efa2d424b416d489e69012bd1a37b43cc81a052f 100644 (file)
@@ -188,7 +188,8 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev)
        twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
                                        val, TWL4030_REG_APLL_CTL);
 
-       audio = kzalloc(sizeof(struct twl4030_audio), GFP_KERNEL);
+       audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio),
+                            GFP_KERNEL);
        if (!audio)
                return -ENOMEM;
 
@@ -229,22 +230,18 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev)
                ret = -ENODEV;
        }
 
-       if (!ret)
-               return 0;
+       if (ret) {
+               platform_set_drvdata(pdev, NULL);
+               twl4030_audio_dev = NULL;
+       }
 
-       platform_set_drvdata(pdev, NULL);
-       kfree(audio);
-       twl4030_audio_dev = NULL;
        return ret;
 }
 
 static int __devexit twl4030_audio_remove(struct platform_device *pdev)
 {
-       struct twl4030_audio *audio = platform_get_drvdata(pdev);
-
        mfd_remove_devices(&pdev->dev);
        platform_set_drvdata(pdev, NULL);
-       kfree(audio);
        twl4030_audio_dev = NULL;
 
        return 0;