aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/s5m8767.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 3592ccb4e603..9d5d9159040f 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -294,11 +294,11 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
294 return val; 294 return val;
295} 295}
296 296
297static inline int s5m8767_convert_voltage( 297static int s5m8767_convert_voltage_to_sel(
298 const struct s5m_voltage_desc *desc, 298 const struct s5m_voltage_desc *desc,
299 int min_vol, int max_vol) 299 int min_vol, int max_vol)
300{ 300{
301 int out_vol = 0; 301 int selector = 0;
302 302
303 if (desc == NULL) 303 if (desc == NULL)
304 return -EINVAL; 304 return -EINVAL;
@@ -306,19 +306,18 @@ static inline int s5m8767_convert_voltage(
306 if (max_vol < desc->min || min_vol > desc->max) 306 if (max_vol < desc->min || min_vol > desc->max)
307 return -EINVAL; 307 return -EINVAL;
308 308
309 out_vol = (min_vol - desc->min) / desc->step; 309 selector = (min_vol - desc->min) / desc->step;
310 310
311 if (desc->min + desc->step * out_vol > max_vol) 311 if (desc->min + desc->step * selector > max_vol)
312 return -EINVAL; 312 return -EINVAL;
313 313
314 return out_vol; 314 return selector;
315} 315}
316 316
317static int s5m8767_set_voltage(struct regulator_dev *rdev, 317static int s5m8767_set_voltage(struct regulator_dev *rdev,
318 int min_uV, int max_uV, unsigned *selector) 318 int min_uV, int max_uV, unsigned *selector)
319{ 319{
320 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 320 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
321 int min_vol = min_uV, max_vol = max_uV;
322 const struct s5m_voltage_desc *desc; 321 const struct s5m_voltage_desc *desc;
323 int reg_id = rdev_get_id(rdev); 322 int reg_id = rdev_get_id(rdev);
324 int reg, mask, ret; 323 int reg, mask, ret;
@@ -343,7 +342,7 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,
343 342
344 desc = reg_voltage_map[reg_id]; 343 desc = reg_voltage_map[reg_id];
345 344
346 i = s5m8767_convert_voltage(desc, min_vol, max_vol); 345 i = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
347 if (i < 0) 346 if (i < 0)
348 return i; 347 return i;
349 348
@@ -385,7 +384,6 @@ static int s5m8767_set_voltage_buck(struct regulator_dev *rdev,
385 int reg_id = rdev_get_id(rdev); 384 int reg_id = rdev_get_id(rdev);
386 const struct s5m_voltage_desc *desc; 385 const struct s5m_voltage_desc *desc;
387 int new_val, old_val, i = 0; 386 int new_val, old_val, i = 0;
388 int min_vol = min_uV, max_vol = max_uV;
389 387
390 if (reg_id < S5M8767_BUCK1 || reg_id > S5M8767_BUCK6) 388 if (reg_id < S5M8767_BUCK1 || reg_id > S5M8767_BUCK6)
391 return -EINVAL; 389 return -EINVAL;
@@ -402,7 +400,7 @@ static int s5m8767_set_voltage_buck(struct regulator_dev *rdev,
402 } 400 }
403 401
404 desc = reg_voltage_map[reg_id]; 402 desc = reg_voltage_map[reg_id];
405 new_val = s5m8767_convert_voltage(desc, min_vol, max_vol); 403 new_val = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
406 if (new_val < 0) 404 if (new_val < 0)
407 return new_val; 405 return new_val;
408 406
@@ -580,7 +578,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
580 for (i = 0; i < 8; i++) { 578 for (i = 0; i < 8; i++) {
581 if (s5m8767->buck2_gpiodvs) { 579 if (s5m8767->buck2_gpiodvs) {
582 s5m8767->buck2_vol[i] = 580 s5m8767->buck2_vol[i] =
583 s5m8767_convert_voltage( 581 s5m8767_convert_voltage_to_sel(
584 &buck_voltage_val2, 582 &buck_voltage_val2,
585 pdata->buck2_voltage[i], 583 pdata->buck2_voltage[i],
586 pdata->buck2_voltage[i] + 584 pdata->buck2_voltage[i] +
@@ -589,7 +587,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
589 587
590 if (s5m8767->buck3_gpiodvs) { 588 if (s5m8767->buck3_gpiodvs) {
591 s5m8767->buck3_vol[i] = 589 s5m8767->buck3_vol[i] =
592 s5m8767_convert_voltage( 590 s5m8767_convert_voltage_to_sel(
593 &buck_voltage_val2, 591 &buck_voltage_val2,
594 pdata->buck3_voltage[i], 592 pdata->buck3_voltage[i],
595 pdata->buck3_voltage[i] + 593 pdata->buck3_voltage[i] +
@@ -598,7 +596,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
598 596
599 if (s5m8767->buck4_gpiodvs) { 597 if (s5m8767->buck4_gpiodvs) {
600 s5m8767->buck4_vol[i] = 598 s5m8767->buck4_vol[i] =
601 s5m8767_convert_voltage( 599 s5m8767_convert_voltage_to_sel(
602 &buck_voltage_val2, 600 &buck_voltage_val2,
603 pdata->buck4_voltage[i], 601 pdata->buck4_voltage[i],
604 pdata->buck4_voltage[i] + 602 pdata->buck4_voltage[i] +