Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292057
b: refs/heads/master
c: 5b5e977
h: refs/heads/master
i:
  292055: 93da967
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed Mar 11, 2012
1 parent a879b46 commit b28eb73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4d984d1cd838435cf1180ab9ffbab24cfdbf7515
refs/heads/master: 5b5e977ce71cab973d9f8c7d5303832a2bafa92c
22 changes: 10 additions & 12 deletions trunk/drivers/regulator/s5m8767.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,31 +294,30 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
return val;
}

static inline int s5m8767_convert_voltage(
static int s5m8767_convert_voltage_to_sel(
const struct s5m_voltage_desc *desc,
int min_vol, int max_vol)
{
int out_vol = 0;
int selector = 0;

if (desc == NULL)
return -EINVAL;

if (max_vol < desc->min || min_vol > desc->max)
return -EINVAL;

out_vol = (min_vol - desc->min) / desc->step;
selector = (min_vol - desc->min) / desc->step;

if (desc->min + desc->step * out_vol > max_vol)
if (desc->min + desc->step * selector > max_vol)
return -EINVAL;

return out_vol;
return selector;
}

static int s5m8767_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector)
{
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
int min_vol = min_uV, max_vol = max_uV;
const struct s5m_voltage_desc *desc;
int reg_id = rdev_get_id(rdev);
int reg, mask, ret;
Expand All @@ -343,7 +342,7 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,

desc = reg_voltage_map[reg_id];

i = s5m8767_convert_voltage(desc, min_vol, max_vol);
i = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
if (i < 0)
return i;

Expand Down Expand Up @@ -385,7 +384,6 @@ static int s5m8767_set_voltage_buck(struct regulator_dev *rdev,
int reg_id = rdev_get_id(rdev);
const struct s5m_voltage_desc *desc;
int new_val, old_val, i = 0;
int min_vol = min_uV, max_vol = max_uV;

if (reg_id < S5M8767_BUCK1 || reg_id > S5M8767_BUCK6)
return -EINVAL;
Expand All @@ -402,7 +400,7 @@ static int s5m8767_set_voltage_buck(struct regulator_dev *rdev,
}

desc = reg_voltage_map[reg_id];
new_val = s5m8767_convert_voltage(desc, min_vol, max_vol);
new_val = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
if (new_val < 0)
return new_val;

Expand Down Expand Up @@ -580,7 +578,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
for (i = 0; i < 8; i++) {
if (s5m8767->buck2_gpiodvs) {
s5m8767->buck2_vol[i] =
s5m8767_convert_voltage(
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
pdata->buck2_voltage[i],
pdata->buck2_voltage[i] +
Expand All @@ -589,7 +587,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)

if (s5m8767->buck3_gpiodvs) {
s5m8767->buck3_vol[i] =
s5m8767_convert_voltage(
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
pdata->buck3_voltage[i],
pdata->buck3_voltage[i] +
Expand All @@ -598,7 +596,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)

if (s5m8767->buck4_gpiodvs) {
s5m8767->buck4_vol[i] =
s5m8767_convert_voltage(
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
pdata->buck4_voltage[i],
pdata->buck4_voltage[i] +
Expand Down

0 comments on commit b28eb73

Please sign in to comment.