regulator: core: Fix logic to determinate if regulator can change voltage
authorAxel Lin <axel.lin@ingics.com>
Tue, 11 Dec 2012 12:36:37 +0000 (20:36 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 11 Dec 2012 12:44:23 +0000 (21:44 +0900)
Having a linear_min_sel setting means the first linear_min_sel selectors are
invalid. We need to subtract linear_min_sel when use n_voltages to determinate
if regulator can change voltage.

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

index 1c8ff8ce5c57b471bfe4aca908b88ac80038637e..f3cdfe5810cc133cb4674f98039d836c294b4580 100644 (file)
@@ -1881,7 +1881,7 @@ int regulator_can_change_voltage(struct regulator *regulator)
 
        if (rdev->constraints &&
            rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE &&
-           rdev->desc->n_voltages > 1)
+           (rdev->desc->n_voltages - rdev->desc->linear_min_sel) > 1)
                return 1;
 
        return 0;