Re: [PATCH v14 04/10] pwm: max7360: Add MAX7360 PWM support

Mathieu Dubois-Briand
2025-09-12T12:05:37Z

On Fri Sep 12, 2025 at 10:57 AM CEST, Uwe Kleine-König wrote:
> On Sun, Aug 24, 2025 at 01:57:23PM +0200, Mathieu Dubois-Briand wrote:
>> +static int max7360_pwm_round_waveform_tohw(struct pwm_chip *chip,
>> + struct pwm_device *pwm,
>> + const struct pwm_waveform *wf,
>> + void *_wfhw)
>> +{
>> + struct max7360_pwm_waveform *wfhw = _wfhw;
>> + u64 duty_steps;
>> +
>> + /*
>> + * Ignore user provided values for period_length_ns and duty_offset_ns:
>> + * we only support fixed period of MAX7360_PWM_PERIOD_NS and offset of 0.
>> + * Values from 0 to 254 as duty_steps will provide duty cycles of 0/256
>> + * to 254/256, while value 255 will provide a duty cycle of 100%.
>> + */
>> + if (wf->duty_length_ns >= MAX7360_PWM_PERIOD_NS) {
>> + duty_steps = MAX7360_PWM_MAX;
>> + } else {
>> + duty_steps = (u32)wf->duty_length_ns * MAX7360_PWM_STEPS / MAX7360_PWM_PERIOD_NS;
>> + if (duty_steps == MAX7360_PWM_MAX)
>> + duty_steps = MAX7360_PWM_MAX - 1;
>> + }
>> +
>> + wfhw->duty_steps = min(MAX7360_PWM_MAX, duty_steps);
>
> duty_steps is never bigger than MAX7360_PWM_MAX, isn't it? Then this can
> be simplified to just
>
> wfhw->duty_steps = duty_steps;
>

Ok, I reviewed this section and I do agree with you. I will prepare a
new patch to fix this line and will send it separately.

> Otherwise looks fine to me.
>
> To get this series forward, it's OK for me to apply the series as is via
> Lee's MFD tree and cope for this minor optimisation later. So:
>
> Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
>
> Best regards
> Uwe

Thanks,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering