aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8660.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-04 01:37:58 -0400
committerMark Brown <broonie@linaro.org>2013-09-16 19:28:41 -0400
commitdcfb6b56f18b5d9eff9b784d4e5b4a085f149de2 (patch)
tree2f6ad4c82116403d04124ae092081d885011de34 /drivers/regulator/max8660.c
parente453f92eec6d72db0d7fe6bab2e0a710dc6cd927 (diff)
regulator: max8660: Use devm_regulator_register
devm_* simplifies the code. [Fixups from rebase onto v3.12 code -- broonie] Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/max8660.c')
-rw-r--r--drivers/regulator/max8660.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index 144bcacd734d..8d94d3d7f97f 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -439,7 +439,7 @@ static int max8660_probe(struct i2c_client *client,
439 for (i = 0; i < pdata->num_subdevs; i++) { 439 for (i = 0; i < pdata->num_subdevs; i++) {
440 440
441 if (!pdata->subdevs[i].platform_data) 441 if (!pdata->subdevs[i].platform_data)
442 goto err_out; 442 return ret;
443 443
444 boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; 444 boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
445 445
@@ -465,7 +465,7 @@ static int max8660_probe(struct i2c_client *client,
465 case MAX8660_V7: 465 case MAX8660_V7:
466 if (type == MAX8661) { 466 if (type == MAX8661) {
467 dev_err(dev, "Regulator not on this chip!\n"); 467 dev_err(dev, "Regulator not on this chip!\n");
468 goto err_out; 468 return -EINVAL;
469 } 469 }
470 470
471 if (boot_on) 471 if (boot_on)
@@ -475,7 +475,7 @@ static int max8660_probe(struct i2c_client *client,
475 default: 475 default:
476 dev_err(dev, "invalid regulator %s\n", 476 dev_err(dev, "invalid regulator %s\n",
477 pdata->subdevs[i].name); 477 pdata->subdevs[i].name);
478 goto err_out; 478 return ret;
479 } 479 }
480 } 480 }
481 481
@@ -489,33 +489,18 @@ static int max8660_probe(struct i2c_client *client,
489 config.of_node = of_node[i]; 489 config.of_node = of_node[i];
490 config.driver_data = max8660; 490 config.driver_data = max8660;
491 491
492 rdev[i] = regulator_register(&max8660_reg[id], &config); 492 rdev[i] = devm_regulator_register(&client->dev,
493 &max8660_reg[id], &config);
493 if (IS_ERR(rdev[i])) { 494 if (IS_ERR(rdev[i])) {
494 ret = PTR_ERR(rdev[i]); 495 ret = PTR_ERR(rdev[i]);
495 dev_err(dev, "failed to register %s\n", 496 dev_err(&client->dev, "failed to register %s\n",
496 max8660_reg[id].name); 497 max8660_reg[id].name);
497 goto err_unregister; 498 return PTR_ERR(rdev[i]);
498 } 499 }
499 } 500 }
500 501
501 i2c_set_clientdata(client, max8660); 502 i2c_set_clientdata(client, max8660);
502 return 0; 503 return 0;
503
504err_unregister:
505 while (--i >= 0)
506 regulator_unregister(rdev[i]);
507err_out:
508 return ret;
509}
510
511static int max8660_remove(struct i2c_client *client)
512{
513 struct max8660 *max8660 = i2c_get_clientdata(client);
514 int i;
515
516 for (i = 0; i < MAX8660_V_END; i++)
517 regulator_unregister(max8660->rdev[i]);
518 return 0;
519} 504}
520 505
521static const struct i2c_device_id max8660_id[] = { 506static const struct i2c_device_id max8660_id[] = {
@@ -527,7 +512,6 @@ MODULE_DEVICE_TABLE(i2c, max8660_id);
527 512
528static struct i2c_driver max8660_driver = { 513static struct i2c_driver max8660_driver = {
529 .probe = max8660_probe, 514 .probe = max8660_probe,
530 .remove = max8660_remove,
531 .driver = { 515 .driver = {
532 .name = "max8660", 516 .name = "max8660",
533 .owner = THIS_MODULE, 517 .owner = THIS_MODULE,