Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350454
b: refs/heads/master
c: 854f73e
h: refs/heads/master
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed Jan 17, 2013
1 parent de2cbc5 commit c10e64e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 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: 3051019409d99084f3b8f090b75d969adcc882e7
refs/heads/master: 854f73ecb5c207007f9e850abd6f82ab89eaefb7
33 changes: 10 additions & 23 deletions trunk/drivers/regulator/s5m8767.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,24 +323,23 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
return val;
}

static int s5m8767_convert_voltage_to_sel(
const struct sec_voltage_desc *desc,
int min_vol, int max_vol)
static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc,
int min_vol)
{
int selector = 0;

if (desc == NULL)
return -EINVAL;

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

if (min_vol < desc->min)
min_vol = desc->min;

selector = DIV_ROUND_UP(min_vol - desc->min, desc->step);

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

return selector;
Expand Down Expand Up @@ -577,23 +576,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
s5m8767->opmode = pdata->opmode;

buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
pdata->buck2_init,
pdata->buck2_init +
buck_voltage_val2.step);
pdata->buck2_init);

sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init);

buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
pdata->buck3_init,
pdata->buck3_init +
buck_voltage_val2.step);
pdata->buck3_init);

sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init);

buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
pdata->buck4_init,
pdata->buck4_init +
buck_voltage_val2.step);
pdata->buck4_init);

sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init);

Expand All @@ -602,27 +595,21 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
s5m8767->buck2_vol[i] =
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
pdata->buck2_voltage[i],
pdata->buck2_voltage[i] +
buck_voltage_val2.step);
pdata->buck2_voltage[i]);
}

if (s5m8767->buck3_gpiodvs) {
s5m8767->buck3_vol[i] =
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
pdata->buck3_voltage[i],
pdata->buck3_voltage[i] +
buck_voltage_val2.step);
pdata->buck3_voltage[i]);
}

if (s5m8767->buck4_gpiodvs) {
s5m8767->buck4_vol[i] =
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
pdata->buck4_voltage[i],
pdata->buck4_voltage[i] +
buck_voltage_val2.step);
pdata->buck4_voltage[i]);
}
}

Expand Down

0 comments on commit c10e64e

Please sign in to comment.