diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-03-19 22:46:35 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-02 18:24:46 -0400 |
commit | 939b62d897d80be2b4632dd81a838d29e1f5f1e3 (patch) | |
tree | f64419c0e3c64139997b82bb3d02df925399b8a4 /drivers/regulator/mc13xxx-regulator-core.c | |
parent | a4d9f179cc788b7f4b735d32c2e4a3b2562e8240 (diff) |
regulator: Convert mc13xxx regulator drivers to set_voltage_sel
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>
Diffstat (limited to 'drivers/regulator/mc13xxx-regulator-core.c')
-rw-r--r-- | drivers/regulator/mc13xxx-regulator-core.c | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 62dcd0a432b..4fa9704739b 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c | |||
@@ -94,62 +94,18 @@ int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev, | |||
94 | } | 94 | } |
95 | EXPORT_SYMBOL_GPL(mc13xxx_regulator_list_voltage); | 95 | EXPORT_SYMBOL_GPL(mc13xxx_regulator_list_voltage); |
96 | 96 | ||
97 | int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev, | 97 | static int mc13xxx_regulator_set_voltage_sel(struct regulator_dev *rdev, |
98 | int min_uV, int max_uV) | 98 | unsigned selector) |
99 | { | 99 | { |
100 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 100 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
101 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; | 101 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; |
102 | int reg_id = rdev_get_id(rdev); | 102 | int id = rdev_get_id(rdev); |
103 | int i; | ||
104 | int bestmatch; | ||
105 | int bestindex; | ||
106 | |||
107 | /* | ||
108 | * Locate the minimum voltage fitting the criteria on | ||
109 | * this regulator. The switchable voltages are not | ||
110 | * in strict falling order so we need to check them | ||
111 | * all for the best match. | ||
112 | */ | ||
113 | bestmatch = INT_MAX; | ||
114 | bestindex = -1; | ||
115 | for (i = 0; i < mc13xxx_regulators[reg_id].desc.n_voltages; i++) { | ||
116 | if (mc13xxx_regulators[reg_id].voltages[i] >= min_uV && | ||
117 | mc13xxx_regulators[reg_id].voltages[i] < bestmatch) { | ||
118 | bestmatch = mc13xxx_regulators[reg_id].voltages[i]; | ||
119 | bestindex = i; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | if (bestindex < 0 || bestmatch > max_uV) { | ||
124 | dev_warn(&rdev->dev, "no possible value for %d<=x<=%d uV\n", | ||
125 | min_uV, max_uV); | ||
126 | return -EINVAL; | ||
127 | } | ||
128 | return bestindex; | ||
129 | } | ||
130 | EXPORT_SYMBOL_GPL(mc13xxx_get_best_voltage_index); | ||
131 | |||
132 | static int mc13xxx_regulator_set_voltage(struct regulator_dev *rdev, int min_uV, | ||
133 | int max_uV, unsigned *selector) | ||
134 | { | ||
135 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | ||
136 | struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; | ||
137 | int value, id = rdev_get_id(rdev); | ||
138 | int ret; | 103 | int ret; |
139 | 104 | ||
140 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", | ||
141 | __func__, id, min_uV, max_uV); | ||
142 | |||
143 | /* Find the best index */ | ||
144 | value = mc13xxx_get_best_voltage_index(rdev, min_uV, max_uV); | ||
145 | dev_dbg(rdev_get_dev(rdev), "%s best value: %d\n", __func__, value); | ||
146 | if (value < 0) | ||
147 | return value; | ||
148 | |||
149 | mc13xxx_lock(priv->mc13xxx); | 105 | mc13xxx_lock(priv->mc13xxx); |
150 | ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg, | 106 | ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg, |
151 | mc13xxx_regulators[id].vsel_mask, | 107 | mc13xxx_regulators[id].vsel_mask, |
152 | value << mc13xxx_regulators[id].vsel_shift); | 108 | selector << mc13xxx_regulators[id].vsel_shift); |
153 | mc13xxx_unlock(priv->mc13xxx); | 109 | mc13xxx_unlock(priv->mc13xxx); |
154 | 110 | ||
155 | return ret; | 111 | return ret; |
@@ -187,7 +143,7 @@ struct regulator_ops mc13xxx_regulator_ops = { | |||
187 | .disable = mc13xxx_regulator_disable, | 143 | .disable = mc13xxx_regulator_disable, |
188 | .is_enabled = mc13xxx_regulator_is_enabled, | 144 | .is_enabled = mc13xxx_regulator_is_enabled, |
189 | .list_voltage = mc13xxx_regulator_list_voltage, | 145 | .list_voltage = mc13xxx_regulator_list_voltage, |
190 | .set_voltage = mc13xxx_regulator_set_voltage, | 146 | .set_voltage_sel = mc13xxx_regulator_set_voltage_sel, |
191 | .get_voltage = mc13xxx_regulator_get_voltage, | 147 | .get_voltage = mc13xxx_regulator_get_voltage, |
192 | }; | 148 | }; |
193 | EXPORT_SYMBOL_GPL(mc13xxx_regulator_ops); | 149 | EXPORT_SYMBOL_GPL(mc13xxx_regulator_ops); |