]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
regulator: wm831x-dcdc: Use devm_kzalloc
authorAxel Lin <axel.lin@gmail.com>
Fri, 23 Mar 2012 09:00:01 +0000 (17:00 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 1 Apr 2012 10:59:30 +0000 (11:59 +0100)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/wm831x-dcdc.c

index 4904a40b0d46f6b3b870155a535312623e72a831..909c53b70375c91610c61dbf69d7cde0aab2e276 100644 (file)
@@ -848,7 +848,7 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
        if (pdata == NULL || pdata->dcdc[id] == NULL)
                return -ENODEV;
 
-       dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
+       dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
        if (dcdc == NULL) {
                dev_err(&pdev->dev, "Unable to allocate private data\n");
                return -ENOMEM;
@@ -897,7 +897,6 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
 err_regulator:
        regulator_unregister(dcdc->regulator);
 err:
-       kfree(dcdc);
        return ret;
 }
 
@@ -909,7 +908,6 @@ static __devexit int wm831x_boostp_remove(struct platform_device *pdev)
 
        free_irq(platform_get_irq_byname(pdev, "UV"), dcdc);
        regulator_unregister(dcdc->regulator);
-       kfree(dcdc);
 
        return 0;
 }
@@ -952,7 +950,7 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev)
        if (pdata == NULL || pdata->epe[id] == NULL)
                return -ENODEV;
 
-       dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
+       dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
        if (dcdc == NULL) {
                dev_err(&pdev->dev, "Unable to allocate private data\n");
                return -ENOMEM;
@@ -984,7 +982,6 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev)
        return 0;
 
 err:
-       kfree(dcdc);
        return ret;
 }
 
@@ -993,9 +990,7 @@ static __devexit int wm831x_epe_remove(struct platform_device *pdev)
        struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
 
        platform_set_drvdata(pdev, NULL);
-
        regulator_unregister(dcdc->regulator);
-       kfree(dcdc);
 
        return 0;
 }