Re: [PATCH v6 2/2] pwm: add support for NXPs high-side switch MC33XS2410
From: Uwe Kleine-König
Date: Wed Nov 06 2024 - 03:14:01 EST
On Mon, Nov 04, 2024 at 02:07:53PM +0100, Dimitri Fedrau wrote:
> Am Mon, Nov 04, 2024 at 09:52:51AM +0100 schrieb Uwe Kleine-König:
> > `echo 0 > /sys/class/pwm/pwmchip3/pwm0/duty_cycle` should result in
> > MC33XS2410_PWM_CTRL3 having MC33XS2410_PWM_CTRL3_EN(pwm->hwpwm) cleared.
> > When mc33xs2410_pwm_get_state() is called then it returns state->enabled
> > = false and in that case the above mentioned warning doesn't trigger.
>
> Yes, as you explained. But the warning is shown.
>
> > Where is the misunderstanding?
>
> if (state->enabled && state->duty_cycle < s2.duty_cycle)
> dev_warn(pwmchip_parent(chip),
> ".apply is supposed to round down duty_cycle (requested: %llu/%llu, applied: %llu/%llu)\n",
> state->duty_cycle, state->period,
> s2.duty_cycle, s2.period);
>
> state has previously applied settings and is parameter of pwm_apply_debug,
> in that case s2=s1, and s1 is returned by get_state:
>
> state->enabled=true
> state->duty_cycle=0
> s2.enabled=false
> s2.duty_cycle=1908
>
> Due to the code the warning should be raised. If it shouldn't the check
> should be different, something like if (state->enabled && s2.enabled &&
> ...)
This should be fixed with https://lore.kernel.org/linux-pwm/20241105153521.1001864-2-u.kleine-koenig@xxxxxxxxxxxx/T/#u
Test feedback and review very welcome.
Best regards
Uwe
Attachment:
signature.asc
Description: PGP signature