lkml.org 
[lkml]   [2013]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 09/20] regulator: lp3972: use devm_regulator_register()
Date
Use devm_regulator_register() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/regulator/lp3972.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 093e6f4..3c18042 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -495,8 +495,9 @@ static int setup_regulators(struct lp3972 *lp3972,
config.init_data = reg->initdata;
config.driver_data = lp3972;

- lp3972->rdev[i] = regulator_register(&regulators[reg->id],
- &config);
+ lp3972->rdev[i] = devm_regulator_register(lp3972->dev,
+ &regulators[reg->id],
+ &config);
if (IS_ERR(lp3972->rdev[i])) {
err = PTR_ERR(lp3972->rdev[i]);
dev_err(lp3972->dev, "regulator init failed: %d\n",
@@ -507,8 +508,6 @@ static int setup_regulators(struct lp3972 *lp3972,

return 0;
error:
- while (--i >= 0)
- regulator_unregister(lp3972->rdev[i]);
kfree(lp3972->rdev);
lp3972->rdev = NULL;
err_nomem:
@@ -560,10 +559,7 @@ static int lp3972_i2c_probe(struct i2c_client *i2c,
static int lp3972_i2c_remove(struct i2c_client *i2c)
{
struct lp3972 *lp3972 = i2c_get_clientdata(i2c);
- int i;

- for (i = 0; i < lp3972->num_regulators; i++)
- regulator_unregister(lp3972->rdev[i]);
kfree(lp3972->rdev);

return 0;
--
1.7.10.4



\
 
 \ /
  Last update: 2013-09-25 10:41    [W:0.077 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site