Hello Sascha, On Fri, Mar 10, 2023 at 07:44:08PM +0100, Sasha Finkelstein via B4 Relay wrote: > +static int apple_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > + const struct pwm_state *state) > +{ > + struct apple_pwm *fpwm; > + > + if (state->polarity == PWM_POLARITY_INVERSED) > + return -EINVAL; > + > + fpwm = to_apple_pwm(chip); > + if (state->enabled) { > + u64 on_cycles, off_cycles; > + > + on_cycles = mul_u64_u64_div_u64(fpwm->clkrate, > + state->duty_cycle, NSEC_PER_SEC); > + if (on_cycles > 0xFFFFFFFF) > + on_cycles = 0xFFFFFFFF; > + > + off_cycles = mul_u64_u64_div_u64(fpwm->clkrate, > + state->period, NSEC_PER_SEC) - on_cycles; > + if (off_cycles > 0xFFFFFFFF) > + return -ERANGE; This is still wrong and needs clamping, too. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Attachment:
signature.asc
Description: PGP signature