aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-11 02:40:18 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-11 05:16:50 -0400
commit9eb0c4218aa444f863e7f54909351d5b4f0fac06 (patch)
treebcb7413f475d7e67d93d3bb1826f2eb3ef7479b1
parentd914d81b74fd4e91aed334c3f664be4b94364ee8 (diff)
regulator: Convert tps65xxx regulator drivers to use devm_kzalloc
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/tps6507x-regulator.c7
-rw-r--r--drivers/regulator/tps6524x-regulator.c3
-rw-r--r--drivers/regulator/tps65910-regulator.c9
-rw-r--r--drivers/regulator/tps65912-regulator.c6
4 files changed, 6 insertions, 19 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index 16d27fc2c7f7..8e432004b949 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -429,7 +429,7 @@ static __devinit int tps6507x_pmic_probe(struct platform_device *pdev)
429 if (!init_data) 429 if (!init_data)
430 return -EINVAL; 430 return -EINVAL;
431 431
432 tps = kzalloc(sizeof(*tps), GFP_KERNEL); 432 tps = devm_kzalloc(&pdev->dev, sizeof(*tps), GFP_KERNEL);
433 if (!tps) 433 if (!tps)
434 return -ENOMEM; 434 return -ENOMEM;
435 435
@@ -479,8 +479,6 @@ static __devinit int tps6507x_pmic_probe(struct platform_device *pdev)
479fail: 479fail:
480 while (--i >= 0) 480 while (--i >= 0)
481 regulator_unregister(tps->rdev[i]); 481 regulator_unregister(tps->rdev[i]);
482
483 kfree(tps);
484 return error; 482 return error;
485} 483}
486 484
@@ -492,9 +490,6 @@ static int __devexit tps6507x_pmic_remove(struct platform_device *pdev)
492 490
493 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) 491 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++)
494 regulator_unregister(tps->rdev[i]); 492 regulator_unregister(tps->rdev[i]);
495
496 kfree(tps);
497
498 return 0; 493 return 0;
499} 494}
500 495
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c
index 6616af7d2956..b88b3df82381 100644
--- a/drivers/regulator/tps6524x-regulator.c
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -595,7 +595,6 @@ static int pmic_remove(struct spi_device *spi)
595 hw->rdev[i] = NULL; 595 hw->rdev[i] = NULL;
596 } 596 }
597 spi_set_drvdata(spi, NULL); 597 spi_set_drvdata(spi, NULL);
598 kfree(hw);
599 return 0; 598 return 0;
600} 599}
601 600
@@ -614,7 +613,7 @@ static int __devinit pmic_probe(struct spi_device *spi)
614 return -EINVAL; 613 return -EINVAL;
615 } 614 }
616 615
617 hw = kzalloc(sizeof(struct tps6524x), GFP_KERNEL); 616 hw = devm_kzalloc(&spi->dev, sizeof(struct tps6524x), GFP_KERNEL);
618 if (!hw) { 617 if (!hw) {
619 dev_err(dev, "cannot allocate regulator private data\n"); 618 dev_err(dev, "cannot allocate regulator private data\n");
620 return -ENOMEM; 619 return -ENOMEM;
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index e7a4ece10628..fe66a2c43fd9 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1109,7 +1109,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
1109 if (!pmic_plat_data) 1109 if (!pmic_plat_data)
1110 return -EINVAL; 1110 return -EINVAL;
1111 1111
1112 pmic = kzalloc(sizeof(*pmic), GFP_KERNEL); 1112 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
1113 if (!pmic) 1113 if (!pmic)
1114 return -ENOMEM; 1114 return -ENOMEM;
1115 1115
@@ -1136,7 +1136,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
1136 break; 1136 break;
1137 default: 1137 default:
1138 pr_err("Invalid tps chip version\n"); 1138 pr_err("Invalid tps chip version\n");
1139 kfree(pmic);
1140 return -ENODEV; 1139 return -ENODEV;
1141 } 1140 }
1142 1141
@@ -1144,7 +1143,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
1144 sizeof(struct regulator_desc), GFP_KERNEL); 1143 sizeof(struct regulator_desc), GFP_KERNEL);
1145 if (!pmic->desc) { 1144 if (!pmic->desc) {
1146 err = -ENOMEM; 1145 err = -ENOMEM;
1147 goto err_free_pmic; 1146 goto err_out;
1148 } 1147 }
1149 1148
1150 pmic->info = kcalloc(pmic->num_regulators, 1149 pmic->info = kcalloc(pmic->num_regulators,
@@ -1233,8 +1232,7 @@ err_free_info:
1233 kfree(pmic->info); 1232 kfree(pmic->info);
1234err_free_desc: 1233err_free_desc:
1235 kfree(pmic->desc); 1234 kfree(pmic->desc);
1236err_free_pmic: 1235err_out:
1237 kfree(pmic);
1238 return err; 1236 return err;
1239} 1237}
1240 1238
@@ -1249,7 +1247,6 @@ static int __devexit tps65910_remove(struct platform_device *pdev)
1249 kfree(pmic->rdev); 1247 kfree(pmic->rdev);
1250 kfree(pmic->info); 1248 kfree(pmic->info);
1251 kfree(pmic->desc); 1249 kfree(pmic->desc);
1252 kfree(pmic);
1253 return 0; 1250 return 0;
1254} 1251}
1255 1252
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 8c9c61383fee..af335dd35903 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -477,7 +477,7 @@ static __devinit int tps65912_probe(struct platform_device *pdev)
477 477
478 reg_data = pmic_plat_data->tps65912_pmic_init_data; 478 reg_data = pmic_plat_data->tps65912_pmic_init_data;
479 479
480 pmic = kzalloc(sizeof(*pmic), GFP_KERNEL); 480 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
481 if (!pmic) 481 if (!pmic)
482 return -ENOMEM; 482 return -ENOMEM;
483 483
@@ -523,8 +523,6 @@ static __devinit int tps65912_probe(struct platform_device *pdev)
523err: 523err:
524 while (--i >= 0) 524 while (--i >= 0)
525 regulator_unregister(pmic->rdev[i]); 525 regulator_unregister(pmic->rdev[i]);
526
527 kfree(pmic);
528 return err; 526 return err;
529} 527}
530 528
@@ -535,8 +533,6 @@ static int __devexit tps65912_remove(struct platform_device *pdev)
535 533
536 for (i = 0; i < TPS65912_NUM_REGULATOR; i++) 534 for (i = 0; i < TPS65912_NUM_REGULATOR; i++)
537 regulator_unregister(tps65912_reg->rdev[i]); 535 regulator_unregister(tps65912_reg->rdev[i]);
538
539 kfree(tps65912_reg);
540 return 0; 536 return 0;
541} 537}
542 538