aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-04 07:47:49 -0400
committerMark Brown <broonie@linaro.org>2013-09-16 19:28:43 -0400
commit4aac198ddcfe38c7cf10cb2d23497b4a5ad24fdf (patch)
tree395ec0def03665cc1e3e5cc83328c3d99958d878
parent9738efae695733a9d367bd083e6ae0474dc5bd3c (diff)
regulator: tps65217: Use devm_regulator_register
devm_* simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/tps65217-regulator.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index 90861d68a0b0..8860379fd6be 100644
--- a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -233,7 +233,7 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
233 struct regulator_init_data *reg_data; 233 struct regulator_init_data *reg_data;
234 struct regulator_dev *rdev; 234 struct regulator_dev *rdev;
235 struct regulator_config config = { }; 235 struct regulator_config config = { };
236 int i, ret; 236 int i;
237 237
238 if (tps->dev->of_node) 238 if (tps->dev->of_node)
239 pdata = tps65217_parse_dt(pdev); 239 pdata = tps65217_parse_dt(pdev);
@@ -269,35 +269,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
269 if (tps->dev->of_node) 269 if (tps->dev->of_node)
270 config.of_node = pdata->of_node[i]; 270 config.of_node = pdata->of_node[i];
271 271
272 rdev = regulator_register(&regulators[i], &config); 272 rdev = devm_regulator_register(&pdev->dev, &regulators[i],
273 &config);
273 if (IS_ERR(rdev)) { 274 if (IS_ERR(rdev)) {
274 dev_err(tps->dev, "failed to register %s regulator\n", 275 dev_err(tps->dev, "failed to register %s regulator\n",
275 pdev->name); 276 pdev->name);
276 ret = PTR_ERR(rdev); 277 return PTR_ERR(rdev);
277 goto err_unregister_regulator;
278 } 278 }
279 279
280 /* Save regulator for cleanup */ 280 /* Save regulator for cleanup */
281 tps->rdev[i] = rdev; 281 tps->rdev[i] = rdev;
282 } 282 }
283 return 0; 283 return 0;
284
285err_unregister_regulator:
286 while (--i >= 0)
287 regulator_unregister(tps->rdev[i]);
288
289 return ret;
290}
291
292static int tps65217_regulator_remove(struct platform_device *pdev)
293{
294 struct tps65217 *tps = platform_get_drvdata(pdev);
295 unsigned int i;
296
297 for (i = 0; i < TPS65217_NUM_REGULATOR; i++)
298 regulator_unregister(tps->rdev[i]);
299
300 return 0;
301} 284}
302 285
303static struct platform_driver tps65217_regulator_driver = { 286static struct platform_driver tps65217_regulator_driver = {
@@ -305,7 +288,6 @@ static struct platform_driver tps65217_regulator_driver = {
305 .name = "tps65217-pmic", 288 .name = "tps65217-pmic",
306 }, 289 },
307 .probe = tps65217_regulator_probe, 290 .probe = tps65217_regulator_probe,
308 .remove = tps65217_regulator_remove,
309}; 291};
310 292
311static int __init tps65217_regulator_init(void) 293static int __init tps65217_regulator_init(void)