Commit a81edbde authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: virtual: 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 5abe0c40
...@@ -291,18 +291,19 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev) ...@@ -291,18 +291,19 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
struct virtual_consumer_data *drvdata; struct virtual_consumer_data *drvdata;
int ret; int ret;
drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL); drvdata = devm_kzalloc(&pdev->dev, sizeof(struct virtual_consumer_data),
GFP_KERNEL);
if (drvdata == NULL) if (drvdata == NULL)
return -ENOMEM; return -ENOMEM;
mutex_init(&drvdata->lock); mutex_init(&drvdata->lock);
drvdata->regulator = regulator_get(&pdev->dev, reg_id); drvdata->regulator = devm_regulator_get(&pdev->dev, reg_id);
if (IS_ERR(drvdata->regulator)) { if (IS_ERR(drvdata->regulator)) {
ret = PTR_ERR(drvdata->regulator); ret = PTR_ERR(drvdata->regulator);
dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n", dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n",
reg_id, ret); reg_id, ret);
goto err; return ret;
} }
ret = sysfs_create_group(&pdev->dev.kobj, ret = sysfs_create_group(&pdev->dev.kobj,
...@@ -310,7 +311,7 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev) ...@@ -310,7 +311,7 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Failed to create attribute group: %d\n", ret); "Failed to create attribute group: %d\n", ret);
goto err_regulator; return ret;
} }
drvdata->mode = regulator_get_mode(drvdata->regulator); drvdata->mode = regulator_get_mode(drvdata->regulator);
...@@ -318,12 +319,6 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev) ...@@ -318,12 +319,6 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, drvdata); platform_set_drvdata(pdev, drvdata);
return 0; return 0;
err_regulator:
regulator_put(drvdata->regulator);
err:
kfree(drvdata);
return ret;
} }
static int __devexit regulator_virtual_remove(struct platform_device *pdev) static int __devexit regulator_virtual_remove(struct platform_device *pdev)
...@@ -334,9 +329,6 @@ static int __devexit regulator_virtual_remove(struct platform_device *pdev) ...@@ -334,9 +329,6 @@ static int __devexit regulator_virtual_remove(struct platform_device *pdev)
if (drvdata->enabled) if (drvdata->enabled)
regulator_disable(drvdata->regulator); regulator_disable(drvdata->regulator);
regulator_put(drvdata->regulator);
kfree(drvdata);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
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