Skip to content

Commit 453e8b3

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: atmel: Fix duty cycle calculation in .get_state()
The CDTY register contains the number of inactive cycles. .apply() does this correctly, however .get_state() got this wrong. Fixes: 651b510 ("pwm: atmel: Implement .get_state()") Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 721b595 commit 453e8b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pwm/pwm-atmel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
319319

320320
cdty = atmel_pwm_ch_readl(atmel_pwm, pwm->hwpwm,
321321
atmel_pwm->data->regs.duty);
322-
tmp = (u64)cdty * NSEC_PER_SEC;
322+
tmp = (u64)(cprd - cdty) * NSEC_PER_SEC;
323323
tmp <<= pres;
324324
state->duty_cycle = DIV64_U64_ROUND_UP(tmp, rate);
325325

0 commit comments

Comments
 (0)