regulator: Convert mc13xxx regulator drivers to set_voltage_sel
authorAxel Lin <axel.lin@gmail.com>
Tue, 20 Mar 2012 02:46:35 +0000 (10:46 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 2 Apr 2012 22:24:46 +0000 (23:24 +0100)
Convert mc13892_sw_regulator_ops and mc13xxx_regulator_ops to set_voltage_sel.
mc13xxx_get_best_voltage_index function is not used now, remove it.

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

index e8cfc99dd8f066eb4a4ab3bc99007b70cf358bbc..ba5868179261ae95d88f00462cb0f98f18b008c7 100644 (file)
@@ -428,24 +428,15 @@ static int mc13892_sw_regulator_get_voltage(struct regulator_dev *rdev)
        return val;
 }
 
-static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev,
-               int min_uV, int max_uV, unsigned *selector)
+static int mc13892_sw_regulator_set_voltage_sel(struct regulator_dev *rdev,
+                                               unsigned selector)
 {
        struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
        int hi, value, mask, id = rdev_get_id(rdev);
        u32 valread;
        int ret;
 
-       dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",
-               __func__, id, min_uV, max_uV);
-
-       /* Find the best index */
-       value = mc13xxx_get_best_voltage_index(rdev, min_uV, max_uV);
-       dev_dbg(rdev_get_dev(rdev), "%s best value: %d\n", __func__, value);
-       if (value < 0)
-               return value;
-
-       value = mc13892_regulators[id].voltages[value];
+       value = mc13892_regulators[id].voltages[selector];
 
        mc13xxx_lock(priv->mc13xxx);
        ret = mc13xxx_reg_read(priv->mc13xxx,
@@ -480,7 +471,7 @@ err:
 static struct regulator_ops mc13892_sw_regulator_ops = {
        .is_enabled = mc13xxx_sw_regulator_is_enabled,
        .list_voltage = mc13xxx_regulator_list_voltage,
-       .set_voltage = mc13892_sw_regulator_set_voltage,
+       .set_voltage_sel = mc13892_sw_regulator_set_voltage_sel,
        .get_voltage = mc13892_sw_regulator_get_voltage,
 };
 
index 62dcd0a432bb65832fc7bcf454b08587401ad293..4fa9704739bc41bb764ece50e58071783501966a 100644 (file)
@@ -94,62 +94,18 @@ int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,
 }
 EXPORT_SYMBOL_GPL(mc13xxx_regulator_list_voltage);
 
-int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,
-                                               int min_uV, int max_uV)
+static int mc13xxx_regulator_set_voltage_sel(struct regulator_dev *rdev,
+                                            unsigned selector)
 {
        struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
        struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
-       int reg_id = rdev_get_id(rdev);
-       int i;
-       int bestmatch;
-       int bestindex;
-
-       /*
-        * Locate the minimum voltage fitting the criteria on
-        * this regulator. The switchable voltages are not
-        * in strict falling order so we need to check them
-        * all for the best match.
-        */
-       bestmatch = INT_MAX;
-       bestindex = -1;
-       for (i = 0; i < mc13xxx_regulators[reg_id].desc.n_voltages; i++) {
-               if (mc13xxx_regulators[reg_id].voltages[i] >= min_uV &&
-                   mc13xxx_regulators[reg_id].voltages[i] < bestmatch) {
-                       bestmatch = mc13xxx_regulators[reg_id].voltages[i];
-                       bestindex = i;
-               }
-       }
-
-       if (bestindex < 0 || bestmatch > max_uV) {
-               dev_warn(&rdev->dev, "no possible value for %d<=x<=%d uV\n",
-                               min_uV, max_uV);
-               return -EINVAL;
-       }
-       return bestindex;
-}
-EXPORT_SYMBOL_GPL(mc13xxx_get_best_voltage_index);
-
-static int mc13xxx_regulator_set_voltage(struct regulator_dev *rdev, int min_uV,
-               int max_uV, unsigned *selector)
-{
-       struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
-       struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
-       int value, id = rdev_get_id(rdev);
+       int id = rdev_get_id(rdev);
        int ret;
 
-       dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",
-               __func__, id, min_uV, max_uV);
-
-       /* Find the best index */
-       value = mc13xxx_get_best_voltage_index(rdev, min_uV, max_uV);
-       dev_dbg(rdev_get_dev(rdev), "%s best value: %d\n", __func__, value);
-       if (value < 0)
-               return value;
-
        mc13xxx_lock(priv->mc13xxx);
        ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg,
                        mc13xxx_regulators[id].vsel_mask,
-                       value << mc13xxx_regulators[id].vsel_shift);
+                       selector << mc13xxx_regulators[id].vsel_shift);
        mc13xxx_unlock(priv->mc13xxx);
 
        return ret;
@@ -187,7 +143,7 @@ struct regulator_ops mc13xxx_regulator_ops = {
        .disable = mc13xxx_regulator_disable,
        .is_enabled = mc13xxx_regulator_is_enabled,
        .list_voltage = mc13xxx_regulator_list_voltage,
-       .set_voltage = mc13xxx_regulator_set_voltage,
+       .set_voltage_sel = mc13xxx_regulator_set_voltage_sel,
        .get_voltage = mc13xxx_regulator_get_voltage,
 };
 EXPORT_SYMBOL_GPL(mc13xxx_regulator_ops);
index b3961c658b0594a8c728f780f1c49fd7830e4959..044aba4d28eca99f952207adf15e4b382b2c9f96 100644 (file)
@@ -35,8 +35,6 @@ struct mc13xxx_regulator_priv {
 
 extern int mc13xxx_sw_regulator(struct regulator_dev *rdev);
 extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev);
-extern int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,
-                                               int min_uV, int max_uV);
 extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,
                                                unsigned selector);
 extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,