regulator: wm8400: Use wm8400_ldo_list_voltage instead of open code to verify selecte...
authorAxel Lin <axel.lin@gmail.com>
Tue, 12 Jun 2012 08:34:55 +0000 (16:34 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 13 Jun 2012 09:47:02 +0000 (10:47 +0100)
Call wm8400_ldo_list_voltage() instead of open code to verify selected voltage
falls within specified range.
Use wm8400_ldo_list_voltage() here is less error prone.

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

index f365795d51c2c4c8aab34ffe6f37cf3ea82684c2..9f9df8eef1a18c0ef20a777135c8be69edf60410 100644 (file)
@@ -35,27 +35,19 @@ static int wm8400_ldo_map_voltage(struct regulator_dev *dev,
                                  int min_uV, int max_uV)
 {
        u16 val;
+       int volt;
 
        if (min_uV < 900000 || min_uV > 3300000)
                return -EINVAL;
 
-       if (min_uV < 1700000) {
-               /* Steps of 50mV from 900mV;  */
+       if (min_uV < 1700000) /* Steps of 50mV from 900mV;  */
                val = DIV_ROUND_UP(min_uV - 900000, 50000);
+       else /* Steps of 100mV from 1700mV */
+               val = DIV_ROUND_UP(min_uV - 1700000, 100000) + 15;
 
-               if ((val * 50000) + 900000 > max_uV)
-                       return -EINVAL;
-               BUG_ON((val * 50000) + 900000 < min_uV);
-       } else {
-               /* Steps of 100mV from 1700mV */
-               val = DIV_ROUND_UP(min_uV - 1700000, 100000);
-
-               if ((val * 100000) + 1700000 > max_uV)
-                       return -EINVAL;
-               BUG_ON((val * 100000) + 1700000 < min_uV);
-
-               val += 0xf;
-       }
+       volt = wm8400_ldo_list_voltage(dev, val);
+       if (volt < min_uV || volt > max_uV)
+               return -EINVAL;
 
        return val;
 }
This page took 0.04669 seconds and 5 git commands to generate.