提交 4aac198d 编写于 作者: S Sachin Kamat 提交者: Mark Brown

regulator: tps65217: Use devm_regulator_register

devm_* simplifies the code.
Signed-off-by: NSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 9738efae
...@@ -233,7 +233,7 @@ static int tps65217_regulator_probe(struct platform_device *pdev) ...@@ -233,7 +233,7 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
struct regulator_init_data *reg_data; struct regulator_init_data *reg_data;
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct regulator_config config = { }; struct regulator_config config = { };
int i, ret; int i;
if (tps->dev->of_node) if (tps->dev->of_node)
pdata = tps65217_parse_dt(pdev); pdata = tps65217_parse_dt(pdev);
...@@ -269,35 +269,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev) ...@@ -269,35 +269,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
if (tps->dev->of_node) if (tps->dev->of_node)
config.of_node = pdata->of_node[i]; config.of_node = pdata->of_node[i];
rdev = regulator_register(&regulators[i], &config); rdev = devm_regulator_register(&pdev->dev, &regulators[i],
&config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(tps->dev, "failed to register %s regulator\n", dev_err(tps->dev, "failed to register %s regulator\n",
pdev->name); pdev->name);
ret = PTR_ERR(rdev); return PTR_ERR(rdev);
goto err_unregister_regulator;
} }
/* Save regulator for cleanup */ /* Save regulator for cleanup */
tps->rdev[i] = rdev; tps->rdev[i] = rdev;
} }
return 0; return 0;
err_unregister_regulator:
while (--i >= 0)
regulator_unregister(tps->rdev[i]);
return ret;
}
static int tps65217_regulator_remove(struct platform_device *pdev)
{
struct tps65217 *tps = platform_get_drvdata(pdev);
unsigned int i;
for (i = 0; i < TPS65217_NUM_REGULATOR; i++)
regulator_unregister(tps->rdev[i]);
return 0;
} }
static struct platform_driver tps65217_regulator_driver = { static struct platform_driver tps65217_regulator_driver = {
...@@ -305,7 +288,6 @@ static struct platform_driver tps65217_regulator_driver = { ...@@ -305,7 +288,6 @@ static struct platform_driver tps65217_regulator_driver = {
.name = "tps65217-pmic", .name = "tps65217-pmic",
}, },
.probe = tps65217_regulator_probe, .probe = tps65217_regulator_probe,
.remove = tps65217_regulator_remove,
}; };
static int __init tps65217_regulator_init(void) static int __init tps65217_regulator_init(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册