Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pwm: berlin: Ensure configuring period and duty_cycle isn't wrongly skipped

As the last call to berlin_pwm_apply() might have exited early if
state->enabled was false, the values for period and duty_cycle stored in
pwm->state might not have been written to hardware and it must be
ensured that they are configured before enabling the PWM.

Fixes: 30dffb42fcd4 ("pwm: berlin: Implement .apply() callback")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

authored by

Uwe Kleine-König and committed by
Thierry Reding
7d6d4aaf 25f70b8f

+3 -6
+3 -6
drivers/pwm/pwm-berlin.c
··· 190 190 return 0; 191 191 } 192 192 193 - if (state->period != pwm->state.period || 194 - state->duty_cycle != pwm->state.duty_cycle) { 195 - err = berlin_pwm_config(chip, pwm, state->duty_cycle, state->period); 196 - if (err) 197 - return err; 198 - } 193 + err = berlin_pwm_config(chip, pwm, state->duty_cycle, state->period); 194 + if (err) 195 + return err; 199 196 200 197 if (!enabled) 201 198 return berlin_pwm_enable(chip, pwm);