diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-09-04 07:47:50 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:28:43 -0400 |
commit | 884ea5570f1eda8a1e0f5235cba4f00bafed450e (patch) | |
tree | f1dfb7eb737667711075cb74892a66aa33ad080a /drivers/regulator/tps6586x-regulator.c | |
parent | 4aac198ddcfe38c7cf10cb2d23497b4a5ad24fdf (diff) |
regulator: tps6586x: 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>
Diffstat (limited to 'drivers/regulator/tps6586x-regulator.c')
-rw-r--r-- | drivers/regulator/tps6586x-regulator.c | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 2c9155b66f09..45e5d683d3f8 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -379,15 +379,14 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
379 | ri = find_regulator_info(id); | 379 | ri = find_regulator_info(id); |
380 | if (!ri) { | 380 | if (!ri) { |
381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); | 381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); |
382 | err = -EINVAL; | 382 | return -EINVAL; |
383 | goto fail; | ||
384 | } | 383 | } |
385 | 384 | ||
386 | err = tps6586x_regulator_preinit(pdev->dev.parent, ri); | 385 | err = tps6586x_regulator_preinit(pdev->dev.parent, ri); |
387 | if (err) { | 386 | if (err) { |
388 | dev_err(&pdev->dev, | 387 | dev_err(&pdev->dev, |
389 | "regulator %d preinit failed, e %d\n", id, err); | 388 | "regulator %d preinit failed, e %d\n", id, err); |
390 | goto fail; | 389 | return err; |
391 | } | 390 | } |
392 | 391 | ||
393 | config.dev = pdev->dev.parent; | 392 | config.dev = pdev->dev.parent; |
@@ -397,12 +396,12 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
397 | if (tps6586x_reg_matches) | 396 | if (tps6586x_reg_matches) |
398 | config.of_node = tps6586x_reg_matches[id].of_node; | 397 | config.of_node = tps6586x_reg_matches[id].of_node; |
399 | 398 | ||
400 | rdev[id] = regulator_register(&ri->desc, &config); | 399 | rdev[id] = devm_regulator_register(&pdev->dev, &ri->desc, |
400 | &config); | ||
401 | if (IS_ERR(rdev[id])) { | 401 | if (IS_ERR(rdev[id])) { |
402 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 402 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
403 | ri->desc.name); | 403 | ri->desc.name); |
404 | err = PTR_ERR(rdev[id]); | 404 | return PTR_ERR(rdev[id]); |
405 | goto fail; | ||
406 | } | 405 | } |
407 | 406 | ||
408 | if (reg_data) { | 407 | if (reg_data) { |
@@ -411,30 +410,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
411 | if (err < 0) { | 410 | if (err < 0) { |
412 | dev_err(&pdev->dev, | 411 | dev_err(&pdev->dev, |
413 | "Slew rate config failed, e %d\n", err); | 412 | "Slew rate config failed, e %d\n", err); |
414 | regulator_unregister(rdev[id]); | 413 | return err; |
415 | goto fail; | ||
416 | } | 414 | } |
417 | } | 415 | } |
418 | } | 416 | } |
419 | 417 | ||
420 | platform_set_drvdata(pdev, rdev); | 418 | platform_set_drvdata(pdev, rdev); |
421 | return 0; | 419 | return 0; |
422 | |||
423 | fail: | ||
424 | while (--id >= 0) | ||
425 | regulator_unregister(rdev[id]); | ||
426 | return err; | ||
427 | } | ||
428 | |||
429 | static int tps6586x_regulator_remove(struct platform_device *pdev) | ||
430 | { | ||
431 | struct regulator_dev **rdev = platform_get_drvdata(pdev); | ||
432 | int id = TPS6586X_ID_MAX_REGULATOR; | ||
433 | |||
434 | while (--id >= 0) | ||
435 | regulator_unregister(rdev[id]); | ||
436 | |||
437 | return 0; | ||
438 | } | 420 | } |
439 | 421 | ||
440 | static struct platform_driver tps6586x_regulator_driver = { | 422 | static struct platform_driver tps6586x_regulator_driver = { |
@@ -443,7 +425,6 @@ static struct platform_driver tps6586x_regulator_driver = { | |||
443 | .owner = THIS_MODULE, | 425 | .owner = THIS_MODULE, |
444 | }, | 426 | }, |
445 | .probe = tps6586x_regulator_probe, | 427 | .probe = tps6586x_regulator_probe, |
446 | .remove = tps6586x_regulator_remove, | ||
447 | }; | 428 | }; |
448 | 429 | ||
449 | static int __init tps6586x_regulator_init(void) | 430 | static int __init tps6586x_regulator_init(void) |