OSDN Git Service

pwm: Prevent a glitch for legacy drivers
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 1 Jul 2021 07:29:26 +0000 (09:29 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 17 Nov 2021 16:09:22 +0000 (17:09 +0100)
commit92f69e582e15bf281ff1ab3ccc7abdd8392550a3
tree763625b54e2b8fe4dde2269972c9754d19e7bfac
parent77965c98cffe41994dce3389c4aae80e2072f098
pwm: Prevent a glitch for legacy drivers

If a running PWM is reconfigured to disabled calling the ->config()
callback before disabling the hardware might result in a glitch where
the (maybe) new period and duty_cycle are visible on the output before
disabling the hardware.

So handle disabling before calling ->config(). Also exit early in this case
which is possible because period and duty_cycle don't matter for disabled PWMs.
In return however ->config has to be called even if state->period ==
pwm->state.period && state->duty_cycle != pwm->state.duty_cycle because setting
these might have been skipped in the previous call.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/core.c