aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/palmas-regulator.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-24 06:11:32 -0400
committerMark Brown <broonie@linaro.org>2013-10-24 06:11:32 -0400
commit420118d48311e0c4ef4aace5aede35079ecc2412 (patch)
treea4affbc11b9271d786b9c9e5711b1e7dc873d3e8 /drivers/regulator/palmas-regulator.c
parent2a2bec6554e9e9d0ae351575ca1f72df1fa0f15f (diff)
parent32dadef2190efd2e06331825b11881daf100d6d9 (diff)
Merge remote-tracking branch 'regulator/topic/alias' into regulator-next
Diffstat (limited to 'drivers/regulator/palmas-regulator.c')
-rw-r--r--drivers/regulator/palmas-regulator.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 7e2b165972e6..4f79c0d61faf 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -856,7 +856,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
856 if (ret < 0) { 856 if (ret < 0) {
857 dev_err(&pdev->dev, 857 dev_err(&pdev->dev,
858 "reading TSTEP reg failed: %d\n", ret); 858 "reading TSTEP reg failed: %d\n", ret);
859 goto err_unregister_regulator; 859 return ret;
860 } 860 }
861 pmic->desc[id].ramp_delay = 861 pmic->desc[id].ramp_delay =
862 palmas_smps_ramp_delay[reg & 0x3]; 862 palmas_smps_ramp_delay[reg & 0x3];
@@ -868,7 +868,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
868 reg_init = pdata->reg_init[id]; 868 reg_init = pdata->reg_init[id];
869 ret = palmas_smps_init(palmas, id, reg_init); 869 ret = palmas_smps_init(palmas, id, reg_init);
870 if (ret) 870 if (ret)
871 goto err_unregister_regulator; 871 return ret;
872 } 872 }
873 873
874 /* Register the regulators */ 874 /* Register the regulators */
@@ -909,7 +909,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
909 909
910 ret = palmas_smps_read(pmic->palmas, addr, &reg); 910 ret = palmas_smps_read(pmic->palmas, addr, &reg);
911 if (ret) 911 if (ret)
912 goto err_unregister_regulator; 912 return ret;
913 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) 913 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE)
914 pmic->range[id] = 1; 914 pmic->range[id] = 1;
915 915
@@ -925,7 +925,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
925 addr = palmas_regs_info[id].ctrl_addr; 925 addr = palmas_regs_info[id].ctrl_addr;
926 ret = palmas_smps_read(pmic->palmas, addr, &reg); 926 ret = palmas_smps_read(pmic->palmas, addr, &reg);
927 if (ret) 927 if (ret)
928 goto err_unregister_regulator; 928 return ret;
929 pmic->current_reg_mode[id] = reg & 929 pmic->current_reg_mode[id] = reg &
930 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 930 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
931 } 931 }
@@ -941,13 +941,13 @@ static int palmas_regulators_probe(struct platform_device *pdev)
941 pmic->desc[id].supply_name = palmas_regs_info[id].sname; 941 pmic->desc[id].supply_name = palmas_regs_info[id].sname;
942 config.of_node = palmas_matches[id].of_node; 942 config.of_node = palmas_matches[id].of_node;
943 943
944 rdev = regulator_register(&pmic->desc[id], &config); 944 rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id],
945 &config);
945 if (IS_ERR(rdev)) { 946 if (IS_ERR(rdev)) {
946 dev_err(&pdev->dev, 947 dev_err(&pdev->dev,
947 "failed to register %s regulator\n", 948 "failed to register %s regulator\n",
948 pdev->name); 949 pdev->name);
949 ret = PTR_ERR(rdev); 950 return PTR_ERR(rdev);
950 goto err_unregister_regulator;
951 } 951 }
952 952
953 /* Save regulator for cleanup */ 953 /* Save regulator for cleanup */
@@ -1015,13 +1015,13 @@ static int palmas_regulators_probe(struct platform_device *pdev)
1015 pmic->desc[id].supply_name = palmas_regs_info[id].sname; 1015 pmic->desc[id].supply_name = palmas_regs_info[id].sname;
1016 config.of_node = palmas_matches[id].of_node; 1016 config.of_node = palmas_matches[id].of_node;
1017 1017
1018 rdev = regulator_register(&pmic->desc[id], &config); 1018 rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id],
1019 &config);
1019 if (IS_ERR(rdev)) { 1020 if (IS_ERR(rdev)) {
1020 dev_err(&pdev->dev, 1021 dev_err(&pdev->dev,
1021 "failed to register %s regulator\n", 1022 "failed to register %s regulator\n",
1022 pdev->name); 1023 pdev->name);
1023 ret = PTR_ERR(rdev); 1024 return PTR_ERR(rdev);
1024 goto err_unregister_regulator;
1025 } 1025 }
1026 1026
1027 /* Save regulator for cleanup */ 1027 /* Save regulator for cleanup */
@@ -1037,31 +1037,14 @@ static int palmas_regulators_probe(struct platform_device *pdev)
1037 else 1037 else
1038 ret = palmas_extreg_init(palmas, 1038 ret = palmas_extreg_init(palmas,
1039 id, reg_init); 1039 id, reg_init);
1040 if (ret) { 1040 if (ret)
1041 regulator_unregister(pmic->rdev[id]); 1041 return ret;
1042 goto err_unregister_regulator;
1043 }
1044 } 1042 }
1045 } 1043 }
1046 } 1044 }
1047 1045
1048 1046
1049 return 0; 1047 return 0;
1050
1051err_unregister_regulator:
1052 while (--id >= 0)
1053 regulator_unregister(pmic->rdev[id]);
1054 return ret;
1055}
1056
1057static int palmas_regulators_remove(struct platform_device *pdev)
1058{
1059 struct palmas_pmic *pmic = platform_get_drvdata(pdev);
1060 int id;
1061
1062 for (id = 0; id < PALMAS_NUM_REGS; id++)
1063 regulator_unregister(pmic->rdev[id]);
1064 return 0;
1065} 1048}
1066 1049
1067static struct of_device_id of_palmas_match_tbl[] = { 1050static struct of_device_id of_palmas_match_tbl[] = {
@@ -1083,7 +1066,6 @@ static struct platform_driver palmas_driver = {
1083 .owner = THIS_MODULE, 1066 .owner = THIS_MODULE,
1084 }, 1067 },
1085 .probe = palmas_regulators_probe, 1068 .probe = palmas_regulators_probe,
1086 .remove = palmas_regulators_remove,
1087}; 1069};
1088 1070
1089static int __init palmas_init(void) 1071static int __init palmas_init(void)