regulator: pwm: Fix calculation of voltage-to-duty cycle
authorLaxman Dewangan <ldewangan@nvidia.com>
Tue, 8 Mar 2016 10:53:21 +0000 (16:23 +0530)
committerMark Brown <broonie@kernel.org>
Sat, 12 Mar 2016 06:07:09 +0000 (13:07 +0700)
With following equation for calculating
voltage_to_duty_cycle_percentage
100 - (((req_uV * 100) - (min_uV * 100)) / diff);

we get 0% for max_uV and 100% for min_uV.

Correcting this to
((req_uV * 100) - (min_uV * 100)) / diff;
 to get proper duty cycle.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/pwm-regulator.c

index 3aca067b990114f7e0618fdfb963d6f66c21c37a..4d8eb3506dc8bba01c8a4f3fbdb2ec621d186c8c 100644 (file)
@@ -115,7 +115,7 @@ static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int
        int max_uV = rdev->constraints->max_uV;
        int diff = max_uV - min_uV;
 
-       return 100 - (((req_uV * 100) - (min_uV * 100)) / diff);
+       return ((req_uV * 100) - (min_uV * 100)) / diff;
 }
 
 static int pwm_regulator_get_voltage(struct regulator_dev *rdev)