summaryrefslogtreecommitdiff
path: root/drivers/regulator/lp3972.c
diff options
context:
space:
mode:
authorNikolay Balandin <nbalandin@dev.rtsoft.ru>2013-05-26 01:50:40 +0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-05-27 16:18:30 +0400
commit2af0af67354b7c9b17d28e6ab47a8177afec125d (patch)
tree6009ef47039f6300162a0713304fe85e651aeac8 /drivers/regulator/lp3972.c
parente4aa937ec75df0eea0bee03bffa3303ad36c986b (diff)
downloadlinux-2af0af67354b7c9b17d28e6ab47a8177afec125d.tar.xz
regulator: lp397x: use devm_kzalloc() to make cleanup paths simpler
Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/lp3972.c')
-rw-r--r--drivers/regulator/lp3972.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 61e4cf9edf6e..573024039ca0 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -528,7 +528,7 @@ static int lp3972_i2c_probe(struct i2c_client *i2c,
return -ENODEV;
}
- lp3972 = kzalloc(sizeof(struct lp3972), GFP_KERNEL);
+ lp3972 = devm_kzalloc(&i2c->dev, sizeof(struct lp3972), GFP_KERNEL);
if (!lp3972)
return -ENOMEM;
@@ -546,19 +546,15 @@ static int lp3972_i2c_probe(struct i2c_client *i2c,
}
if (ret < 0) {
dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret);
- goto err_detect;
+ return ret;
}
ret = setup_regulators(lp3972, pdata);
if (ret < 0)
- goto err_detect;
+ return ret;
i2c_set_clientdata(i2c, lp3972);
return 0;
-
-err_detect:
- kfree(lp3972);
- return ret;
}
static int lp3972_i2c_remove(struct i2c_client *i2c)
@@ -569,7 +565,6 @@ static int lp3972_i2c_remove(struct i2c_client *i2c)
for (i = 0; i < lp3972->num_regulators; i++)
regulator_unregister(lp3972->rdev[i]);
kfree(lp3972->rdev);
- kfree(lp3972);
return 0;
}