Skip to content

Commit

Permalink
regulator: pwm: Fix calculation of voltage-to-duty cycle
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Laxman Dewangan authored and Mark Brown committed Mar 12, 2016
1 parent 92e963f commit 1aaab34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/pwm-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1aaab34

Please sign in to comment.