Skip to content

Commit 25f70b8

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: tiecap: Ensure configuring period and duty_cycle isn't wrongly skipped
As the last call to ecap_pwm_apply() might have exited early if state->enabled was false, the values for period and duty_cycle stored in pwm->state might not have been written to hardware and it must be ensured that they are configured before enabling the PWM. Fixes: 0ca7acd ("pwm: tiecap: Implement .apply() callback") Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent fe8255f commit 25f70b8

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

drivers/pwm/pwm-tiecap.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,13 @@ static int ecap_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
189189
return 0;
190190
}
191191

192-
if (state->period != pwm->state.period ||
193-
state->duty_cycle != pwm->state.duty_cycle) {
194-
if (state->period > NSEC_PER_SEC)
195-
return -ERANGE;
192+
if (state->period > NSEC_PER_SEC)
193+
return -ERANGE;
196194

197-
err = ecap_pwm_config(chip, pwm, state->duty_cycle,
198-
state->period, enabled);
199-
if (err)
200-
return err;
201-
}
195+
err = ecap_pwm_config(chip, pwm, state->duty_cycle,
196+
state->period, enabled);
197+
if (err)
198+
return err;
202199

203200
if (!enabled)
204201
return ecap_pwm_enable(chip, pwm);

0 commit comments

Comments
 (0)