regulator: userspace-consumer: Convert to use devm_* APIs
authorAxel Lin <axel.lin@gmail.com>
Wed, 18 Apr 2012 01:34:34 +0000 (09:34 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 18 Apr 2012 09:26:24 +0000 (10:26 +0100)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/userspace-consumer.c

index 518667ef9a0d7e132b57fa92cb37397b6c799d9c..a7c8deb5f28fc02f93955f1c2b8f1ddcf2354f9a 100644 (file)
@@ -115,7 +115,9 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
        if (!pdata)
                return -EINVAL;
 
-       drvdata = kzalloc(sizeof(struct userspace_consumer_data), GFP_KERNEL);
+       drvdata = devm_kzalloc(&pdev->dev,
+                              sizeof(struct userspace_consumer_data),
+                              GFP_KERNEL);
        if (drvdata == NULL)
                return -ENOMEM;
 
@@ -125,16 +127,16 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 
        mutex_init(&drvdata->lock);
 
-       ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
-                                drvdata->supplies);
+       ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
+                                     drvdata->supplies);
        if (ret) {
                dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret);
-               goto err_alloc_supplies;
+               return ret;
        }
 
        ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
        if (ret != 0)
-               goto err_create_attrs;
+               return ret;
 
        if (pdata->init_on) {
                ret = regulator_bulk_enable(drvdata->num_supplies,
@@ -154,11 +156,6 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
 err_enable:
        sysfs_remove_group(&pdev->dev.kobj, &attr_group);
 
-err_create_attrs:
-       regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
-
-err_alloc_supplies:
-       kfree(drvdata);
        return ret;
 }
 
@@ -171,9 +168,6 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev)
        if (data->enabled)
                regulator_bulk_disable(data->num_supplies, data->supplies);
 
-       regulator_bulk_free(data->num_supplies, data->supplies);
-       kfree(data);
-
        return 0;
 }