diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-09-04 01:38:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:28:41 -0400 |
commit | 4177f95b8433f809228ab485e3303ae4708c98ca (patch) | |
tree | 189de9c6f9cd4c451d6270fff08780808690534c /drivers/regulator/max8997.c | |
parent | 8d581fd01c922f9df586074078d70027156cfff8 (diff) |
regulator: max8997: Use devm_regulator_register
devm_* simplifies the code.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r-- | drivers/regulator/max8997.c | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index df20069f0537..059e8ed7fa24 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -1081,7 +1081,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1081 | pdata->buck1_voltage[i] + | 1081 | pdata->buck1_voltage[i] + |
1082 | buck1245_voltage_map_desc.step); | 1082 | buck1245_voltage_map_desc.step); |
1083 | if (ret < 0) | 1083 | if (ret < 0) |
1084 | goto err_out; | 1084 | return ret; |
1085 | 1085 | ||
1086 | max8997->buck2_vol[i] = ret = | 1086 | max8997->buck2_vol[i] = ret = |
1087 | max8997_get_voltage_proper_val( | 1087 | max8997_get_voltage_proper_val( |
@@ -1090,7 +1090,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1090 | pdata->buck2_voltage[i] + | 1090 | pdata->buck2_voltage[i] + |
1091 | buck1245_voltage_map_desc.step); | 1091 | buck1245_voltage_map_desc.step); |
1092 | if (ret < 0) | 1092 | if (ret < 0) |
1093 | goto err_out; | 1093 | return ret; |
1094 | 1094 | ||
1095 | max8997->buck5_vol[i] = ret = | 1095 | max8997->buck5_vol[i] = ret = |
1096 | max8997_get_voltage_proper_val( | 1096 | max8997_get_voltage_proper_val( |
@@ -1099,7 +1099,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1099 | pdata->buck5_voltage[i] + | 1099 | pdata->buck5_voltage[i] + |
1100 | buck1245_voltage_map_desc.step); | 1100 | buck1245_voltage_map_desc.step); |
1101 | if (ret < 0) | 1101 | if (ret < 0) |
1102 | goto err_out; | 1102 | return ret; |
1103 | 1103 | ||
1104 | if (max_buck1 < max8997->buck1_vol[i]) | 1104 | if (max_buck1 < max8997->buck1_vol[i]) |
1105 | max_buck1 = max8997->buck1_vol[i]; | 1105 | max_buck1 = max8997->buck1_vol[i]; |
@@ -1143,24 +1143,23 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1143 | !gpio_is_valid(pdata->buck125_gpios[1]) || | 1143 | !gpio_is_valid(pdata->buck125_gpios[1]) || |
1144 | !gpio_is_valid(pdata->buck125_gpios[2])) { | 1144 | !gpio_is_valid(pdata->buck125_gpios[2])) { |
1145 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); | 1145 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); |
1146 | ret = -EINVAL; | 1146 | return -EINVAL; |
1147 | goto err_out; | ||
1148 | } | 1147 | } |
1149 | 1148 | ||
1150 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], | 1149 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], |
1151 | "MAX8997 SET1"); | 1150 | "MAX8997 SET1"); |
1152 | if (ret) | 1151 | if (ret) |
1153 | goto err_out; | 1152 | return ret; |
1154 | 1153 | ||
1155 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], | 1154 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], |
1156 | "MAX8997 SET2"); | 1155 | "MAX8997 SET2"); |
1157 | if (ret) | 1156 | if (ret) |
1158 | goto err_out; | 1157 | return ret; |
1159 | 1158 | ||
1160 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], | 1159 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], |
1161 | "MAX8997 SET3"); | 1160 | "MAX8997 SET3"); |
1162 | if (ret) | 1161 | if (ret) |
1163 | goto err_out; | 1162 | return ret; |
1164 | 1163 | ||
1165 | gpio_direction_output(pdata->buck125_gpios[0], | 1164 | gpio_direction_output(pdata->buck125_gpios[0], |
1166 | (max8997->buck125_gpioindex >> 2) | 1165 | (max8997->buck125_gpioindex >> 2) |
@@ -1205,33 +1204,17 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1205 | config.driver_data = max8997; | 1204 | config.driver_data = max8997; |
1206 | config.of_node = pdata->regulators[i].reg_node; | 1205 | config.of_node = pdata->regulators[i].reg_node; |
1207 | 1206 | ||
1208 | rdev[i] = regulator_register(®ulators[id], &config); | 1207 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], |
1208 | &config); | ||
1209 | if (IS_ERR(rdev[i])) { | 1209 | if (IS_ERR(rdev[i])) { |
1210 | ret = PTR_ERR(rdev[i]); | ||
1211 | dev_err(max8997->dev, "regulator init failed for %d\n", | 1210 | dev_err(max8997->dev, "regulator init failed for %d\n", |
1212 | id); | 1211 | id); |
1213 | rdev[i] = NULL; | 1212 | rdev[i] = NULL; |
1214 | goto err; | 1213 | return PTR_ERR(rdev[i]); |
1215 | } | 1214 | } |
1216 | } | 1215 | } |
1217 | 1216 | ||
1218 | return 0; | 1217 | return 0; |
1219 | err: | ||
1220 | while (--i >= 0) | ||
1221 | regulator_unregister(rdev[i]); | ||
1222 | err_out: | ||
1223 | return ret; | ||
1224 | } | ||
1225 | |||
1226 | static int max8997_pmic_remove(struct platform_device *pdev) | ||
1227 | { | ||
1228 | struct max8997_data *max8997 = platform_get_drvdata(pdev); | ||
1229 | struct regulator_dev **rdev = max8997->rdev; | ||
1230 | int i; | ||
1231 | |||
1232 | for (i = 0; i < max8997->num_regulators; i++) | ||
1233 | regulator_unregister(rdev[i]); | ||
1234 | return 0; | ||
1235 | } | 1218 | } |
1236 | 1219 | ||
1237 | static const struct platform_device_id max8997_pmic_id[] = { | 1220 | static const struct platform_device_id max8997_pmic_id[] = { |
@@ -1246,7 +1229,6 @@ static struct platform_driver max8997_pmic_driver = { | |||
1246 | .owner = THIS_MODULE, | 1229 | .owner = THIS_MODULE, |
1247 | }, | 1230 | }, |
1248 | .probe = max8997_pmic_probe, | 1231 | .probe = max8997_pmic_probe, |
1249 | .remove = max8997_pmic_remove, | ||
1250 | .id_table = max8997_pmic_id, | 1232 | .id_table = max8997_pmic_id, |
1251 | }; | 1233 | }; |
1252 | 1234 | ||