aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8997.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r--drivers/regulator/max8997.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index df20069f0537..2d618fc9c1af 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -690,8 +690,9 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
690 if (max8997->ignore_gpiodvs_side_effect == false) 690 if (max8997->ignore_gpiodvs_side_effect == false)
691 return -EINVAL; 691 return -EINVAL;
692 692
693 dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:" 693 dev_warn(&rdev->dev,
694 " %d -> %d\n", max8997->buck125_gpioindex, tmp_idx); 694 "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET: %d -> %d\n",
695 max8997->buck125_gpioindex, tmp_idx);
695 696
696out: 697out:
697 if (new_idx < 0 || new_val < 0) 698 if (new_idx < 0 || new_val < 0)
@@ -1081,7 +1082,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1081 pdata->buck1_voltage[i] + 1082 pdata->buck1_voltage[i] +
1082 buck1245_voltage_map_desc.step); 1083 buck1245_voltage_map_desc.step);
1083 if (ret < 0) 1084 if (ret < 0)
1084 goto err_out; 1085 return ret;
1085 1086
1086 max8997->buck2_vol[i] = ret = 1087 max8997->buck2_vol[i] = ret =
1087 max8997_get_voltage_proper_val( 1088 max8997_get_voltage_proper_val(
@@ -1090,7 +1091,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1090 pdata->buck2_voltage[i] + 1091 pdata->buck2_voltage[i] +
1091 buck1245_voltage_map_desc.step); 1092 buck1245_voltage_map_desc.step);
1092 if (ret < 0) 1093 if (ret < 0)
1093 goto err_out; 1094 return ret;
1094 1095
1095 max8997->buck5_vol[i] = ret = 1096 max8997->buck5_vol[i] = ret =
1096 max8997_get_voltage_proper_val( 1097 max8997_get_voltage_proper_val(
@@ -1099,7 +1100,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1099 pdata->buck5_voltage[i] + 1100 pdata->buck5_voltage[i] +
1100 buck1245_voltage_map_desc.step); 1101 buck1245_voltage_map_desc.step);
1101 if (ret < 0) 1102 if (ret < 0)
1102 goto err_out; 1103 return ret;
1103 1104
1104 if (max_buck1 < max8997->buck1_vol[i]) 1105 if (max_buck1 < max8997->buck1_vol[i])
1105 max_buck1 = max8997->buck1_vol[i]; 1106 max_buck1 = max8997->buck1_vol[i];
@@ -1143,24 +1144,23 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1143 !gpio_is_valid(pdata->buck125_gpios[1]) || 1144 !gpio_is_valid(pdata->buck125_gpios[1]) ||
1144 !gpio_is_valid(pdata->buck125_gpios[2])) { 1145 !gpio_is_valid(pdata->buck125_gpios[2])) {
1145 dev_err(&pdev->dev, "GPIO NOT VALID\n"); 1146 dev_err(&pdev->dev, "GPIO NOT VALID\n");
1146 ret = -EINVAL; 1147 return -EINVAL;
1147 goto err_out;
1148 } 1148 }
1149 1149
1150 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], 1150 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0],
1151 "MAX8997 SET1"); 1151 "MAX8997 SET1");
1152 if (ret) 1152 if (ret)
1153 goto err_out; 1153 return ret;
1154 1154
1155 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], 1155 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1],
1156 "MAX8997 SET2"); 1156 "MAX8997 SET2");
1157 if (ret) 1157 if (ret)
1158 goto err_out; 1158 return ret;
1159 1159
1160 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], 1160 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2],
1161 "MAX8997 SET3"); 1161 "MAX8997 SET3");
1162 if (ret) 1162 if (ret)
1163 goto err_out; 1163 return ret;
1164 1164
1165 gpio_direction_output(pdata->buck125_gpios[0], 1165 gpio_direction_output(pdata->buck125_gpios[0],
1166 (max8997->buck125_gpioindex >> 2) 1166 (max8997->buck125_gpioindex >> 2)
@@ -1205,33 +1205,16 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1205 config.driver_data = max8997; 1205 config.driver_data = max8997;
1206 config.of_node = pdata->regulators[i].reg_node; 1206 config.of_node = pdata->regulators[i].reg_node;
1207 1207
1208 rdev[i] = regulator_register(&regulators[id], &config); 1208 rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id],
1209 &config);
1209 if (IS_ERR(rdev[i])) { 1210 if (IS_ERR(rdev[i])) {
1210 ret = PTR_ERR(rdev[i]);
1211 dev_err(max8997->dev, "regulator init failed for %d\n", 1211 dev_err(max8997->dev, "regulator init failed for %d\n",
1212 id); 1212 id);
1213 rdev[i] = NULL; 1213 return PTR_ERR(rdev[i]);
1214 goto err;
1215 } 1214 }
1216 } 1215 }
1217 1216
1218 return 0; 1217 return 0;
1219err:
1220 while (--i >= 0)
1221 regulator_unregister(rdev[i]);
1222err_out:
1223 return ret;
1224}
1225
1226static 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
1237static const struct platform_device_id max8997_pmic_id[] = { 1220static 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