Commit 93227c801372522d6f667aac0de2cacc7995d8b9

Authored by Axel Lin
Committed by Mark Brown
1 parent 6ce4eac1f6

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>

Showing 1 changed file with 6 additions and 35 deletions Side-by-side Diff

drivers/regulator/lp3972.c
... ... @@ -22,8 +22,6 @@
22 22 struct device *dev;
23 23 struct mutex io_lock;
24 24 struct i2c_client *i2c;
25   - int num_regulators;
26   - struct regulator_dev **rdev;
27 25 };
28 26  
29 27 /* LP3972 Control Registers */
30 28  
31 29  
32 30  
33 31  
... ... @@ -478,41 +476,27 @@
478 476 {
479 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 479 /* Instantiate the regulators */
490 480 for (i = 0; i < pdata->num_regulators; i++) {
491 481 struct lp3972_regulator_subdev *reg = &pdata->regulators[i];
492 482 struct regulator_config config = { };
  483 + struct regulator_dev *rdev;
493 484  
494 485 config.dev = lp3972->dev;
495 486 config.init_data = reg->initdata;
496 487 config.driver_data = lp3972;
497 488  
498   - lp3972->rdev[i] = regulator_register(&regulators[reg->id],
499   - &config);
500   - if (IS_ERR(lp3972->rdev[i])) {
501   - err = PTR_ERR(lp3972->rdev[i]);
  489 + rdev = devm_regulator_register(lp3972->dev,
  490 + &regulators[reg->id], &config);
  491 + if (IS_ERR(rdev)) {
  492 + err = PTR_ERR(rdev);
502 493 dev_err(lp3972->dev, "regulator init failed: %d\n",
503 494 err);
504   - goto error;
  495 + return err;
505 496 }
506 497 }
507 498  
508 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 502 static int lp3972_i2c_probe(struct i2c_client *i2c,
... ... @@ -557,18 +541,6 @@
557 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 544 static const struct i2c_device_id lp3972_i2c_id[] = {
573 545 { "lp3972", 0 },
574 546 { }
... ... @@ -581,7 +553,6 @@
581 553 .owner = THIS_MODULE,
582 554 },
583 555 .probe = lp3972_i2c_probe,
584   - .remove = lp3972_i2c_remove,
585 556 .id_table = lp3972_i2c_id,
586 557 };
587 558