diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-11-13 01:55:14 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-24 09:02:18 -0500 |
commit | 93227c801372522d6f667aac0de2cacc7995d8b9 (patch) | |
tree | ba27b9c002e6255f62d54615f272265337ef6bfb | |
parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) |
regulator: lp3972: Convert to devm_regulator_register
Both num_regulators and **rdev are no longer required after this conversion,
thus remove them from struct lp3972.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/lp3972.c | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index 093e6f44ff8a..aea485afcc1a 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c | |||
@@ -22,8 +22,6 @@ struct lp3972 { | |||
22 | struct device *dev; | 22 | struct device *dev; |
23 | struct mutex io_lock; | 23 | struct mutex io_lock; |
24 | struct i2c_client *i2c; | 24 | struct i2c_client *i2c; |
25 | int num_regulators; | ||
26 | struct regulator_dev **rdev; | ||
27 | }; | 25 | }; |
28 | 26 | ||
29 | /* LP3972 Control Registers */ | 27 | /* LP3972 Control Registers */ |
@@ -478,41 +476,27 @@ static int setup_regulators(struct lp3972 *lp3972, | |||
478 | { | 476 | { |
479 | int i, err; | 477 | int i, err; |
480 | 478 | ||
481 | lp3972->num_regulators = pdata->num_regulators; | ||
482 | lp3972->rdev = kcalloc(pdata->num_regulators, | ||
483 | sizeof(struct regulator_dev *), GFP_KERNEL); | ||
484 | if (!lp3972->rdev) { | ||
485 | err = -ENOMEM; | ||
486 | goto err_nomem; | ||
487 | } | ||
488 | |||
489 | /* Instantiate the regulators */ | 479 | /* Instantiate the regulators */ |
490 | for (i = 0; i < pdata->num_regulators; i++) { | 480 | for (i = 0; i < pdata->num_regulators; i++) { |
491 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; | 481 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; |
492 | struct regulator_config config = { }; | 482 | struct regulator_config config = { }; |
483 | struct regulator_dev *rdev; | ||
493 | 484 | ||
494 | config.dev = lp3972->dev; | 485 | config.dev = lp3972->dev; |
495 | config.init_data = reg->initdata; | 486 | config.init_data = reg->initdata; |
496 | config.driver_data = lp3972; | 487 | config.driver_data = lp3972; |
497 | 488 | ||
498 | lp3972->rdev[i] = regulator_register(®ulators[reg->id], | 489 | rdev = devm_regulator_register(lp3972->dev, |
499 | &config); | 490 | ®ulators[reg->id], &config); |
500 | if (IS_ERR(lp3972->rdev[i])) { | 491 | if (IS_ERR(rdev)) { |
501 | err = PTR_ERR(lp3972->rdev[i]); | 492 | err = PTR_ERR(rdev); |
502 | dev_err(lp3972->dev, "regulator init failed: %d\n", | 493 | dev_err(lp3972->dev, "regulator init failed: %d\n", |
503 | err); | 494 | err); |
504 | goto error; | 495 | return err; |
505 | } | 496 | } |
506 | } | 497 | } |
507 | 498 | ||
508 | return 0; | 499 | return 0; |
509 | error: | ||
510 | while (--i >= 0) | ||
511 | regulator_unregister(lp3972->rdev[i]); | ||
512 | kfree(lp3972->rdev); | ||
513 | lp3972->rdev = NULL; | ||
514 | err_nomem: | ||
515 | return err; | ||
516 | } | 500 | } |
517 | 501 | ||
518 | static int lp3972_i2c_probe(struct i2c_client *i2c, | 502 | static int lp3972_i2c_probe(struct i2c_client *i2c, |
@@ -557,18 +541,6 @@ static int lp3972_i2c_probe(struct i2c_client *i2c, | |||
557 | return 0; | 541 | return 0; |
558 | } | 542 | } |
559 | 543 | ||
560 | static int lp3972_i2c_remove(struct i2c_client *i2c) | ||
561 | { | ||
562 | struct lp3972 *lp3972 = i2c_get_clientdata(i2c); | ||
563 | int i; | ||
564 | |||
565 | for (i = 0; i < lp3972->num_regulators; i++) | ||
566 | regulator_unregister(lp3972->rdev[i]); | ||
567 | kfree(lp3972->rdev); | ||
568 | |||
569 | return 0; | ||
570 | } | ||
571 | |||
572 | static const struct i2c_device_id lp3972_i2c_id[] = { | 544 | static const struct i2c_device_id lp3972_i2c_id[] = { |
573 | { "lp3972", 0 }, | 545 | { "lp3972", 0 }, |
574 | { } | 546 | { } |
@@ -581,7 +553,6 @@ static struct i2c_driver lp3972_i2c_driver = { | |||
581 | .owner = THIS_MODULE, | 553 | .owner = THIS_MODULE, |
582 | }, | 554 | }, |
583 | .probe = lp3972_i2c_probe, | 555 | .probe = lp3972_i2c_probe, |
584 | .remove = lp3972_i2c_remove, | ||
585 | .id_table = lp3972_i2c_id, | 556 | .id_table = lp3972_i2c_id, |
586 | }; | 557 | }; |
587 | 558 | ||