Commit ae76e830 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: da903x: Use DIV_ROUND_UP macro to calculate selector

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent e9a15c8c
...@@ -119,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev, ...@@ -119,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -202,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, ...@@ -202,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -233,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, ...@@ -233,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
thresh = (info->max_uV + info->min_uV) / 2; thresh = (info->max_uV + info->min_uV) / 2;
if (min_uV < thresh) { if (min_uV < thresh) {
val = (thresh - min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(thresh - min_uV, info->step_uV);
val |= 0x4; val |= 0x4;
} else { } else {
val = (min_uV - thresh + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
} }
*selector = val; *selector = val;
...@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev, ...@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -307,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, ...@@ -307,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val); val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment