mfd: ab8500-gpadc: Convert to managed resources for allocating memory
authorLee Jones <lee.jones@linaro.org>
Thu, 23 May 2013 15:25:06 +0000 (16:25 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 13 Jun 2013 10:11:40 +0000 (12:11 +0200)
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/ab8500-gpadc.c

index 13f7866..f1d4565 100644 (file)
@@ -925,7 +925,7 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
        int ret = 0;
        struct ab8500_gpadc *gpadc;
 
-       gpadc = kzalloc(sizeof(struct ab8500_gpadc), GFP_KERNEL);
+       gpadc = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_gpadc), GFP_KERNEL);
        if (!gpadc) {
                dev_err(&pdev->dev, "Error: No memory\n");
                return -ENOMEM;
@@ -1005,8 +1005,6 @@ fail_irq:
        free_irq(gpadc->irq_sw, gpadc);
        free_irq(gpadc->irq_hw, gpadc);
 fail:
-       kfree(gpadc);
-       gpadc = NULL;
        return ret;
 }
 
@@ -1031,8 +1029,6 @@ static int ab8500_gpadc_remove(struct platform_device *pdev)
 
        pm_runtime_put_noidle(gpadc->dev);
 
-       kfree(gpadc);
-       gpadc = NULL;
        return 0;
 }