diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-05-19 10:34:09 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-19 13:41:29 -0400 |
commit | 68d8c1cd5158e1452c454dadbc64b3955e88e98b (patch) | |
tree | ec67a2d0fb7c80d28f2d9879b718cac8900bd8b1 /drivers/regulator | |
parent | 33a6943d2c7fb7567148cc80f016d0f65e3caf36 (diff) |
regulator: tps65910: use devm_* for memory allocation
use the devm_* apis for memory allocation.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 4833457438c2..521c9252be18 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -1183,25 +1183,25 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
1183 | return -ENODEV; | 1183 | return -ENODEV; |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | pmic->desc = kcalloc(pmic->num_regulators, | 1186 | pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators * |
1187 | sizeof(struct regulator_desc), GFP_KERNEL); | 1187 | sizeof(struct regulator_desc), GFP_KERNEL); |
1188 | if (!pmic->desc) { | 1188 | if (!pmic->desc) { |
1189 | err = -ENOMEM; | 1189 | dev_err(&pdev->dev, "Memory alloc fails for desc\n"); |
1190 | goto err_out; | 1190 | return -ENOMEM; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | pmic->info = kcalloc(pmic->num_regulators, | 1193 | pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators * |
1194 | sizeof(struct tps_info *), GFP_KERNEL); | 1194 | sizeof(struct tps_info *), GFP_KERNEL); |
1195 | if (!pmic->info) { | 1195 | if (!pmic->info) { |
1196 | err = -ENOMEM; | 1196 | dev_err(&pdev->dev, "Memory alloc fails for info\n"); |
1197 | goto err_free_desc; | 1197 | return -ENOMEM; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | pmic->rdev = kcalloc(pmic->num_regulators, | 1200 | pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators * |
1201 | sizeof(struct regulator_dev *), GFP_KERNEL); | 1201 | sizeof(struct regulator_dev *), GFP_KERNEL); |
1202 | if (!pmic->rdev) { | 1202 | if (!pmic->rdev) { |
1203 | err = -ENOMEM; | 1203 | dev_err(&pdev->dev, "Memory alloc fails for rdev\n"); |
1204 | goto err_free_info; | 1204 | return -ENOMEM; |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; | 1207 | for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; |
@@ -1279,12 +1279,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
1279 | err_unregister_regulator: | 1279 | err_unregister_regulator: |
1280 | while (--i >= 0) | 1280 | while (--i >= 0) |
1281 | regulator_unregister(pmic->rdev[i]); | 1281 | regulator_unregister(pmic->rdev[i]); |
1282 | kfree(pmic->rdev); | ||
1283 | err_free_info: | ||
1284 | kfree(pmic->info); | ||
1285 | err_free_desc: | ||
1286 | kfree(pmic->desc); | ||
1287 | err_out: | ||
1288 | return err; | 1282 | return err; |
1289 | } | 1283 | } |
1290 | 1284 | ||
@@ -1296,9 +1290,6 @@ static int __devexit tps65910_remove(struct platform_device *pdev) | |||
1296 | for (i = 0; i < pmic->num_regulators; i++) | 1290 | for (i = 0; i < pmic->num_regulators; i++) |
1297 | regulator_unregister(pmic->rdev[i]); | 1291 | regulator_unregister(pmic->rdev[i]); |
1298 | 1292 | ||
1299 | kfree(pmic->rdev); | ||
1300 | kfree(pmic->info); | ||
1301 | kfree(pmic->desc); | ||
1302 | return 0; | 1293 | return 0; |
1303 | } | 1294 | } |
1304 | 1295 | ||