Commit 72b86876 authored by Mark Brown's avatar Mark Brown Committed by Liam Girdwood

regulator: Improve virtual consumer probe error handling

Report errors to the user and try harder to clean up if we're not
able to probe.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 9ed2099e
...@@ -286,8 +286,7 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev) ...@@ -286,8 +286,7 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)
drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL); drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL);
if (drvdata == NULL) { if (drvdata == NULL) {
ret = -ENOMEM; return -ENOMEM;
goto err;
} }
mutex_init(&drvdata->lock); mutex_init(&drvdata->lock);
...@@ -302,8 +301,11 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev) ...@@ -302,8 +301,11 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(attributes); i++) { for (i = 0; i < ARRAY_SIZE(attributes); i++) {
ret = device_create_file(&pdev->dev, attributes[i]); ret = device_create_file(&pdev->dev, attributes[i]);
if (ret != 0) if (ret != 0) {
goto err; dev_err(&pdev->dev, "Failed to create attr %d: %d\n",
i, ret);
goto err_regulator;
}
} }
drvdata->mode = regulator_get_mode(drvdata->regulator); drvdata->mode = regulator_get_mode(drvdata->regulator);
...@@ -312,6 +314,8 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev) ...@@ -312,6 +314,8 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)
return 0; return 0;
err_regulator:
regulator_put(drvdata->regulator);
err: err:
for (i = 0; i < ARRAY_SIZE(attributes); i++) for (i = 0; i < ARRAY_SIZE(attributes); i++)
device_remove_file(&pdev->dev, attributes[i]); device_remove_file(&pdev->dev, attributes[i]);
......
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