]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector
authorAxel Lin <axel.lin@gmail.com>
Tue, 6 Mar 2012 01:54:22 +0000 (09:54 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 11 Mar 2012 20:48:52 +0000 (20:48 +0000)
Use DIV_ROUND_UP macro for better readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/tps65217-regulator.c

index 28a10eaeda17a6056c63a4714f9c696c1feda1b1..15f2fa0bb0058edd54f6e4b6475f6d14255d687c 100644 (file)
@@ -82,11 +82,11 @@ static int tps65217_uv_to_vsel1(int uV, unsigned int *vsel)
                return -EINVAL;
 
        if (uV <= 1500000)
-               *vsel = (uV - 875001) / 25000;
+               *vsel = DIV_ROUND_UP(uV - 900000, 25000);
        else if (uV <= 2900000)
-               *vsel = 24 + (uV - 1450001) / 50000;
+               *vsel = 24 + DIV_ROUND_UP(uV - 1500000, 50000);
        else if (uV < 3300000)
-               *vsel = 52 + (uV - 2800001) / 100000;
+               *vsel = 52 + DIV_ROUND_UP(uV - 2900000, 100000);
        else
                *vsel = 56;
 
@@ -116,11 +116,11 @@ static int tps65217_uv_to_vsel2(int uV, unsigned int *vsel)
                return -EINVAL;
 
        if (uV <= 1900000)
-               *vsel = (uV - 1450001) / 50000;
+               *vsel = DIV_ROUND_UP(uV - 1500000, 50000);
        else if (uV <= 2400000)
-               *vsel = 8 + (uV - 1800001) / 100000;
+               *vsel = 8 + DIV_ROUND_UP(uV - 1900000, 100000);
        else
-               *vsel = 13 + (uV - 2350001) / 50000;
+               *vsel = 13 + DIV_ROUND_UP(uV - 2400000, 50000);
 
        return 0;
 }