Commit 68d8c1cd5158e1452c454dadbc64b3955e88e98b

Authored by Laxman Dewangan
Committed by Mark Brown
1 parent 33a6943d2c

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>

Showing 1 changed file with 9 additions and 18 deletions Side-by-side Diff

drivers/regulator/tps65910-regulator.c
... ... @@ -1183,25 +1183,25 @@
1183 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 1187 sizeof(struct regulator_desc), GFP_KERNEL);
1188 1188 if (!pmic->desc) {
1189   - err = -ENOMEM;
1190   - goto err_out;
  1189 + dev_err(&pdev->dev, "Memory alloc fails for desc\n");
  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 1194 sizeof(struct tps_info *), GFP_KERNEL);
1195 1195 if (!pmic->info) {
1196   - err = -ENOMEM;
1197   - goto err_free_desc;
  1196 + dev_err(&pdev->dev, "Memory alloc fails for info\n");
  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 1201 sizeof(struct regulator_dev *), GFP_KERNEL);
1202 1202 if (!pmic->rdev) {
1203   - err = -ENOMEM;
1204   - goto err_free_info;
  1203 + dev_err(&pdev->dev, "Memory alloc fails for rdev\n");
  1204 + return -ENOMEM;
1205 1205 }
1206 1206  
1207 1207 for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS;
... ... @@ -1279,12 +1279,6 @@
1279 1279 err_unregister_regulator:
1280 1280 while (--i >= 0)
1281 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 1282 return err;
1289 1283 }
1290 1284  
... ... @@ -1296,9 +1290,6 @@
1296 1290 for (i = 0; i < pmic->num_regulators; i++)
1297 1291 regulator_unregister(pmic->rdev[i]);
1298 1292  
1299   - kfree(pmic->rdev);
1300   - kfree(pmic->info);
1301   - kfree(pmic->desc);
1302 1293 return 0;
1303 1294 }
1304 1295