Commit 68d8c1cd authored by Laxman Dewangan's avatar Laxman Dewangan Committed by Mark Brown

regulator: tps65910: use devm_* for memory allocation

use the devm_* apis for memory allocation.
Signed-off-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 33a6943d
...@@ -1183,25 +1183,25 @@ static __devinit int tps65910_probe(struct platform_device *pdev) ...@@ -1183,25 +1183,25 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
pmic->desc = kcalloc(pmic->num_regulators, pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators *
sizeof(struct regulator_desc), GFP_KERNEL); sizeof(struct regulator_desc), GFP_KERNEL);
if (!pmic->desc) { if (!pmic->desc) {
err = -ENOMEM; dev_err(&pdev->dev, "Memory alloc fails for desc\n");
goto err_out; return -ENOMEM;
} }
pmic->info = kcalloc(pmic->num_regulators, pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators *
sizeof(struct tps_info *), GFP_KERNEL); sizeof(struct tps_info *), GFP_KERNEL);
if (!pmic->info) { if (!pmic->info) {
err = -ENOMEM; dev_err(&pdev->dev, "Memory alloc fails for info\n");
goto err_free_desc; return -ENOMEM;
} }
pmic->rdev = kcalloc(pmic->num_regulators, pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators *
sizeof(struct regulator_dev *), GFP_KERNEL); sizeof(struct regulator_dev *), GFP_KERNEL);
if (!pmic->rdev) { if (!pmic->rdev) {
err = -ENOMEM; dev_err(&pdev->dev, "Memory alloc fails for rdev\n");
goto err_free_info; return -ENOMEM;
} }
for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; 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,12 +1279,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
err_unregister_regulator: err_unregister_regulator:
while (--i >= 0) while (--i >= 0)
regulator_unregister(pmic->rdev[i]); regulator_unregister(pmic->rdev[i]);
kfree(pmic->rdev);
err_free_info:
kfree(pmic->info);
err_free_desc:
kfree(pmic->desc);
err_out:
return err; return err;
} }
...@@ -1296,9 +1290,6 @@ static int __devexit tps65910_remove(struct platform_device *pdev) ...@@ -1296,9 +1290,6 @@ static int __devexit tps65910_remove(struct platform_device *pdev)
for (i = 0; i < pmic->num_regulators; i++) for (i = 0; i < pmic->num_regulators; i++)
regulator_unregister(pmic->rdev[i]); regulator_unregister(pmic->rdev[i]);
kfree(pmic->rdev);
kfree(pmic->info);
kfree(pmic->desc);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment