diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-03-08 05:53:21 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-12 01:07:09 -0500 |
commit | 1aaab34878ac14efede3f0e737b99447745699d1 (patch) | |
tree | 3bfb7728506b912b19b84c5d5c4d4bfa5445dd3f /drivers/regulator | |
parent | 92e963f50fc74041b5e9e744c330dca48e04f08d (diff) |
regulator: pwm: Fix calculation of voltage-to-duty cycle
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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/pwm-regulator.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 3aca067b9901..4d8eb3506dc8 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c | |||
@@ -115,7 +115,7 @@ static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int | |||
115 | int max_uV = rdev->constraints->max_uV; | 115 | int max_uV = rdev->constraints->max_uV; |
116 | int diff = max_uV - min_uV; | 116 | int diff = max_uV - min_uV; |
117 | 117 | ||
118 | return 100 - (((req_uV * 100) - (min_uV * 100)) / diff); | 118 | return ((req_uV * 100) - (min_uV * 100)) / diff; |
119 | } | 119 | } |
120 | 120 | ||
121 | static int pwm_regulator_get_voltage(struct regulator_dev *rdev) | 121 | static int pwm_regulator_get_voltage(struct regulator_dev *rdev) |