Re: [PATCH v7 2/5] pwm: Add Apple PWM controller

From: Uwe Kleine-König
Date: Fri Mar 10 2023 - 12:40:04 EST


Hello,

On Sat, Jan 14, 2023 at 04:25:05PM +0300, Sasha Finkelstein 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)
> + return -ERANGE;

The idea is to configure the biggest duty_cycle that is not bigger than
the requested duty_cycle. So don't return an error here, but use
0xffffffff instead.

I should have catched that in my v4 and my v6 review, sorry, I missed
that.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature