Commit 5abe0c40 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: userspace-consumer: Convert to use devm_* APIs

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 62bc4d4a
...@@ -115,7 +115,9 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) ...@@ -115,7 +115,9 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
if (!pdata) if (!pdata)
return -EINVAL; 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) if (drvdata == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -125,16 +127,16 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) ...@@ -125,16 +127,16 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
mutex_init(&drvdata->lock); mutex_init(&drvdata->lock);
ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies, ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
drvdata->supplies); drvdata->supplies);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to get supplies: %d\n", 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); ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
if (ret != 0) if (ret != 0)
goto err_create_attrs; return ret;
if (pdata->init_on) { if (pdata->init_on) {
ret = regulator_bulk_enable(drvdata->num_supplies, ret = regulator_bulk_enable(drvdata->num_supplies,
...@@ -154,11 +156,6 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) ...@@ -154,11 +156,6 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
err_enable: err_enable:
sysfs_remove_group(&pdev->dev.kobj, &attr_group); 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; return ret;
} }
...@@ -171,9 +168,6 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev) ...@@ -171,9 +168,6 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev)
if (data->enabled) if (data->enabled)
regulator_bulk_disable(data->num_supplies, data->supplies); regulator_bulk_disable(data->num_supplies, data->supplies);
regulator_bulk_free(data->num_supplies, data->supplies);
kfree(data);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment