regulator: wm831x-dcdc: Convert wm831x_buckp_ops to regulator_set_voltage_sel_regmap
authorAxel Lin <axel.lin@gmail.com>
Wed, 13 Jun 2012 12:27:58 +0000 (20:27 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 17 Jun 2012 20:07:19 +0000 (21:07 +0100)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/wm831x-dcdc.c

index fbcff56e011480e5a3038f4dfab5604abbc09674..91b5b0a727ef7513cea6a5603103c9622031271e 100644 (file)
@@ -599,51 +599,25 @@ static struct platform_driver wm831x_buckv_driver = {
  * BUCKP specifics
  */
 
-static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg,
-                                       int min_uV, int max_uV, int *selector)
+static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, int uV)
 {
        struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
        struct wm831x *wm831x = dcdc->wm831x;
-       u16 vsel;
-
-       if (min_uV <= 34000000)
-               vsel = (min_uV - 850000) / 25000;
-       else
-               return -EINVAL;
-
-       if (regulator_list_voltage_linear(rdev, vsel) > max_uV)
-               return -EINVAL;
-
-       *selector = vsel;
-
-       return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel);
-}
-
-static int wm831x_buckp_set_voltage(struct regulator_dev *rdev,
-                                   int min_uV, int max_uV,
-                                   unsigned *selector)
-{
-       struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
-       u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
-
-       return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV,
-                                           selector);
-}
-
-static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev,
-                                           int uV)
-{
-       struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
        u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
-       unsigned selector;
+       int sel;
+
+       sel = regulator_map_voltage_linear(rdev, uV, uV);
+       if (sel < 0)
+               return sel;
 
-       return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV, &selector);
+       return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, sel);
 }
 
 static struct regulator_ops wm831x_buckp_ops = {
-       .set_voltage = wm831x_buckp_set_voltage,
+       .set_voltage_sel = regulator_set_voltage_sel_regmap,
        .get_voltage_sel = regulator_get_voltage_sel_regmap,
        .list_voltage = regulator_list_voltage_linear,
+       .map_voltage = regulator_map_voltage_linear,
        .set_suspend_voltage = wm831x_buckp_set_suspend_voltage,
 
        .is_enabled = regulator_is_enabled_regmap,