regulator: Convert tps6524x to set_voltage_sel
authorAxel Lin <axel.lin@gmail.com>
Wed, 28 Mar 2012 11:45:43 +0000 (19:45 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 1 Apr 2012 10:59:36 +0000 (11:59 +0100)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/tps6524x-regulator.c

index 4a421be6d4f2fa7d7b700b43a24367d354b0a020..3a4a1d550db01293dd94e650f6cec039c7ddf1dd 100644 (file)
@@ -458,12 +458,10 @@ static int list_voltage(struct regulator_dev *rdev, unsigned selector)
                info->voltages[selector] : -EINVAL);
 }
 
-static int set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
-                      unsigned *selector)
+static int set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
 {
        const struct supply_info *info;
        struct tps6524x *hw;
-       unsigned i;
 
        hw      = rdev_get_drvdata(rdev);
        info    = &supply_info[rdev_get_id(rdev)];
@@ -471,17 +469,7 @@ static int set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
        if (info->flags & FIXED_VOLTAGE)
                return -EINVAL;
 
-       for (i = 0; i < info->n_voltages; i++)
-               if (min_uV <= info->voltages[i] &&
-                   max_uV >= info->voltages[i])
-                       break;
-
-       if (i >= info->n_voltages)
-               i = info->n_voltages - 1;
-
-       *selector = i;
-
-       return write_field(hw, &info->voltage, i);
+       return write_field(hw, &info->voltage, selector);
 }
 
 static int get_voltage(struct regulator_dev *rdev)
@@ -588,7 +576,7 @@ static struct regulator_ops regulator_ops = {
        .enable                 = enable_supply,
        .disable                = disable_supply,
        .get_voltage            = get_voltage,
-       .set_voltage            = set_voltage,
+       .set_voltage_sel        = set_voltage_sel,
        .list_voltage           = list_voltage,
        .set_current_limit      = set_current_limit,
        .get_current_limit      = get_current_limit,