diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-11-13 01:52:26 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-13 08:24:44 -0500 |
commit | 56dde80a1a62b1f84f9ba7d2aee267dc9476ee58 (patch) | |
tree | f9e49adffa8dac744e70b0a974770361aa12f908 /drivers/regulator | |
parent | d4d5cef649d1042454c286474343cec50ff1cb60 (diff) |
regulator: lp3971: Convert to devm_regulator_register
Both num_regulators and **rdev are no longer required after this conversion,
thus remove them from struct lp3971.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/lp3971.c | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 947c05ffe0ab..3b1102b75071 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -25,8 +25,6 @@ struct lp3971 { | |||
25 | struct device *dev; | 25 | struct device *dev; |
26 | struct mutex io_lock; | 26 | struct mutex io_lock; |
27 | struct i2c_client *i2c; | 27 | struct i2c_client *i2c; |
28 | int num_regulators; | ||
29 | struct regulator_dev **rdev; | ||
30 | }; | 28 | }; |
31 | 29 | ||
32 | static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg); | 30 | static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg); |
@@ -383,42 +381,27 @@ static int setup_regulators(struct lp3971 *lp3971, | |||
383 | { | 381 | { |
384 | int i, err; | 382 | int i, err; |
385 | 383 | ||
386 | lp3971->num_regulators = pdata->num_regulators; | ||
387 | lp3971->rdev = kcalloc(pdata->num_regulators, | ||
388 | sizeof(struct regulator_dev *), GFP_KERNEL); | ||
389 | if (!lp3971->rdev) { | ||
390 | err = -ENOMEM; | ||
391 | goto err_nomem; | ||
392 | } | ||
393 | |||
394 | /* Instantiate the regulators */ | 384 | /* Instantiate the regulators */ |
395 | for (i = 0; i < pdata->num_regulators; i++) { | 385 | for (i = 0; i < pdata->num_regulators; i++) { |
396 | struct regulator_config config = { }; | 386 | struct regulator_config config = { }; |
397 | struct lp3971_regulator_subdev *reg = &pdata->regulators[i]; | 387 | struct lp3971_regulator_subdev *reg = &pdata->regulators[i]; |
388 | struct regulator_dev *rdev; | ||
398 | 389 | ||
399 | config.dev = lp3971->dev; | 390 | config.dev = lp3971->dev; |
400 | config.init_data = reg->initdata; | 391 | config.init_data = reg->initdata; |
401 | config.driver_data = lp3971; | 392 | config.driver_data = lp3971; |
402 | 393 | ||
403 | lp3971->rdev[i] = regulator_register(®ulators[reg->id], | 394 | rdev = devm_regulator_register(lp3971->dev, |
404 | &config); | 395 | ®ulators[reg->id], &config); |
405 | if (IS_ERR(lp3971->rdev[i])) { | 396 | if (IS_ERR(rdev)) { |
406 | err = PTR_ERR(lp3971->rdev[i]); | 397 | err = PTR_ERR(rdev); |
407 | dev_err(lp3971->dev, "regulator init failed: %d\n", | 398 | dev_err(lp3971->dev, "regulator init failed: %d\n", |
408 | err); | 399 | err); |
409 | goto error; | 400 | return err; |
410 | } | 401 | } |
411 | } | 402 | } |
412 | 403 | ||
413 | return 0; | 404 | return 0; |
414 | |||
415 | error: | ||
416 | while (--i >= 0) | ||
417 | regulator_unregister(lp3971->rdev[i]); | ||
418 | kfree(lp3971->rdev); | ||
419 | lp3971->rdev = NULL; | ||
420 | err_nomem: | ||
421 | return err; | ||
422 | } | 405 | } |
423 | 406 | ||
424 | static int lp3971_i2c_probe(struct i2c_client *i2c, | 407 | static int lp3971_i2c_probe(struct i2c_client *i2c, |
@@ -460,19 +443,6 @@ static int lp3971_i2c_probe(struct i2c_client *i2c, | |||
460 | return 0; | 443 | return 0; |
461 | } | 444 | } |
462 | 445 | ||
463 | static int lp3971_i2c_remove(struct i2c_client *i2c) | ||
464 | { | ||
465 | struct lp3971 *lp3971 = i2c_get_clientdata(i2c); | ||
466 | int i; | ||
467 | |||
468 | for (i = 0; i < lp3971->num_regulators; i++) | ||
469 | regulator_unregister(lp3971->rdev[i]); | ||
470 | |||
471 | kfree(lp3971->rdev); | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static const struct i2c_device_id lp3971_i2c_id[] = { | 446 | static const struct i2c_device_id lp3971_i2c_id[] = { |
477 | { "lp3971", 0 }, | 447 | { "lp3971", 0 }, |
478 | { } | 448 | { } |
@@ -485,7 +455,6 @@ static struct i2c_driver lp3971_i2c_driver = { | |||
485 | .owner = THIS_MODULE, | 455 | .owner = THIS_MODULE, |
486 | }, | 456 | }, |
487 | .probe = lp3971_i2c_probe, | 457 | .probe = lp3971_i2c_probe, |
488 | .remove = lp3971_i2c_remove, | ||
489 | .id_table = lp3971_i2c_id, | 458 | .id_table = lp3971_i2c_id, |
490 | }; | 459 | }; |
491 | 460 | ||