Skip to content

Commit b13296d

Browse files
AxelLinbroonie
authored andcommitted
regulator: ab3100: Use regulator_map_voltage_iterate()
regulator_map_voltage_iterate() is for drivers implementing set_voltage_sel() and list_voltage() to use it as their map_voltage() operation. In this case, regulator_map_voltage_iterate() happen to be doing the same thing as ab3100_get_best_voltage_index() function. So we can use it to replace ab3100_get_best_voltage_index() function. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent 8b22285 commit b13296d

1 file changed

Lines changed: 1 addition & 34 deletions

File tree

‎drivers/regulator/ab3100.c‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -304,39 +304,6 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
304304
return abreg->typ_voltages[regval];
305305
}
306306

307-
static int ab3100_get_best_voltage_index(struct regulator_dev *reg,
308-
int min_uV, int max_uV)
309-
{
310-
struct ab3100_regulator *abreg = reg->reg_data;
311-
int i;
312-
int bestmatch;
313-
int bestindex;
314-
315-
/*
316-
* Locate the minimum voltage fitting the criteria on
317-
* this regulator. The switchable voltages are not
318-
* in strict falling order so we need to check them
319-
* all for the best match.
320-
*/
321-
bestmatch = INT_MAX;
322-
bestindex = -1;
323-
for (i = 0; i < abreg->voltages_len; i++) {
324-
if (abreg->typ_voltages[i] <= max_uV &&
325-
abreg->typ_voltages[i] >= min_uV &&
326-
abreg->typ_voltages[i] < bestmatch) {
327-
bestmatch = abreg->typ_voltages[i];
328-
bestindex = i;
329-
}
330-
}
331-
332-
if (bestindex < 0) {
333-
dev_warn(&reg->dev, "requested %d<=x<=%d uV, out of range!\n",
334-
min_uV, max_uV);
335-
return -EINVAL;
336-
}
337-
return bestindex;
338-
}
339-
340307
static int ab3100_set_voltage_regulator_sel(struct regulator_dev *reg,
341308
unsigned selector)
342309
{
@@ -383,7 +350,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg,
383350
return -EINVAL;
384351

385352
/* LDO E and BUCK have special suspend voltages you can set */
386-
bestindex = ab3100_get_best_voltage_index(reg, uV, uV);
353+
bestindex = regulator_map_voltage_iterate(reg, uV, uV);
387354

388355
err = abx500_get_register_interruptible(abreg->dev, 0,
389356
targetreg, &regval);

0 commit comments

Comments
 (0)