Skip to content

Commit

Permalink
pwm: sifive: Use 64-bit division macro
Browse files Browse the repository at this point in the history
Since the PWM framework is switching struct pwm_args.period's datatype
to u64, prepare for this transition by using DIV64_U64_ROUND_CLOSEST to
handle a 64-bit divisor.

Signed-off-by: Guru Das Srinagesh <[email protected]>
Acked-by: Palmer Dabbelt <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
  • Loading branch information
Guru Das Srinagesh authored and thierryreding committed Jun 17, 2020
1 parent 5bc5d99 commit 4cc2343
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/pwm/pwm-sifive.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
* consecutively
*/
num = (u64)duty_cycle * (1U << PWM_SIFIVE_CMPWIDTH);
frac = DIV_ROUND_CLOSEST_ULL(num, state->period);
frac = DIV64_U64_ROUND_CLOSEST(num, state->period);
/* The hardware cannot generate a 100% duty cycle */
frac = min(frac, (1U << PWM_SIFIVE_CMPWIDTH) - 1);

Expand Down

0 comments on commit 4cc2343

Please sign in to comment.