diff options
author | Lee Jones <lee.jones@linaro.org> | 2015-07-09 11:35:28 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-07-09 13:54:25 -0400 |
commit | f3f6439d8635d783f145b321db3049369e745799 (patch) | |
tree | a3feb879bc6f2dc02e85b62ff1b9829dd55e6793 /drivers/regulator/pwm-regulator.c | |
parent | f747a1fe7848453957dbdf362a42d7a6735c6ff0 (diff) |
regulator: pwm-regulator: Small clean-ups
Remove over-bracketing, use framework API to fetch PWM period and
be more forthcoming that pwm_voltage_to_duty_cycle() actually returns
duty cycle as a percentage, rather than a register value.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/pwm-regulator.c')
-rw-r--r-- | drivers/regulator/pwm-regulator.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index d92e66772ec0..936e387cc532 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c | |||
@@ -92,13 +92,13 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev, | |||
92 | /** | 92 | /** |
93 | * Continuous voltage call-backs | 93 | * Continuous voltage call-backs |
94 | */ | 94 | */ |
95 | static int pwm_voltage_to_duty_cycle(struct regulator_dev *rdev, int req_uV) | 95 | static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int req_uV) |
96 | { | 96 | { |
97 | int min_uV = rdev->constraints->min_uV; | 97 | int min_uV = rdev->constraints->min_uV; |
98 | int max_uV = rdev->constraints->max_uV; | 98 | int max_uV = rdev->constraints->max_uV; |
99 | int diff = max_uV - min_uV; | 99 | int diff = max_uV - min_uV; |
100 | 100 | ||
101 | return 100 - ((((req_uV * 100) - (min_uV * 100)) / diff)); | 101 | return 100 - (((req_uV * 100) - (min_uV * 100)) / diff); |
102 | } | 102 | } |
103 | 103 | ||
104 | static int pwm_regulator_get_voltage(struct regulator_dev *rdev) | 104 | static int pwm_regulator_get_voltage(struct regulator_dev *rdev) |
@@ -114,14 +114,13 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev, | |||
114 | { | 114 | { |
115 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); | 115 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); |
116 | unsigned int ramp_delay = rdev->constraints->ramp_delay; | 116 | unsigned int ramp_delay = rdev->constraints->ramp_delay; |
117 | unsigned int period = pwm_get_period(drvdata->pwm); | ||
117 | int duty_cycle; | 118 | int duty_cycle; |
118 | int ret; | 119 | int ret; |
119 | 120 | ||
120 | duty_cycle = pwm_voltage_to_duty_cycle(rdev, min_uV); | 121 | duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV); |
121 | 122 | ||
122 | ret = pwm_config(drvdata->pwm, | 123 | ret = pwm_config(drvdata->pwm, (period / 100) * duty_cycle, period); |
123 | (drvdata->pwm->period / 100) * duty_cycle, | ||
124 | drvdata->pwm->period); | ||
125 | if (ret) { | 124 | if (ret) { |
126 | dev_err(&rdev->dev, "Failed to configure PWM\n"); | 125 | dev_err(&rdev->dev, "Failed to configure PWM\n"); |
127 | return ret; | 126 | return ret; |