Skip to content

Commit

Permalink
regulator: Improve virtual consumer probe error handling
Browse files Browse the repository at this point in the history
Report errors to the user and try harder to clean up if we're not
able to probe.

Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
  • Loading branch information
broonie authored and Liam Girdwood committed Sep 22, 2009
1 parent 9ed2099 commit 72b8687
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/regulator/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)

drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL);
if (drvdata == NULL) {
ret = -ENOMEM;
goto err;
return -ENOMEM;
}

mutex_init(&drvdata->lock);
Expand All @@ -302,8 +301,11 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)

for (i = 0; i < ARRAY_SIZE(attributes); i++) {
ret = device_create_file(&pdev->dev, attributes[i]);
if (ret != 0)
goto err;
if (ret != 0) {
dev_err(&pdev->dev, "Failed to create attr %d: %d\n",
i, ret);
goto err_regulator;
}
}

drvdata->mode = regulator_get_mode(drvdata->regulator);
Expand All @@ -312,6 +314,8 @@ static int regulator_virtual_consumer_probe(struct platform_device *pdev)

return 0;

err_regulator:
regulator_put(drvdata->regulator);
err:
for (i = 0; i < ARRAY_SIZE(attributes); i++)
device_remove_file(&pdev->dev, attributes[i]);
Expand Down

0 comments on commit 72b8687

Please sign in to comment.