diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-07-07 11:42:14 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-09 05:44:01 -0400 |
commit | 57135250358e54c237450f30474616f3d850b8de (patch) | |
tree | 0328dbaccdd1e1a0aab18fa341b14bfe5571e4b2 | |
parent | 7171511eaec5bf23fb06078f59784a3a0626b38f (diff) |
regulator: lp8755: Use devm_regulator_register
This patch moves data allocated using regulator_register to
devm_regulator_register and does away with the calls to
regulator_unregister. Also some labels are removed and a new labelerr is
introduced which is less specific to context.
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/lp8755.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/regulator/lp8755.c b/drivers/regulator/lp8755.c index 785a25e9a437..4a415d4ee463 100644 --- a/drivers/regulator/lp8755.c +++ b/drivers/regulator/lp8755.c | |||
@@ -339,22 +339,18 @@ static int lp8755_regulator_init(struct lp8755_chip *pchip) | |||
339 | rconfig.init_data = pdata->buck_data[buck_num]; | 339 | rconfig.init_data = pdata->buck_data[buck_num]; |
340 | rconfig.of_node = pchip->dev->of_node; | 340 | rconfig.of_node = pchip->dev->of_node; |
341 | pchip->rdev[buck_num] = | 341 | pchip->rdev[buck_num] = |
342 | regulator_register(&lp8755_regulators[buck_num], &rconfig); | 342 | devm_regulator_register(pchip->dev, |
343 | &lp8755_regulators[buck_num], &rconfig); | ||
343 | if (IS_ERR(pchip->rdev[buck_num])) { | 344 | if (IS_ERR(pchip->rdev[buck_num])) { |
344 | ret = PTR_ERR(pchip->rdev[buck_num]); | 345 | ret = PTR_ERR(pchip->rdev[buck_num]); |
345 | pchip->rdev[buck_num] = NULL; | 346 | pchip->rdev[buck_num] = NULL; |
346 | dev_err(pchip->dev, "regulator init failed: buck %d\n", | 347 | dev_err(pchip->dev, "regulator init failed: buck %d\n", |
347 | buck_num); | 348 | buck_num); |
348 | goto err_buck; | 349 | return ret; |
349 | } | 350 | } |
350 | } | 351 | } |
351 | 352 | ||
352 | return 0; | 353 | return 0; |
353 | |||
354 | err_buck: | ||
355 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) | ||
356 | regulator_unregister(pchip->rdev[icnt]); | ||
357 | return ret; | ||
358 | } | 354 | } |
359 | 355 | ||
360 | static irqreturn_t lp8755_irq_handler(int irq, void *data) | 356 | static irqreturn_t lp8755_irq_handler(int irq, void *data) |
@@ -490,23 +486,19 @@ static int lp8755_probe(struct i2c_client *client, | |||
490 | ret = lp8755_regulator_init(pchip); | 486 | ret = lp8755_regulator_init(pchip); |
491 | if (ret < 0) { | 487 | if (ret < 0) { |
492 | dev_err(&client->dev, "fail to initialize regulators\n"); | 488 | dev_err(&client->dev, "fail to initialize regulators\n"); |
493 | goto err_regulator; | 489 | goto err; |
494 | } | 490 | } |
495 | 491 | ||
496 | pchip->irq = client->irq; | 492 | pchip->irq = client->irq; |
497 | ret = lp8755_int_config(pchip); | 493 | ret = lp8755_int_config(pchip); |
498 | if (ret < 0) { | 494 | if (ret < 0) { |
499 | dev_err(&client->dev, "fail to irq config\n"); | 495 | dev_err(&client->dev, "fail to irq config\n"); |
500 | goto err_irq; | 496 | goto err; |
501 | } | 497 | } |
502 | 498 | ||
503 | return ret; | 499 | return ret; |
504 | 500 | ||
505 | err_irq: | 501 | err: |
506 | for (icnt = 0; icnt < mphase_buck[pchip->mphase].nreg; icnt++) | ||
507 | regulator_unregister(pchip->rdev[icnt]); | ||
508 | |||
509 | err_regulator: | ||
510 | /* output disable */ | 502 | /* output disable */ |
511 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) | 503 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) |
512 | lp8755_write(pchip, icnt, 0x00); | 504 | lp8755_write(pchip, icnt, 0x00); |
@@ -519,9 +511,6 @@ static int lp8755_remove(struct i2c_client *client) | |||
519 | int icnt; | 511 | int icnt; |
520 | struct lp8755_chip *pchip = i2c_get_clientdata(client); | 512 | struct lp8755_chip *pchip = i2c_get_clientdata(client); |
521 | 513 | ||
522 | for (icnt = 0; icnt < mphase_buck[pchip->mphase].nreg; icnt++) | ||
523 | regulator_unregister(pchip->rdev[icnt]); | ||
524 | |||
525 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) | 514 | for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) |
526 | lp8755_write(pchip, icnt, 0x00); | 515 | lp8755_write(pchip, icnt, 0x00); |
527 | 516 | ||