regulator: core: Properly handle the case min_uV < rdev->desc->min_uV in map_voltage_...
authorAxel Lin <axel.lin@gmail.com>
Thu, 7 Jun 2012 01:52:12 +0000 (09:52 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 7 Jun 2012 23:15:55 +0000 (07:15 +0800)
Properly handle the case if the specified min_uV is less than the voltage given
by the lowest selector.

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

index 7584a74eec8a4f7706a59e9013e40bab34d30ef8..09a737c868b573227d22226926a081f35a29e6b2 100644 (file)
@@ -2050,6 +2050,9 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
                return -EINVAL;
        }
 
+       if (min_uV < rdev->desc->min_uV)
+               min_uV = rdev->desc->min_uV;
+
        ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
        if (ret < 0)
                return ret;