]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regulator: da903x: Use DIV_ROUND_UP macro to calculate selector
authorAxel Lin <axel.lin@gmail.com>
Mon, 5 Mar 2012 22:54:40 +0000 (06:54 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 11 Mar 2012 20:48:52 +0000 (20:48 +0000)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/da903x.c

index 8dbc54da7d7078004ff61eddd1d1f82a71f0f257..1851f0929ef01fdb1401b63dd0d731caf83775b9 100644 (file)
@@ -119,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
                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;
        val <<= 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,
                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;
        val <<= 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,
 
        thresh = (info->max_uV + info->min_uV) / 2;
        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;
        } else {
-               val = (min_uV - thresh + info->step_uV - 1) / info->step_uV;
+               val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
        }
 
        *selector = val;
@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
                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;
        val <<= 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,
                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);
        *selector = val;
        val <<= info->vol_shift;